Merge branch 'master' of git://git.ikiwiki.info into aggregateinternal
[ikiwiki] / IkiWiki / Plugin / version.pm
1 #!/usr/bin/perl
2 # Ikiwiki version plugin.
3 package IkiWiki::Plugin::version;
4
5 use warnings;
6 use strict;
7 use IkiWiki 2.00;
8
9 sub import { #{{{
10         hook(type => "needsbuild", id => "version", call => \&needsbuild);
11         hook(type => "preprocess", id => "version", call => \&preprocess);
12 } # }}}
13
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 (exists $pagesources{$page} &&
22                             grep { $_ eq $pagesources{$page} } @$needsbuild) {
23                                 # remove state, will be re-added if
24                                 # the version is still shown during the
25                                 # rebuild
26                                 delete $pagestate{$page}{version}{shown};
27                         }
28                 }
29         }
30 } # }}}
31
32 sub preprocess (@) { #{{{
33         my %params=@_;
34         $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
35 } # }}}
36
37 1