Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki.git] / IkiWiki / Plugin / version.pm
blobfc265526c15e41682efec8c7702d3a54e5efcf17
1 #!/usr/bin/perl
2 # Ikiwiki version plugin.
3 package IkiWiki::Plugin::version;
5 use warnings;
6 use strict;
7 use IkiWiki 3.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);
15 sub getsetup () {
16 return
17 plugin => {
18 safe => 1,
19 rebuild => undef,
20 section => "widget",
24 sub needsbuild (@) {
25 my $needsbuild=shift;
26 foreach my $page (keys %pagestate) {
27 if (exists $pagestate{$page}{version}{shown}) {
28 if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) {
29 push @$needsbuild, $pagesources{$page};
31 if (exists $pagesources{$page} &&
32 grep { $_ eq $pagesources{$page} } @$needsbuild) {
33 # remove state, will be re-added if
34 # the version is still shown during the
35 # rebuild
36 delete $pagestate{$page}{version}{shown};
40 return $needsbuild;
43 sub preprocess (@) {
44 my %params=@_;
45 $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;