dynlogo.pl 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright (C) 2004 Sebastian Blatt <sblatt@havens.de>
  2. #
  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.
  7. #
  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.
  12. #
  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
  18. # Makes the wiki logo depend on the current date.
  19. #
  20. # Example Usage: Put the following into your config file and modify as
  21. # needed:
  22. #
  23. # $DynLogoDirectory = '/mypic/dynlogo';
  24. # $DynLogoDefault = 'wiki.jpg';
  25. # %DynLogoMap = ('\d{4}-12-31' => 'party.jpg');
  26. # $LogoUrl = GetDynLogoUrl();
  27. #
  28. use strict;
  29. use v5.10;
  30. AddModuleDescription('dynlogo.pl', 'Dynamic Logo');
  31. our ($DynLogoDirectory, $DynLogoDefault, %DynLogoMap);
  32. # Directory to search for images.
  33. $DynLogoDirectory = '/pic/dynlogo';
  34. # Default logo in the $DynLogoDirectory.
  35. $DynLogoDefault = 'logo.png';
  36. # This maps a regular expression matching a date string of the form
  37. # "%Y-%m-%d" to a filename in the $DynLogoDirectory. Example usage:
  38. # %DynLogoMap = ('\d{4}-12-24'=>'logo-1224.jpg');
  39. %DynLogoMap = ();
  40. sub GetDynLogoUrl {
  41. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime(time);
  42. my $today = sprintf("%d-%02d-%02d", $year + 1900, $mon + 1, $mday);
  43. foreach my $k (keys(%DynLogoMap)) {
  44. if ($today=~m/$k/) {
  45. return $DynLogoDirectory."/".$DynLogoMap{$k};
  46. }
  47. }
  48. return "$DynLogoDirectory/$DynLogoDefault";
  49. }