]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/version.pm
rssurl and atomurl are only needed where $feeds is set
[ikiwiki.git] / 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 (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 } # }}}
30
31 sub preprocess (@) { #{{{
32         my %params=@_;
33         $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
34 } # }}}
35
36 1