ready for review, I think
[ikiwiki.git] / IkiWiki / Plugin / version.pm
blobc13643478ab25012c5aacab3f0c9ca43aa2b2689
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};
42 sub preprocess (@) {
43 my %params=@_;
44 $pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;