summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/recentchangesdiff.pm
blob: bd2826f76518fc2c1a7060d21110331ce744ac2d (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::recentchangesdiff;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 2.00;
  6. sub import { #{{{
  7. hook(type => "pagetemplate", id => "recentchangesdiff",
  8. call => \&pagetemplate);
  9. } #}}}
  10. sub pagetemplate (@) { #{{{
  11. my %params=@_;
  12. my $template=$params{template};
  13. if ($config{rcs} && exists $params{rev} && length $params{rev} &&
  14. $template->query(name => "diff")) {
  15. my $diff=IkiWiki::rcs_diff($params{rev});
  16. if (defined $diff && length $diff) {
  17. # escape links and preprocessor stuff
  18. $diff =~ s/(?<!\\)\[\[/\\\[\[/g;
  19. $template->param(diff => $diff);
  20. }
  21. }
  22. } #}}}
  23. 1