X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/d5de560f50cee1b3f7facb4a7b53d90556ec091c..35c56622ea56c7d97299faba5e72b5a67fa25c66:/IkiWiki/Plugin/recentchanges.pm diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index bc069fbf2..e124a4540 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -4,8 +4,10 @@ package IkiWiki::Plugin::recentchanges; use warnings; use strict; use IkiWiki 2.00; +use Encode; sub import { #{{{ + hook(type => "getsetup", id => "recentchanges", call => \&getsetup); hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig); hook(type => "refresh", id => "recentchanges", call => \&refresh); hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate); @@ -13,6 +15,28 @@ sub import { #{{{ hook(type => "cgi", id => "recentchanges", call => \&cgi); } #}}} +sub getsetup () { #{{{ + return + plugin => { + safe => 1, + rebuild => 1, + }, + recentchangespage => { + type => "string", + example => "recentchanges", + description => "name of the recentchanges page", + safe => 1, + rebuild => 1, + }, + recentchangesnum => { + type => "integer", + example => 100, + description => "number of changes to track", + safe => 1, + rebuild => 0, + }, +} #}}} + sub checkconfig () { #{{{ $config{recentchangespage}='recentchanges' unless defined $config{recentchangespage}; $config{recentchangesnum}=100 unless defined $config{recentchangesnum}; @@ -63,7 +87,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"); } @@ -80,7 +104,7 @@ sub cgi ($) { #{{{ "

"); } else { - IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_url("/".htmlpage($link))); + IkiWiki::redirect($cgi, urlto($link, undef, 1)); } exit; @@ -90,7 +114,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). @@ -108,11 +132,11 @@ sub store ($$$) { #{{{ page => $_->{page} ). "\">". - IkiWiki::pagetitle($_->{page}). + pagetitle($_->{page}). "" } else { - $_->{link} = IkiWiki::pagetitle($_->{page}); + $_->{link} = pagetitle($_->{page}); } $_->{baseurl}="$config{url}/" if length $config{url}; @@ -149,8 +173,13 @@ sub store ($$$) { #{{{ $template->param( %$change, commitdate => displaytime($change->{when}, "%X %x"), + commitdate_raw => scalar localtime($change->{when}), 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});