From 149a3e65a75d3d6e1b2106be00c7ec675c26406a Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 31 Dec 2008 13:02:48 +0100 Subject: po: fix redirect after edit, using a somehow tricky hack Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 515809f70..44fd44a2d 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -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) + } } #}}} -- cgit v1.2.3