]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
po: fix redirect after edit, using a somehow tricky hack
authorintrigeri <intrigeri@boum.org>
Wed, 31 Dec 2008 12:02:48 +0000 (13:02 +0100)
committerintrigeri <intrigeri@boum.org>
Wed, 31 Dec 2008 12:02:48 +0000 (13:02 +0100)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/po.pm
doc/plugins/po.mdwn

index 515809f70dfd99ad334cb32d32db7cc8d22c6fd5..44fd44a2d9c673a0e4cdfc9b77a8f2bda3bc4239 100644 (file)
@@ -465,7 +465,24 @@ sub myurlto ($$;$) { #{{{
            && istranslatable('index')) {
                return IkiWiki::beautify_urlpath(IkiWiki::baseurl($from) . "index." . lang($from) . ".$config{htmlext}");
        }
-       return $origsubs{'urlto'}->($to,$from,$absolute);
+       # avoid using our injected beautify_urlpath if run by cgi_editpage,
+       # so that one is redirected to the just-edited page rather than to the
+       # negociated translation; to prevent unnecessary fiddling with caller/inject,
+       # we only do so when our beautify_urlpath would actually do what we want to
+       # avoid, i.e. when po_link_to = negotiated
+       if ($config{po_link_to} eq "negotiated") {
+               my @caller = caller(1);
+               my $run_by_editpage = ($caller[3] eq "IkiWiki::cgi_editpage");
+               inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'})
+                       if $run_by_editpage;
+               my $res = $origsubs{'urlto'}->($to,$from,$absolute);
+               inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath)
+                       if $run_by_editpage;
+               return $res;
+       }
+       else {
+               return $origsubs{'urlto'}->($to,$from,$absolute)
+       }
 } #}}}
 
 
index 722a7c66c08dc851c5bfae42acb164a81a483e22..da8a1307436464c443dbb602c51951adfebbb1d1 100644 (file)
@@ -520,12 +520,6 @@ See [[contrib/po]].
 
 They are not updated when the source page changes (e.g. meta title).
 
-### Redirect after edit
-
-After editing master page, when using `po_link_to=negotiated`, one is
-redirected to the page in her preferred language. Would be slightly
-better to be redirected, in any case, to the just saved page.
-
 Page formats
 ------------