]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/calendar.pm
po plugin: replace tweakbestlink hook with a wrapper function
[git.ikiwiki.info.git] / IkiWiki / Plugin / calendar.pm
index 0bb0e81fdc77c0eaf52da7ed06c31b70cf810ce3..6d536a91bb63a6e0a32f399844115e52208d5bdf 100644 (file)
@@ -30,28 +30,25 @@ my $time=time;
 my @now=localtime($time);
 
 sub import { #{{{
 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);
 } #}}}
 
        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
+               plugin => {
+                       safe => 1,
+                       rebuild => undef,
+               },
+               archivebase => {
+                       type => "string",
+                       example => "archives",
+                       description => "base of the archives hierarchy",
+                       safe => 1,
+                       rebuild => 1,
+               },
+} #}}}
 
 sub is_leap_year (@) { #{{{
        my %params=@_;
 
 sub is_leap_year (@) { #{{{
        my %params=@_;
@@ -400,4 +397,24 @@ sub preprocess (@) { #{{{
        return "\n<div><div class=\"calendar\">$calendar</div></div>\n";
 } #}}
 
        return "\n<div><div class=\"calendar\">$calendar</div></div>\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
 1