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();
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 if (! defined $pagespec) {
31 $pagespec=$config{archive_pagespec} || "*";
34 sub writearchive ($$;$) {
35 my $template=template(shift);
39 my $page=defined $month ? "$year/$month" : $year;
41 my $pagefile=newpagefile("$archivebase/$page", $config{default_pageext});
42 $template->param(pagespec => $pagespec);
43 $template->param(year => $year);
44 $template->param(month => $month) if defined $month;
46 if ($force || ! -e "$config{srcdir}/$pagefile") {
47 writefile($pagefile, $config{srcdir}, $template->output);
48 IkiWiki::rcs_add($pagefile) if $config{rcs};
52 foreach my $y ($startyear..$endyear) {
53 writearchive("calendaryear.tmpl", $y);
54 foreach my $m (qw{01 02 03 04 05 06 07 08 09 10 11 12}) {
55 writearchive("calendarmonth.tmpl", $y, $m);
59 IkiWiki::rcs_commit_staged(gettext("calendar update"), undef, undef)
62 system("ikiwiki", "-setup", $setup, "-refresh");