X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/b4b452f4ee73fb67c6ff0aa761783def7483313b..5c0e56d149c6b33d010561f64f583e7ad1c529da:/IkiWiki/Plugin/version.pm?ds=inline diff --git a/IkiWiki/Plugin/version.pm b/IkiWiki/Plugin/version.pm index 0e8d7b5e7..587cd55fa 100644 --- a/IkiWiki/Plugin/version.pm +++ b/IkiWiki/Plugin/version.pm @@ -4,26 +4,43 @@ 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, + }, +} + +sub needsbuild (@) { my $needsbuild=shift; foreach my $page (keys %pagestate) { - if (exists $pagestate{$page}{version}{shown} && - $pagestate{$page}{version}{shown} ne $IkiWiki::version) { - push @$needsbuild, $pagesources{$page}; + if (exists $pagestate{$page}{version}{shown}) { + if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) { + push @$needsbuild, $pagesources{$page}; + } + if (exists $pagesources{$page} && + grep { $_ eq $pagesources{$page} } @$needsbuild) { + # remove state, will be re-added if + # the version is still shown during the + # rebuild + delete $pagestate{$page}{version}{shown}; + } } } -} # }}} +} -sub preprocess (@) { #{{{ +sub preprocess (@) { my %params=@_; $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version; -} # }}} +} 1