summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-03-03 15:53:34 -0500
committerJoey Hess <joey@kodama.kitenet.net>2008-03-03 15:53:34 -0500
commitd93aaed7919f0449d387aed6c6ee3aaff85a12eb (patch)
treef31e998cae4b6ec478d366f7997b0a892d89a328 /IkiWiki/Plugin
parent59379d0205fdbdb90553d1f5cef666e7e72a8927 (diff)
* Add recentchangesdiff plugin that adds diffs to the recentchanges feeds.
* rcs_diff is a new function that rcs modules should implement. * Implemented rcs_diff for git, svn, and tla (tla version untested). Mercurial and monotone still todo.
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r--IkiWiki/Plugin/recentchanges.pm5
-rw-r--r--IkiWiki/Plugin/recentchangesdiff.pm27
2 files changed, 30 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm
index 22f934f2e..e591df79f 100644
--- a/IkiWiki/Plugin/recentchanges.pm
+++ b/IkiWiki/Plugin/recentchanges.pm
@@ -133,7 +133,7 @@ sub store ($$$) { #{{{
);
}
- # escape wikilinks and preprocessor stuff in commit messages
+ # escape wikilinks and preprocessor stuff in commit messages
if (ref $change->{message}) {
foreach my $field (@{$change->{message}}) {
if (exists $field->{line}) {
@@ -150,7 +150,8 @@ sub store ($$$) { #{{{
wikiname => $config{wikiname},
);
IkiWiki::run_hooks(pagetemplate => sub {
- shift->(page => $page, destpage => $page, template => $template);
+ shift->(page => $page, destpage => $page,
+ template => $template, rev => $change->{rev});
});
my $file=$page."._change";
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