]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/version.pm
pagespec_match_list * optimisation
[git.ikiwiki.info.git] / IkiWiki / Plugin / version.pm
index d39fd941966b35787c32910b988b938878de4792..587cd55fa8f608fc2309d23eaa91ad1e32539c62 100644 (file)
@@ -4,21 +4,31 @@ 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}) {
                        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 +36,11 @@ sub needsbuild (@) { #{{{
                        }
                }
        }
-} # }}}
+}
 
-sub preprocess (@) { #{{{
+sub preprocess (@) {
        my %params=@_;
        $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
-} # }}}
+}
 
 1