po: fix broken links from slave pages
authorintrigeri <intrigeri@boum.org>
Thu, 15 Jan 2009 20:49:32 +0000 (21:49 +0100)
committerintrigeri <intrigeri@boum.org>
Thu, 15 Jan 2009 20:49:32 +0000 (21:49 +0100)
... by overriding cgiurl.

Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm

index 1575754834d646fc73f5c960b2eb6b08a6c9122d..a050d2b71ce789b33fcfc7b494e5fe1255b60e74 100644 (file)
@@ -56,6 +56,8 @@ sub import {
        inject(name => "IkiWiki::urlto", call => \&myurlto);
        $origsubs{'nicepagetitle'}=\&IkiWiki::nicepagetitle;
        inject(name => "IkiWiki::nicepagetitle", call => \&mynicepagetitle);
+       $origsubs{'cgiurl'}=\&IkiWiki::cgiurl;
+       inject(name => "IkiWiki::cgiurl", call => \&mycgiurl);
 }
 
 
@@ -599,6 +601,16 @@ sub mynicepagetitle ($;$) {
        return $res.' ('.percenttranslated($page).'&nbsp;%)';
 }
 
+sub mycgiurl (@) {
+       my %params=@_;
+
+       # slave pages have no subpages
+       if (istranslation($params{'from'})) {
+               $params{'from'} = masterpage($params{'from'});
+       }
+       return $origsubs{'cgiurl'}->(%params);
+}
+
 # ,----
 # | Blackboxes for private data
 # `----