]> sipb.mit.edu Git - ikiwiki.git/commitdiff
po: fix link to homepage in special case
authorintrigeri <intrigeri@boum.org>
Thu, 6 Nov 2008 16:28:04 +0000 (17:28 +0100)
committerintrigeri <intrigeri@boum.org>
Thu, 6 Nov 2008 16:28:04 +0000 (17:28 +0100)
... by wrapping IkiWiki::urlto in order to workaround hard-coded
/index.$config{htmlext}, which is wrong when usedirs=0 and po_link_to=current
and translatable homepage

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

index c8ec37c228378d600ae526086b5fe97fb2ac503d..7902fa7455e42f917597b387ab65aee2f0a75f7e 100644 (file)
@@ -48,6 +48,8 @@ sub import { #{{{
        inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath);
        $origsubs{'targetpage'}=\&IkiWiki::targetpage;
        inject(name => "IkiWiki::targetpage", call => \&mytargetpage);
+       $origsubs{'urlto'}=\&IkiWiki::urlto;
+       inject(name => "IkiWiki::urlto", call => \&myurlto);
 } #}}}
 
 sub getsetup () { #{{{
@@ -256,6 +258,21 @@ sub urlto_with_orig_beautiful_urlpath($$) { #{{{
        return $res;
 } #}}}
 
+sub myurlto ($$;$) { #{{{
+       my $to=shift;
+       my $from=shift;
+       my $absolute=shift;
+
+       if (! length $to
+           && $config{po_link_to} eq "current"
+           && istranslation($from)
+           && istranslatable('index')) {
+               my ($masterpage, $curlang) = ($from =~ /(.*)[.]([a-z]{2})$/);
+               return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . $curlang . ".$config{htmlext}");
+       }
+       return $origsubs{'urlto'}->($to,$from,$absolute);
+} #}}}
+
 sub mybestlink ($$) { #{{{
        my $page=shift;
        my $link=shift;
index 923ccd63afbbb967977458de0c2d27ba2884b956..4262640bcf591d58f001e1f5ed7360650c2dcb7d 100644 (file)
@@ -254,11 +254,6 @@ in the backlinks.
 
 `po_link_to = current`: seems to work nicely
 
-### parentlinks
-
-When `usedirs` is disabled and the home page is translatable, the
-parent link to the wiki home page is broken (`/index.html`).
-
 Translation quality assurance
 -----------------------------