From 72ac9821e566373de49a77ffee642b14ecf643e1 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 13:56:03 +0200 Subject: inline: moved rootpage logic to a function The po plugin's injected bestlink must do something special when called by this exact part of inline's code. Signed-off-by: intrigeri --- IkiWiki/Plugin/inline.pm | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a501566b5..c9cbb9cb7 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -307,17 +307,7 @@ sub preprocess_inline (@) { # Add a blog post form, with feed buttons. my $formtemplate=template("blogpost.tmpl", blind_cache => 1); $formtemplate->param(cgiurl => $config{cgiurl}); - my $rootpage; - if (exists $params{rootpage}) { - $rootpage=bestlink($params{page}, $params{rootpage}); - if (!length $rootpage) { - $rootpage=$params{rootpage}; - } - } - else { - $rootpage=$params{page}; - } - $formtemplate->param(rootpage => $rootpage); + $formtemplate->param(rootpage => rootpage(%params)); $formtemplate->param(rssurl => $rssurl) if $feeds && $rss; $formtemplate->param(atomurl => $atomurl) if $feeds && $atom; if (exists $params{postformtext}) { @@ -654,4 +644,21 @@ sub pingurl (@) { exit 0; # daemon done } + +sub rootpage (@) { + my %params=@_; + + my $rootpage; + if (exists $params{rootpage}) { + $rootpage=bestlink($params{page}, $params{rootpage}); + if (!length $rootpage) { + $rootpage=$params{rootpage}; + } + } + else { + $rootpage=$params{page}; + } + return $rootpage; +} + 1 -- cgit v1.2.3 From cf43ae5a1f5460a98cdd7acb36c0691b2eec988f Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 13:57:15 +0200 Subject: po: keep masterpage as the rootpage for inline's post form Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 55c1c32c6..103347c37 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -564,9 +564,13 @@ sub mybestlink ($$) { my $link=shift; my $res=$origsubs{'bestlink'}->(masterpage($page), $link); + my @caller = caller(1); if (length $res && istranslatable($res) - && istranslation($page)) { + && istranslation($page) + # keep masterpage as the rootpage for inline's post form + && !(exists $caller[3] && defined $caller[3] + && ($caller[3] eq "IkiWiki::rootpage"))) { return $res . "." . lang($page); } return $res; -- cgit v1.2.3 From 53dc18ec2b46ded088a3dca0abafb2f3c184969e Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 14:47:11 +0200 Subject: Revert "po: keep masterpage as the rootpage for inline's post form" This reverts commit cf43ae5a1f5460a98cdd7acb36c0691b2eec988f, which actually only works when a rootpage parameter is set. A more complete fix will be written soon. --- IkiWiki/Plugin/po.pm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 103347c37..55c1c32c6 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -564,13 +564,9 @@ sub mybestlink ($$) { my $link=shift; my $res=$origsubs{'bestlink'}->(masterpage($page), $link); - my @caller = caller(1); if (length $res && istranslatable($res) - && istranslation($page) - # keep masterpage as the rootpage for inline's post form - && !(exists $caller[3] && defined $caller[3] - && ($caller[3] eq "IkiWiki::rootpage"))) { + && istranslation($page)) { return $res . "." . lang($page); } return $res; -- cgit v1.2.3 From e671e72053e81fa06cb9c9407ff17a0beff2f1fe Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 15:00:16 +0200 Subject: po: better rootpage logic for inline's post form Set rootpage to the non-l10n'd rootpage parameter if it is set, else to the masterpage of the linking page. Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 55c1c32c6..14c7318fe 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -59,6 +59,8 @@ sub import { inject(name => "IkiWiki::urlto", call => \&myurlto); $origsubs{'cgiurl'}=\&IkiWiki::cgiurl; inject(name => "IkiWiki::cgiurl", call => \&mycgiurl); + $origsubs{'rootpage'}=\&IkiWiki::rootpage; + inject(name => "IkiWiki::rootpage", call => \&myrootpage); } @@ -649,6 +651,22 @@ sub mycgiurl (@) { return $origsubs{'cgiurl'}->(%params); } +sub myrootpage (@) { + my %params=@_; + + my $rootpage; + if (exists $params{rootpage}) { + $rootpage=$origsubs{'bestlink'}->($params{page}, $params{rootpage}); + if (!length $rootpage) { + $rootpage=$params{rootpage}; + } + } + else { + $rootpage=masterpage($params{page}); + } + return $rootpage; +} + # ,---- # | Blackboxes for private data # `---- -- cgit v1.2.3 From 646c9a4c95a480544d63c161651c45b3b029e598 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 16:34:58 +0200 Subject: po: fix link() pagespec when used on translation pages Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 14c7318fe..21e3b8e37 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -566,9 +566,12 @@ sub mybestlink ($$) { my $link=shift; my $res=$origsubs{'bestlink'}->(masterpage($page), $link); + my @caller = caller(1); if (length $res && istranslatable($res) - && istranslation($page)) { + && istranslation($page) + && !(exists $caller[3] && defined $caller[3] + && ($caller[3] eq "IkiWiki::PageSpec::match_link"))) { return $res . "." . lang($page); } return $res; -- cgit v1.2.3