wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / dynlogo.pl
blobf4fdda78c04b6d0c039a920320e08be08f16b584
1 # Copyright (C) 2004 Sebastian Blatt <sblatt@havens.de>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 # Makes the wiki logo depend on the current date.
21 # Example Usage: Put the following into your config file and modify as
22 # needed:
24 # $DynLogoDirectory = '/mypic/dynlogo';
25 # $DynLogoDefault = 'wiki.jpg';
26 # %DynLogoMap = ('\d{4}-12-31' => 'party.jpg');
27 # $LogoUrl = GetDynLogoUrl();
30 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dynlogo.pl">dynlogo.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dynamic_Logo">Dynamic Logo</a></p>';
32 use vars qw($DynLogoDirectory $DynLogoDefault %DynLogoMap);
34 # Directory to search for images.
35 $DynLogoDirectory = '/pic/dynlogo';
37 # Default logo in the $DynLogoDirectory.
38 $DynLogoDefault = 'logo.png';
40 # This maps a regular expression matching a date string of the form
41 # "%Y-%m-%d" to a filename in the $DynLogoDirectory. Example usage:
42 # %DynLogoMap = ('\d{4}-12-24'=>'logo-1224.jpg');
43 %DynLogoMap = ();
45 sub GetDynLogoUrl {
46 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime(time);
47 my $today = sprintf("%d-%02d-%02d", $year + 1900, $mon + 1, $mday);
48 foreach $k(keys(%DynLogoMap)) {
49 if ($today=~m/$k/) {
50 return $DynLogoDirectory."/".$DynLogoMap{$k};
53 return "$DynLogoDirectory/$DynLogoDefault";