]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/recentchanges.pm
tweak recentchanges permalink code
[ikiwiki.git] / IkiWiki / Plugin / recentchanges.pm
index 37e45a05af65109bedb626eb56d6de8ae20ac3d1..e124a454089b2470907c19556461b84a8956966e 100644 (file)
@@ -4,6 +4,7 @@ package IkiWiki::Plugin::recentchanges;
 use warnings;
 use strict;
 use IkiWiki 2.00;
+use Encode;
 
 sub import { #{{{
        hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
@@ -86,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");
                }
@@ -103,12 +104,7 @@ sub cgi ($) { #{{{
                                "</p>");
                }
                else {
-                       if (defined pagetype($link)) {
-                               IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link)));
-                       }
-                       else {
-                               IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".$link));
-                       }
+                       IkiWiki::redirect($cgi, urlto($link, undef, 1));
                }
 
                exit;
@@ -118,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).
@@ -136,11 +132,11 @@ sub store ($$$) { #{{{
                                                page => $_->{page}
                                        ).
                                        "\">".
-                                       IkiWiki::pagetitle($_->{page}).
+                                       pagetitle($_->{page}).
                                        "</a>"
                        }
                        else {
-                               $_->{link} = IkiWiki::pagetitle($_->{page});
+                               $_->{link} = pagetitle($_->{page});
                        }
                        $_->{baseurl}="$config{url}/" if length $config{url};
 
@@ -177,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});