X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/5023f2301d42319cb552102c532452b8fb4744af..52bbdbb1a5ce994c9afac253c1d9bfd94acf4d1d:/IkiWiki/Plugin/calendar.pm diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 91aff1ea7..dd6898c57 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -30,28 +30,21 @@ my $time=time; my @now=localtime($time); sub import { #{{{ - hook(type => "needsbuild", id => "version", call => \&needsbuild); + hook(type => "getsetup", id => "calendar", call => \&getsetup); + hook(type => "needsbuild", id => "calendar", call => \&needsbuild); hook(type => "preprocess", id => "calendar", call => \&preprocess); } #}}} -sub needsbuild (@) { #{{{ - my $needsbuild=shift; - foreach my $page (keys %pagestate) { - if (exists $pagestate{$page}{calendar}{nextchange}) { - if ($pagestate{$page}{calendar}{nextchange} >= $time) { - # force a rebuild so the calendar shows - # the current day - push @$needsbuild, $pagesources{$page}; - } - if (grep { $_ eq $pagesources{$page} } @$needsbuild) { - # remove state, will be re-added if - # the calendar is still there during the - # rebuild - delete $pagestate{$page}{calendar}; - } - } - } -} # }}} +sub getsetup () { #{{{ + return + archivebase => { + type => "string", + default => "archives", + description => "base of the archives hierarchy", + safe => 1, + rebuild => 1, + }, +} #}}} sub is_leap_year (@) { #{{{ my %params=@_; @@ -400,4 +393,24 @@ sub preprocess (@) { #{{{ return "\n
$calendar
\n"; } #}} +sub needsbuild (@) { #{{{ + my $needsbuild=shift; + foreach my $page (keys %pagestate) { + if (exists $pagestate{$page}{calendar}{nextchange}) { + if ($pagestate{$page}{calendar}{nextchange} <= $time) { + # force a rebuild so the calendar shows + # the current day + push @$needsbuild, $pagesources{$page}; + } + if (exists $pagesources{$page} && + grep { $_ eq $pagesources{$page} } @$needsbuild) { + # remove state, will be re-added if + # the calendar is still there during the + # rebuild + delete $pagestate{$page}{calendar}; + } + } + } +} # }}} + 1