weblog-1.pl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2004, 2005 Alex Schroeder <alex@emacswiki.org>
  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 3 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, see <http://www.gnu.org/licenses/>.
  15. use strict;
  16. use v5.10;
  17. our (@MyInitVariables, $UserGotoBar, @UserGotoBarPages, $CommentsPrefix, $EditAllowed);
  18. our ($WeblogTextLogo, $WeblogXmlLogo);
  19. $WeblogXmlLogo = '/images/rss.png';
  20. $WeblogTextLogo = '/images/txt.png';
  21. AddModuleDescription('weblog-1.pl', 'Minimal Weblog Extension');
  22. $CommentsPrefix = 'Comments_on_'; # TODO huh? But that's the default value, right?
  23. $EditAllowed = 2;
  24. push(@MyInitVariables, \&WebLog1Init);
  25. sub WebLog1Init {
  26. if (GetParam('blog', 1)) { # language independent!
  27. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime(time);
  28. my $today = sprintf("%d-%02d-%02d", $year + 1900, $mon + 1, $mday);
  29. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime(time - 60*60*24);
  30. my $yesterday = sprintf("%d-%02d-%02d", $year + 1900, $mon + 1, $mday);
  31. # this modification is not mod_perl safe!
  32. my $blog = T('Blog');
  33. push(@UserGotoBarPages, $blog) unless grep (/^$blog$/, @UserGotoBarPages);
  34. push(@UserGotoBarPages, $today) unless grep (/^$today$/, @UserGotoBarPages);
  35. push(@UserGotoBarPages, $yesterday) unless grep (/^$yesterday$/, @UserGotoBarPages);
  36. $UserGotoBar .=
  37. ScriptLink('action=rss',
  38. "<img src=\"$WeblogXmlLogo\" alt=\"XML\" class=\"XML\" />")
  39. . ' '. ScriptLink('action=rc;raw=1',
  40. "<img src=\"$WeblogTextLogo\" alt=\"TXT\" class=\"XML\" />");
  41. }
  42. }