fix targetpage replacement to support 3 argument form
authorJoey Hess <joey@kitenet.net>
Thu, 24 Mar 2011 23:44:32 +0000 (19:44 -0400)
committerJoey Hess <joey@kitenet.net>
Thu, 24 Mar 2011 23:44:32 +0000 (19:44 -0400)
Oddly, this hadn't caused any visible breakage. Possibly inline,
which is the only thing to use targetpage, resolves the function
to the "real" one before po gets loaded?

IkiWiki/Plugin/po.pm

index 0ea35b21c79a38fa26e563e10c4cdb98e5ff5107..9ccc79268b7564a159815da059e6de6adaba8439 100644 (file)
@@ -624,20 +624,24 @@ sub mybeautify_urlpath ($) {
        return $res;
 }
 
-sub mytargetpage ($$) {
+sub mytargetpage ($$;$) {
        my $page=shift;
        my $ext=shift;
+       my $filename=shift;
 
        if (istranslation($page) || istranslatable($page)) {
                my ($masterpage, $lang) = (masterpage($page), lang($page));
-               if (! $config{usedirs} || $masterpage eq 'index') {
+               if (defined $filename) {
+                       return $masterpage . "/" . $filename . "." . $lang . "." . $ext;
+               }
+               elsif (! $config{usedirs} || $masterpage eq 'index') {
                        return $masterpage . "." . $lang . "." . $ext;
                }
                else {
                        return $masterpage . "/index." . $lang . "." . $ext;
                }
        }
-       return $origsubs{'targetpage'}->($page, $ext);
+       return $origsubs{'targetpage'}->($page, $ext, $filename);
 }
 
 sub myurlto ($;$$) {