<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# Ikiwiki version plugin.
package IkiWiki::Plugin::version;

use warnings;
use strict;
use IkiWiki 3.00;

sub import {
	hook(type =&gt; "getsetup", id =&gt; "version", call =&gt; \&amp;getsetup);
	hook(type =&gt; "needsbuild", id =&gt; "version", call =&gt; \&amp;needsbuild);
	hook(type =&gt; "preprocess", id =&gt; "version", call =&gt; \&amp;preprocess);
}

sub getsetup () {
	return
		plugin =&gt; {
			safe =&gt; 1,
			rebuild =&gt; undef,
		},
}

sub needsbuild (@) {
	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} &amp;&amp;
			    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};
			}
		}
	}
}

sub preprocess (@) {
	my %params=@_;
	$pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
}

1
</pre></body></html>