ikiwiki/IkiWiki/Plugin/version.pm

49 lines
1.0 KiB
Perl
Raw Normal View History

2007-12-09 01:05:01 +01:00
#!/usr/bin/perl
# Ikiwiki version plugin.
package IkiWiki::Plugin::version;
use warnings;
use strict;
use IkiWiki 3.00;
2007-12-09 01:05:01 +01:00
sub import {
hook(type => "getsetup", id => "version", call => \&getsetup);
2007-12-09 01:05:01 +01:00
hook(type => "needsbuild", id => "version", call => \&needsbuild);
hook(type => "preprocess", id => "version", call => \&preprocess);
}
2007-12-09 01:05:01 +01:00
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
2010-02-12 12:35:52 +01:00
section => "widget",
},
}
sub needsbuild (@) {
2007-12-09 01:05:01 +01:00
my $needsbuild=shift;
foreach my $page (keys %pagestate) {
if (exists $pagestate{$page}{version}{shown}) {
if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) {
push @$needsbuild, $pagesources{$page};
}
if (exists $pagesources{$page} &&
grep { $_ eq $pagesources{$page} } @$needsbuild) {
# remove state, will be re-added if
# the version is still shown during the
# rebuild
delete $pagestate{$page}{version}{shown};
}
2007-12-09 01:05:01 +01:00
}
}
return $needsbuild;
}
2007-12-09 01:05:01 +01:00
sub preprocess (@) {
2007-12-09 01:05:01 +01:00
my %params=@_;
$pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
}
2007-12-09 01:05:01 +01:00
1