X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/9169c3247ffae04ae2fbc9ceda4176ffb5f263d3..f77f7a02a6f235e02c4729f6f56e7c43bd8a33fb:/IkiWiki/Plugin/recentchanges.pm diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 6ab4f9d03..4d7023c1c 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -4,6 +4,8 @@ package IkiWiki::Plugin::recentchanges; use warnings; use strict; use IkiWiki 2.00; +use Encode; +use HTML::Entities; sub import { #{{{ hook(type => "getsetup", id => "recentchanges", call => \&getsetup); @@ -16,16 +18,20 @@ sub import { #{{{ sub getsetup () { #{{{ return + plugin => { + safe => 1, + rebuild => 1, + }, recentchangespage => { type => "string", - default => "recentchanges", + example => "recentchanges", description => "name of the recentchanges page", safe => 1, rebuild => 1, }, recentchangesnum => { type => "integer", - default => 100, + example => 100, description => "number of changes to track", safe => 1, rebuild => 0, @@ -82,7 +88,7 @@ sub cgi ($) { #{{{ # page they link to is deleted, or newly created, or # changes for whatever reason. So this CGI handles that # dynamic linking stuff. - my $page=$cgi->param("page"); + my $page=decode_utf8($cgi->param("page")); if (!defined $page) { error("missing page parameter"); } @@ -99,7 +105,7 @@ sub cgi ($) { #{{{ "

"); } else { - IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link))); + IkiWiki::redirect($cgi, urlto($link, undef, 1)); } exit; @@ -109,7 +115,7 @@ sub cgi ($) { #{{{ sub store ($$$) { #{{{ my $change=shift; - my $page="$config{recentchangespage}/change_".IkiWiki::titlepage($change->{rev}); + my $page="$config{recentchangespage}/change_".titlepage($change->{rev}); # Optimisation to avoid re-writing pages. Assumes commits never # change (or that any changes are not important). @@ -126,12 +132,12 @@ sub store ($$$) { #{{{ do => "recentchanges_link", page => $_->{page} ). - "\">". - IkiWiki::pagetitle($_->{page}). + "\" rel=\"nofollow\">". + pagetitle($_->{page}). "" } else { - $_->{link} = IkiWiki::pagetitle($_->{page}); + $_->{link} = pagetitle($_->{page}); } $_->{baseurl}="$config{url}/" if length $config{url}; @@ -154,11 +160,13 @@ sub store ($$$) { #{{{ ); } - # escape wikilinks and preprocessor stuff in commit messages if (ref $change->{message}) { foreach my $field (@{$change->{message}}) { if (exists $field->{line}) { - $field->{line} =~ s/(?{line} = encode_entities($field->{line}); + # escape links and preprocessor stuff + $field->{line} = encode_entities($field->{line}, '\[\]'); } } } @@ -170,6 +178,10 @@ sub store ($$$) { #{{{ commitdate => displaytime($change->{when}, "%X %x"), wikiname => $config{wikiname}, ); + + $template->param(permalink => "$config{url}/$config{recentchangespage}/#change-".titlepage($change->{rev})) + if exists $config{url}; + IkiWiki::run_hooks(pagetemplate => sub { shift->(page => $page, destpage => $page, template => $template, rev => $change->{rev});