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

use warnings;
use strict;
use IkiWiki 2.00;

my $maxlines=200;

sub import { #{{{
	hook(type =&gt; "getsetup", id =&gt; "recentchangesdiff",
		call =&gt; \&amp;getsetup);
	hook(type =&gt; "pagetemplate", id =&gt; "recentchangesdiff",
		call =&gt; \&amp;pagetemplate);
} #}}}

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

sub pagetemplate (@) { #{{{
	my %params=@_;
	my $template=$params{template};
	if ($config{rcs} &amp;&amp; exists $params{rev} &amp;&amp; length $params{rev} &amp;&amp;
	    $template-&gt;query(name =&gt; "diff")) {
		my @lines=IkiWiki::rcs_diff($params{rev});
		if (@lines) {
			my $diff;
			if (@lines &gt; $maxlines) {
				# only include so many lines of diff
				$diff=join("", @lines[0..($maxlines-1)])."\n".
					gettext("(Diff truncated)");
			}
			else {
				$diff=join("", @lines);
			}
			# escape links and preprocessor stuff
			$diff =~ s/(?&lt;!\\)\[\[/\\\[\[/g;
			$template-&gt;param(diff =&gt; $diff);
		}
	}
} #}}}

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