9 die gettext("usage: ikiwiki-calendar [-f] your.setup [pagespec] [year]"), "\n";
16 my $setup=shift || usage();
17 my $pagespec=shift || "*";
18 my $year=shift || 1900+(localtime(time))[5];
20 %config=IkiWiki::defaultconfig();
21 IkiWiki::Setup::load($setup);
22 IkiWiki::loadplugins();
23 IkiWiki::checkconfig();
25 my $archivebase = 'archives';
26 $archivebase = $config{archivebase} if defined $config{archivebase};
28 sub writearchive ($$;$) {
29 my $template=template(shift);
33 my $page=defined $month ? "$year/$month" : $year;
35 my $pagefile=newpagefile("$archivebase/$page", $config{default_pageext});
36 $template->param(pagespec => $pagespec);
37 $template->param(year => $year);
38 $template->param(month => $month) if defined $month;
40 if ($force || ! -e "$config{srcdir}/$pagefile") {
41 writefile($pagefile, $config{srcdir}, $template->output);
42 IkiWiki::rcs_add($pagefile) if $config{rcs};
48 foreach my $y ($year-1, $year, $year+1) {
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)
57 IkiWiki::unlockwiki();
59 system("ikiwiki", "-setup", $setup, "-refresh");