]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/version.pm
add code to delete old change pages
[git.ikiwiki.info.git] / IkiWiki / Plugin / version.pm
1 #!/usr/bin/perl
2 # Ikiwiki version plugin.
3 package IkiWiki::Plugin::version;
5 use warnings;
6 use strict;
7 use IkiWiki 2.00;
9 sub import { #{{{
10         hook(type => "needsbuild", id => "version", call => \&needsbuild);
11         hook(type => "preprocess", id => "version", call => \&preprocess);
12 } # }}}
14 sub needsbuild (@) { #{{{
15         my $needsbuild=shift;
16         foreach my $page (keys %pagestate) {
17                 if (exists $pagestate{$page}{version}{shown}) {
18                         if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) {
19                                 push @$needsbuild, $pagesources{$page};
20                         }
21                         if (grep { $_ eq $pagesources{$page} } @$needsbuild) {
22                                 # remove state, will be re-added if
23                                 # the version is still shown during the
24                                 # rebuild
25                                 delete $pagestate{$page}{version}{shown};
26                         }
27                 }
28         }
29 } # }}}
31 sub preprocess (@) { #{{{
32         my %params=@_;
33         $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
34 } # }}}
36 1