]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/version.pm
po plugin: reworked available options
[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 => "getsetup", id => "version", call => \&getsetup);
11         hook(type => "needsbuild", id => "version", call => \&needsbuild);
12         hook(type => "preprocess", id => "version", call => \&preprocess);
13 } # }}}
15 sub getsetup () { #{{{
16         return
17                 plugin => {
18                         safe => 1,
19                         rebuild => undef,
20                 },
21 } #}}}
23 sub needsbuild (@) { #{{{
24         my $needsbuild=shift;
25         foreach my $page (keys %pagestate) {
26                 if (exists $pagestate{$page}{version}{shown}) {
27                         if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) {
28                                 push @$needsbuild, $pagesources{$page};
29                         }
30                         if (exists $pagesources{$page} &&
31                             grep { $_ eq $pagesources{$page} } @$needsbuild) {
32                                 # remove state, will be re-added if
33                                 # the version is still shown during the
34                                 # rebuild
35                                 delete $pagestate{$page}{version}{shown};
36                         }
37                 }
38         }
39 } # }}}
41 sub preprocess (@) { #{{{
42         my %params=@_;
43         $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
44 } # }}}
46 1