9 die gettext("usage: ikiwiki-calendar [-f] your.setup [pagespec] [year]"), "\n";
16 my $setup=shift || usage();
17 my $pagespec=shift || "*";
18 my $startyear=shift || 1900+(localtime(time))[5];
19 my $endyear=shift || $startyear;
21 %config=IkiWiki::defaultconfig();
22 IkiWiki::Setup::load($setup);
23 IkiWiki::loadplugins();
24 IkiWiki::checkconfig();
26 my $archivebase = 'archives';
27 $archivebase = $config{archivebase} if defined $config{archivebase};
29 sub writearchive ($$;$) {
30 my $template=template(shift);
34 my $page=defined $month ? "$year/$month" : $year;
36 my $pagefile=newpagefile("$archivebase/$page", $config{default_pageext});
37 $template->param(pagespec => $pagespec);
38 $template->param(year => $year);
39 $template->param(month => $month) if defined $month;
41 if ($force || ! -e "$config{srcdir}/$pagefile") {
42 writefile($pagefile, $config{srcdir}, $template->output);
43 IkiWiki::rcs_add($pagefile) if $config{rcs};
47 foreach my $y ($startyear..$endyear) {
48 writearchive("calendaryear.tmpl", $y);
49 foreach my $m (qw{01 02 03 04 05 06 07 08 09 10 11 12}) {
50 writearchive("calendarmonth.tmpl", $y, $m);
54 IkiWiki::rcs_commit_staged(gettext("calendar update"), undef, undef)
57 system("ikiwiki", "-setup", $setup, "-refresh");