X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/a829e5b8650743aac227331db657ba1e87737426..9a1c60c9c63eafe11b9e6d14329c76e97d2c9f11:/IkiWiki/Plugin/version.pm diff --git a/IkiWiki/Plugin/version.pm b/IkiWiki/Plugin/version.pm index d39fd9419..fc265526c 100644 --- a/IkiWiki/Plugin/version.pm +++ b/IkiWiki/Plugin/version.pm @@ -4,21 +4,32 @@ package IkiWiki::Plugin::version; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; -sub import { #{{{ +sub import { + hook(type => "getsetup", id => "version", call => \&getsetup); hook(type => "needsbuild", id => "version", call => \&needsbuild); hook(type => "preprocess", id => "version", call => \&preprocess); -} # }}} +} -sub needsbuild (@) { #{{{ +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => undef, + section => "widget", + }, +} + +sub needsbuild (@) { my $needsbuild=shift; foreach my $page (keys %pagestate) { if (exists $pagestate{$page}{version}{shown}) { if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) { push @$needsbuild, $pagesources{$page}; } - if (grep { $_ eq $pagesources{$page} } @$needsbuild) { + if (exists $pagesources{$page} && + grep { $_ eq $pagesources{$page} } @$needsbuild) { # remove state, will be re-added if # the version is still shown during the # rebuild @@ -26,11 +37,12 @@ sub needsbuild (@) { #{{{ } } } -} # }}} + return $needsbuild; +} -sub preprocess (@) { #{{{ +sub preprocess (@) { my %params=@_; $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version; -} # }}} +} 1