use warnings;
use strict;
use IkiWiki 2.00;
+use Encode;
+use HTML::Entities;
sub import { #{{{
hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
sub getsetup () { #{{{
return
+ plugin => {
+ safe => 1,
+ rebuild => 1,
+ },
recentchangespage => {
type => "string",
example => "recentchanges",
# 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");
}
"</p>");
}
else {
- IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link)));
+ IkiWiki::redirect($cgi, urlto($link, undef, 1));
}
exit;
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).
do => "recentchanges_link",
page => $_->{page}
).
- "\">".
- IkiWiki::pagetitle($_->{page}).
+ "\" rel=\"nofollow\">".
+ pagetitle($_->{page}).
"</a>"
}
else {
- $_->{link} = IkiWiki::pagetitle($_->{page});
+ $_->{link} = pagetitle($_->{page});
}
$_->{baseurl}="$config{url}/" if length $config{url};
);
}
- # escape wikilinks and preprocessor stuff in commit messages
if (ref $change->{message}) {
foreach my $field (@{$change->{message}}) {
if (exists $field->{line}) {
- $field->{line} =~ s/(?<!\\)\[\[/\\\[\[/g;
+ # escape html
+ $field->{line} = encode_entities($field->{line});
+ # escape links and preprocessor stuff
+ $field->{line} = encode_entities($field->{line}, '\[\]');
}
}
}
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});