aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/recentchangesdiff.pm
diff options
context:
space:
mode:
Diffstat (limited to 'IkiWiki/Plugin/recentchangesdiff.pm')
-rw-r--r--IkiWiki/Plugin/recentchangesdiff.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/recentchangesdiff.pm b/IkiWiki/Plugin/recentchangesdiff.pm
new file mode 100644
index 000000000..bd2826f76
--- /dev/null
+++ b/IkiWiki/Plugin/recentchangesdiff.pm
@@ -0,0 +1,27 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::recentchangesdiff;
+
+use warnings;
+use strict;
+use IkiWiki 2.00;
+
+sub import { #{{{
+ hook(type => "pagetemplate", id => "recentchangesdiff",
+ call => \&pagetemplate);
+} #}}}
+
+sub pagetemplate (@) { #{{{
+ my %params=@_;
+ my $template=$params{template};
+ if ($config{rcs} && exists $params{rev} && length $params{rev} &&
+ $template->query(name => "diff")) {
+ my $diff=IkiWiki::rcs_diff($params{rev});
+ if (defined $diff && length $diff) {
+ # escape links and preprocessor stuff
+ $diff =~ s/(?<!\\)\[\[/\\\[\[/g;
+ $template->param(diff => $diff);
+ }
+ }
+} #}}}
+
+1