weblog-1.pl 2.1 KB

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