4 use lib
'.'; # For use in nonstandard directory, munged by Makefile.
10 die gettext
("usage: ikiwiki-calendar [-f] your.setup [pagespec] [year]"), "\n";
17 my $setup=shift || usage
();
18 my $pagespec=shift || "*";
19 my $startyear=shift || 1900+(localtime(time))[5];
20 my $endyear=shift || $startyear;
22 %config=IkiWiki
::defaultconfig
();
23 IkiWiki
::Setup
::load
($setup);
24 IkiWiki
::loadplugins
();
25 IkiWiki
::checkconfig
();
27 my $archivebase = 'archives';
28 $archivebase = $config{archivebase
} if defined $config{archivebase
};
30 sub writearchive
($$;$) {
31 my $template=template
(shift);
35 my $page=defined $month ?
"$year/$month" : $year;
37 my $pagefile=newpagefile
("$archivebase/$page", $config{default_pageext
});
38 $template->param(pagespec
=> $pagespec);
39 $template->param(year
=> $year);
40 $template->param(month
=> $month) if defined $month;
42 if ($force || ! -e
"$config{srcdir}/$pagefile") {
43 writefile
($pagefile, $config{srcdir
}, $template->output);
44 IkiWiki
::rcs_add
($pagefile) if $config{rcs
};
48 foreach my $y ($startyear..$endyear) {
49 writearchive
("calendaryear.tmpl", $y);
50 foreach my $m (qw{01 02 03 04 05 06 07 08 09 10 11 12}) {
51 writearchive
("calendarmonth.tmpl", $y, $m);
55 IkiWiki
::rcs_commit_staged
(gettext
("calendar update"), undef, undef)
58 system("ikiwiki", "-setup", $setup, "-refresh");