2007-12-09 01:05:01 +01:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# Ikiwiki version plugin.
|
|
|
|
package IkiWiki::Plugin::version;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-12-23 22:34:19 +01:00
|
|
|
use IkiWiki 3.00;
|
2007-12-09 01:05:01 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub import {
|
2008-08-04 01:35:35 +02:00
|
|
|
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);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-12-09 01:05:01 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup () {
|
2008-08-04 01:35:35 +02:00
|
|
|
return
|
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => undef,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-08-04 01:35:35 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub needsbuild (@) {
|
2007-12-09 01:05:01 +01:00
|
|
|
my $needsbuild=shift;
|
|
|
|
foreach my $page (keys %pagestate) {
|
2007-12-09 01:12:50 +01:00
|
|
|
if (exists $pagestate{$page}{version}{shown}) {
|
|
|
|
if ($pagestate{$page}{version}{shown} ne $IkiWiki::version) {
|
|
|
|
push @$needsbuild, $pagesources{$page};
|
|
|
|
}
|
2008-01-29 23:36:25 +01:00
|
|
|
if (exists $pagesources{$page} &&
|
|
|
|
grep { $_ eq $pagesources{$page} } @$needsbuild) {
|
2007-12-09 01:12:50 +01:00
|
|
|
# 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
|
|
|
}
|
|
|
|
}
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-12-09 01:05:01 +01:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub preprocess (@) {
|
2007-12-09 01:05:01 +01:00
|
|
|
my %params=@_;
|
|
|
|
$pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2007-12-09 01:05:01 +01:00
|
|
|
|
|
|
|
1
|