Files
oddmuse/modules/weblog-2.pl

42 lines
1.7 KiB
Perl
Raw Normal View History

# Copyright (C) 20042014 Alex Schroeder <alex@gnu.org>
2004-01-30 21:35:44 +00:00
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
2004-01-30 21:35:44 +00:00
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
2004-01-30 21:35:44 +00:00
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
2004-01-30 21:35:44 +00:00
use strict;
use v5.10;
2004-01-30 11:53:18 +00:00
use Time::ParseDate;
AddModuleDescription('weblog-2.pl', 'Complex Weblog Extension');
2004-01-30 11:53:18 +00:00
2015-04-10 13:31:28 +03:00
our ($q, @MyInitVariables, @UserGotoBarPages);
2005-01-04 09:52:44 +00:00
push(@MyInitVariables, \&WebLog2Init);
2004-01-30 11:53:18 +00:00
2005-01-04 09:52:44 +00:00
sub WebLog2Init {
my $id = GetId();
my ($sec, $min, $hour, $mday, $mon, $year) = localtime; # CalcDay uses gmtime!
my $today = sprintf('%4d-%02d-%02d', $year + 1900, $mon + 1, $mday);
my ($current) = ($id =~ m|^(\d\d\d\d-\d\d-\d\d)|);
2004-01-30 11:53:18 +00:00
if ($current and $current ne $today) {
my $time = parsedate($current, GMT => 1);
($sec,$min,$hour,$mday,$mon,$year) = localtime($time - 60*60*24);
my $previous = sprintf("%4d-%02d-%02d", $year + 1900, $mon + 1, $mday);
($sec,$min,$hour,$mday,$mon,$year) = localtime($time + 60*60*24);
my $next = sprintf("%4d-%02d-%02d", $year + 1900, $mon + 1, $mday);
2004-01-30 11:53:18 +00:00
push(@UserGotoBarPages,$next) unless grep(/^$next$/, @UserGotoBarPages);
push(@UserGotoBarPages,$current) unless grep(/^$current$/, @UserGotoBarPages);
push(@UserGotoBarPages,$previous) unless grep(/^$previous$/, @UserGotoBarPages);
}
}