]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/version.pm
po: new po_translation_status_in_links option
[git.ikiwiki.info.git] / IkiWiki / Plugin / version.pm
index 0e8d7b5e71a03d3844e15c0b28540fcfb2794487..3526dafde5bb4df0403aebda6c9bca5e3aadb86e 100644 (file)
@@ -6,24 +6,41 @@ use warnings;
 use strict;
 use IkiWiki 2.00;
 
 use strict;
 use IkiWiki 2.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);
        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) {
        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;
        my %params=@_;
        $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
-} # }}}
+}
 
 1
 
 1