From 949eb252e9f918bd57e58b75479ed3b4c017f87d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 Aug 2009 21:41:48 -0400 Subject: po: use discussionpage config setting This was tricky. $links{$page/discussion} must be checked; with it in lowercase. --- IkiWiki/Plugin/po.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 52677076e..b8967058e 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -284,17 +284,16 @@ sub pagetemplate (@) { map add_depends($page, $_), (values %{otherlanguages($page)}); } if ($config{discussion} && istranslation($page)) { - my $discussionlink=gettext("discussion"); - if ($page !~ /.*\/\Q$discussionlink\E$/i && + if ($page !~ /.*\/\Q$config{discussionpage}\E$/i && (length $config{cgiurl} || - exists $links{$masterpage."/".$discussionlink})) { + exists $links{$masterpage."/".lc($config{discussionpage})})) { $template->param('discussionlink' => htmllink( $page, $destpage, - $masterpage . '/' . gettext("Discussion"), + $masterpage . '/' . $config{discussionpage}, noimageinline => 1, forcesubpage => 0, - linktext => gettext("Discussion"), + linktext => $config{discussionpage}, )); } } -- cgit v1.2.3 From e03155172756f5c54c180136a5982e543cacb534 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 15 Aug 2009 16:42:29 -0400 Subject: update for consistency --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index b8967058e..1bf0b72e3 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -99,7 +99,7 @@ sub getsetup () { type => "string", example => { 'fr' => 'Français', - 'es' => 'Castellano', + 'es' => 'Español', 'de' => 'Deutsch' }, description => "slave languages (PO files)", -- cgit v1.2.3 From 1be07eae46e4993ecfea3da750727e1ec2d4b07d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 15 Aug 2009 21:08:17 -0400 Subject: replace N/A with 0 I think the N/A was not intended to be visible, but it can show up as the percent translated to a language. This happens if the page is located in an underlay, and not translated to the language in any other underlay. --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 1bf0b72e3..ce32aab05 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -891,7 +891,7 @@ sub percenttranslated ($) { my $page=shift; $page=~s/^\///; - return gettext("N/A") unless istranslation($page); + return gettext("0") unless istranslation($page); my $file=srcfile($pagesources{$page}); my $masterfile = srcfile($pagesources{masterpage($page)}); my %options = ( -- cgit v1.2.3 From 4ff3e2a540d154d49dfc70fb89dcc8422f2047e3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 15 Aug 2009 22:18:05 -0400 Subject: po: Better fix for missing underlay translation problem. If a page is taken from the underlay, and one of the specified languages does not have po files in the underlay, it would create a broken link to the translated version of the page for that language. With this change, there's no broken link. --- IkiWiki/Plugin/po.pm | 4 ++-- doc/plugins/po.mdwn | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index ce32aab05..aa3d72b90 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -891,7 +891,7 @@ sub percenttranslated ($) { my $page=shift; $page=~s/^\///; - return gettext("0") unless istranslation($page); + return gettext("N/A") unless istranslation($page); my $file=srcfile($pagesources{$page}); my $masterfile = srcfile($pagesources{masterpage($page)}); my %options = ( @@ -934,7 +934,7 @@ sub otherlanguagesloop ($) { master => 1, }; } - else { + elsif (istranslation($otherpage)) { push @ret, { url => urlto_with_orig_beautiful_urlpath($otherpage, $page), code => $lang, diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 684593bf3..3766ad295 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -307,7 +307,8 @@ pages as edit links, as if those pages do not exist. That's really confusing, especially as clicking such a link brings up an edit form to create a new, english page. -This is with po_link_to=current or negotiated. With default, it doesn't happen.. +This is with po_link_to=current or negotiated. With default, it doesn't +happen.. --[[Joey]] Double commits of po files -------------------------- @@ -321,7 +322,7 @@ and then committed again. The second commit makes this change: +"Content-Transfer-Encoding: ENCODING\n" Same thing happens when a change to an existing page triggers a po file -update. +update. --[[Joey]] Documentation ------------- -- cgit v1.2.3 From 9b799ccc851afc70b5b068e088f095e14005bda8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Aug 2009 14:05:59 -0400 Subject: po: Fixed to run rcs_add ralative to srcdir. --- IkiWiki/Plugin/po.pm | 2 +- debian/changelog | 1 + doc/bugs/po_plugin_cannot_add_po_files_into_git.mdwn | 7 +++++++ 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index aa3d72b90..414906999 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -414,7 +414,7 @@ sub change (@) { } if (@pofiles) { refreshpofiles($masterfile, @pofiles); - map { IkiWiki::rcs_add($_) } @pofiles if $config{rcs}; + map { s/^\Q$config{srcdir}\E\/*//; IkiWiki::rcs_add($_) } @pofiles if $config{rcs}; $updated_po_files=1; } } diff --git a/debian/changelog b/debian/changelog index ddf69f284..4bb450a55 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ ikiwiki (3.141593) UNRELEASED; urgency=low pages from the basewiki. * Updated French program translation from Philippe Batailler. Closes: #542036 + * po: Fixed to run rcs_add ralative to srcdir. -- Joey Hess Wed, 12 Aug 2009 12:25:30 -0400 diff --git a/doc/bugs/po_plugin_cannot_add_po_files_into_git.mdwn b/doc/bugs/po_plugin_cannot_add_po_files_into_git.mdwn index f87457080..6fadff07e 100644 --- a/doc/bugs/po_plugin_cannot_add_po_files_into_git.mdwn +++ b/doc/bugs/po_plugin_cannot_add_po_files_into_git.mdwn @@ -5,3 +5,10 @@ I have set absolute path for srcdir = '/path/to/repo/doc/'. The root of my git r I have no problem when I use an relative path like srcdir = '.'. I have an other issue with the po plugin when I set the srcdir to './doc/' (provided that my config file is in /path/to/repo). In this case the po plugin try to add 'doc/doc/index.fr.po' which does not exists (seems like the srcdir path is prepended twice). + +> You should never use a relative srcdir path with ikiwiki. +> +> I wonder what version of git you have there, since it works ok with the +> version I have here. But, the po plugin is definitly doing the wrong +> thing; it's telling git to add the po file with the full scrdir path +> rather than relative to its root. Fixed that. [[done]] --[[Joey]] -- cgit v1.2.3 From 0113c69d4fb5f55da932cb26e9eb58709d12e5a5 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 26 Aug 2009 07:02:29 +0200 Subject: po: (hopefully) fixed WikiLink to self with po_link_to=default --- IkiWiki/Plugin/po.pm | 3 +++ 1 file changed, 3 insertions(+) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 414906999..ea0e56467 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -547,6 +547,9 @@ sub mybestlink ($$) { my $page=shift; my $link=shift; + return $origsubs{'bestlink'}->($page, $link) + if $config{po_link_to} eq "default"; + my $res=$origsubs{'bestlink'}->(masterpage($page), $link); if (length $res && ($config{po_link_to} eq "current" || $config{po_link_to} eq "negotiated") -- cgit v1.2.3 From 496e8523c6706d096f1b794e3f3ba5dd2fa260f3 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Wed, 26 Aug 2009 07:56:33 +0200 Subject: po: do not beautify urls on the recentchanges page ... else, the recentchanges page shows a link such as "sandbox.es". But, clicking on it goes to the English (or negotiated language) version of the page. It is better in this one case if the link goes direct to the translated version of the page. --- IkiWiki/Plugin/po.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index ea0e56467..88d021388 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -605,17 +605,21 @@ sub myurlto ($$;$) { # 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 + # avoid, i.e. when po_link_to = negotiated. + # also avoid doing so when run by cgi_goto, so that the links on recentchanges + # page actually lead to the exact page they pretend to. if ($config{po_link_to} eq "negotiated") { my @caller = caller(1); - my $run_by_editpage = 0; - $run_by_editpage = 1 if (exists $caller[3] && defined $caller[3] - && $caller[3] eq "IkiWiki::cgi_editpage"); + my $use_orig = 0; + $use_orig = 1 if (exists $caller[3] && defined $caller[3] + && ($caller[3] eq "IkiWiki::cgi_editpage" || + $caller[3] eq "IkiWiki::Plugin::goto::cgi_goto") + ); inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'}) - if $run_by_editpage; + if $use_orig; my $res = $origsubs{'urlto'}->($to,$from,$absolute); inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath) - if $run_by_editpage; + if $use_orig; return $res; } else { -- cgit v1.2.3 From 3c2bffe21b91684971155ab41b15dacc515b2fc5 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 27 Aug 2009 19:59:15 +0200 Subject: po(scan): removed scary comment about only wanting to change the first link Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 88d021388..3039334c4 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -204,10 +204,7 @@ sub scan (@) { if (istranslation($page)) { foreach my $destpage (@{$links{$page}}) { if (istranslatable($destpage)) { - # replace one occurence of $destpage in $links{$page} - # (we only want to replace the one that was added by - # IkiWiki::Plugin::link::scan, other occurences may be - # there for other reasons) + # replace the occurence of $destpage in $links{$page} for (my $i=0; $i<@{$links{$page}}; $i++) { if (@{$links{$page}}[$i] eq $destpage) { @{$links{$page}}[$i] = $destpage . '.' . lang($page); -- cgit v1.2.3 From 6c0f9c691c3df3a2ec30dec626c997623568a400 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 27 Aug 2009 20:19:17 +0200 Subject: po: override the title template variable for coherent homepage titling Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 3039334c4..2b2839f24 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -302,6 +302,9 @@ sub pagetemplate (@) { && $masterpage eq "index") { $template->param('parentlinks' => []); } + if (ishomepage($page) && $template->query(name => "title")) { + $template->param(title => $config{wikiname}); + } } # }}} # Add the renamed page translations to the list of to-be-renamed pages. @@ -960,6 +963,14 @@ sub homepageurl (;$) { return urlto('', $page); } +sub ishomepage ($) { + my $page = shift; + + return 1 if $page eq 'index'; + map { return 1 if $page eq 'index.'.$_ } keys %{$config{po_slave_languages}}; + return undef; +} + sub deletetranslations ($) { my $deletedmasterfile=shift; -- cgit v1.2.3 From cdc3576c8d1efb2593cac2d9da3f2393a2afe26e Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 27 Aug 2009 20:31:44 +0200 Subject: po: do not inject custom bestlink function when po_link_to eq default Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 2b2839f24..12f41f6de 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -51,8 +51,6 @@ sub import { hook(type => "formbuilder_setup", id => "po", call => \&formbuilder_setup, last => 1); hook(type => "formbuilder", id => "po", call => \&formbuilder); - $origsubs{'bestlink'}=\&IkiWiki::bestlink; - inject(name => "IkiWiki::bestlink", call => \&mybestlink); $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); $origsubs{'targetpage'}=\&IkiWiki::targetpage; @@ -153,6 +151,10 @@ sub checkconfig () { warn(gettext('po_link_to=negotiated requires usedirs to be enabled, falling back to po_link_to=default')); $config{po_link_to}='default'; } + unless ($config{po_link_to} eq 'default') { + $origsubs{'bestlink'}=\&IkiWiki::bestlink; + inject(name => "IkiWiki::bestlink", call => \&mybestlink); + } push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/; @@ -543,16 +545,13 @@ sub formbuilder (@) { # `---- # Implement po_link_to 'current' and 'negotiated' settings. +# Not injected otherwise. sub mybestlink ($$) { my $page=shift; my $link=shift; - return $origsubs{'bestlink'}->($page, $link) - if $config{po_link_to} eq "default"; - my $res=$origsubs{'bestlink'}->(masterpage($page), $link); if (length $res - && ($config{po_link_to} eq "current" || $config{po_link_to} eq "negotiated") && istranslatable($res) && istranslation($page)) { return $res . "." . lang($page); -- cgit v1.2.3 From 1914ae2fd24e1e8021404eae847d70c710f8542d Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 12:38:07 +0200 Subject: po: fix interdiction to create pages of type po ... which was broken by the new page_types code. Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 12f41f6de..b9f59f3e8 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -533,7 +533,7 @@ sub formbuilder (@) { next unless "$field" eq "type"; if ($field->type eq 'select') { # remove po from the list of types - my @types = grep { $_ ne 'po' } $field->options; + my @types = grep { $_->[0] ne 'po' } $field->options; $field->options(\@types) if @types; } } -- cgit v1.2.3 From c9301d2c296f6822ecb38cc264e74c7186c13124 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 13:12:58 +0200 Subject: po: favor the type of linking page's masterpage on page creation Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index b9f59f3e8..55c1c32c6 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -531,10 +531,23 @@ sub formbuilder (@) { if ($form->field("do") eq "create") { foreach my $field ($form->field) { next unless "$field" eq "type"; - if ($field->type eq 'select') { - # remove po from the list of types - my @types = grep { $_->[0] ne 'po' } $field->options; - $field->options(\@types) if @types; + next unless $field->type eq 'select'; + my $orig_value = $field->value; + # remove po from the list of types + my @types = grep { $_->[0] ne 'po' } $field->options; + $field->options(\@types) if @types; + # favor the type of linking page's masterpage + if ($orig_value eq 'po') { + my ($from, $type); + if (defined $form->field('from')) { + ($from)=$form->field('from')=~/$config{wiki_file_regexp}/; + $from = masterpage($from); + } + if (defined $from && exists $pagesources{$from}) { + $type=pagetype($pagesources{$from}); + } + $type=$config{default_pageext} unless defined $type; + $field->value($type) ; } } } -- cgit v1.2.3 From 18ddf727d1fb30e3a3022fa8a73077c4c75dd262 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 12:38:07 +0200 Subject: po: fix interdiction to create pages of type po ... which was broken by the new page_types code. Signed-off-by: intrigeri (cherry picked from commit 1914ae2fd24e1e8021404eae847d70c710f8542d) --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 12f41f6de..b9f59f3e8 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -533,7 +533,7 @@ sub formbuilder (@) { next unless "$field" eq "type"; if ($field->type eq 'select') { # remove po from the list of types - my @types = grep { $_ ne 'po' } $field->options; + my @types = grep { $_->[0] ne 'po' } $field->options; $field->options(\@types) if @types; } } -- cgit v1.2.3 From 5136c22eed0527bce976c76205c6ccb2ddb0b062 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Fri, 28 Aug 2009 13:12:58 +0200 Subject: po: favor the type of linking page's masterpage on page creation Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index b9f59f3e8..55c1c32c6 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -531,10 +531,23 @@ sub formbuilder (@) { if ($form->field("do") eq "create") { foreach my $field ($form->field) { next unless "$field" eq "type"; - if ($field->type eq 'select') { - # remove po from the list of types - my @types = grep { $_->[0] ne 'po' } $field->options; - $field->options(\@types) if @types; + next unless $field->type eq 'select'; + my $orig_value = $field->value; + # remove po from the list of types + my @types = grep { $_->[0] ne 'po' } $field->options; + $field->options(\@types) if @types; + # favor the type of linking page's masterpage + if ($orig_value eq 'po') { + my ($from, $type); + if (defined $form->field('from')) { + ($from)=$form->field('from')=~/$config{wiki_file_regexp}/; + $from = masterpage($from); + } + if (defined $from && exists $pagesources{$from}) { + $type=pagetype($pagesources{$from}); + } + $type=$config{default_pageext} unless defined $type; + $field->value($type) ; } } } -- 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(-) (limited to 'IkiWiki/Plugin/po.pm') 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(-) (limited to 'IkiWiki/Plugin/po.pm') 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(+) (limited to 'IkiWiki/Plugin/po.pm') 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(-) (limited to 'IkiWiki/Plugin/po.pm') 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 From ec26a9619358498afb817c759625607d3b40f15d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 28 Aug 2009 19:15:25 -0400 Subject: avoid clobbering origsub if checkconfig runs more than once checkconfig can run more than once in a single ikiwiki run if setup is building wrappers. That clobbered the origsub value for bestlink, leading to infinite recursion --- IkiWiki/Plugin/po.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/po.pm') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 55c1c32c6..cde2ad4e3 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -152,8 +152,10 @@ sub checkconfig () { $config{po_link_to}='default'; } unless ($config{po_link_to} eq 'default') { - $origsubs{'bestlink'}=\&IkiWiki::bestlink; - inject(name => "IkiWiki::bestlink", call => \&mybestlink); + if (! exists $origsubs{'bestlink'}) { + $origsubs{'bestlink'}=\&IkiWiki::bestlink; + inject(name => "IkiWiki::bestlink", call => \&mybestlink); + } } push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/; -- cgit v1.2.3