From 159c0c043cdd4009562087144a37fdda38eb6409 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 Aug 2009 21:04:19 -0400 Subject: optimise gettext calls --- IkiWiki/Plugin/brokenlinks.pm | 2 +- IkiWiki/Plugin/inline.pm | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index cf8f25281..f8d44892b 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -28,9 +28,9 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); my %broken; + my $discussion=gettext("Discussion"); foreach my $page (pagespec_match_list([keys %links], $params{pages}, location => $params{page})) { - my $discussion=gettext("Discussion"); my %seen; foreach my $link (@{$links{$page}}) { next if $seen{$link}; diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 04ad6ed23..2fbb45e02 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -348,6 +348,9 @@ sub preprocess_inline (@) { } my $template=HTML::Template->new(@params) unless $raw; + my $discussionlink=lc(gettext("Discussion")) + if $config{discussion}; + foreach my $page (@list) { my $file = $pagesources{$page}; my $type = pagetype($file); @@ -371,7 +374,6 @@ sub preprocess_inline (@) { my $file = $pagesources{$page}; my $type = pagetype($file); if ($config{discussion}) { - my $discussionlink=lc(gettext("Discussion")); if ($page !~ /.*\/\Q$discussionlink\E$/ && (length $config{cgiurl} || exists $links{$page."/".$discussionlink})) { -- cgit v1.2.3 From 830c9e59b2c4d5c90e4316d8e81558e1aeb132f2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 Aug 2009 21:41:33 -0400 Subject: Add discussionpage configuration setting By adding this setting, we get both more configurability, and a minor optimisation too, since gettext does not need to be called continually to get the Discussion value. --- IkiWiki.pm | 7 +++++++ IkiWiki/Plugin/brokenlinks.pm | 3 +-- IkiWiki/Plugin/editpage.pm | 5 +++-- IkiWiki/Plugin/inline.pm | 9 +++------ IkiWiki/Plugin/opendiscussion.pm | 3 +-- IkiWiki/Plugin/orphans.pm | 3 +-- IkiWiki/Render.pm | 9 ++++----- debian/changelog | 2 ++ 8 files changed, 22 insertions(+), 19 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index a11b330f2..b47da966e 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -220,6 +220,13 @@ sub getsetup () { safe => 1, rebuild => 1, }, + discussionpage => { + type => "string", + default => gettext("Discussion"), + description => "name of Discussion pages", + safe => 1, + rebuild => 1, + }, sslcookie => { type => "boolean", default => 0, diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index f8d44892b..5ad4c917c 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -28,14 +28,13 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); my %broken; - my $discussion=gettext("Discussion"); foreach my $page (pagespec_match_list([keys %links], $params{pages}, location => $params{page})) { my %seen; foreach my $link (@{$links{$page}}) { next if $seen{$link}; $seen{$link}=1; - next if $link =~ /.*\/\Q$discussion\E/i && $config{discussion}; + next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion}; my $bestlink=bestlink($page, $link); next if length $bestlink; push @{$broken{$link}}, $page; diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 467cd9ed5..fca970c60 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -229,8 +229,9 @@ sub cgi_editpage ($$) { my $dir=$from."/"; $dir=~s![^/]+/+$!!; - if ((defined $form->field('subpage') && length $form->field('subpage')) || - $page eq lc(gettext('Discussion'))) { + if ((defined $form->field('subpage') && + length $form->field('subpage')) || + $page eq lc($config{discussionpage})) { $best_loc="$from/$page"; } else { diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 2fbb45e02..704fa711d 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -348,9 +348,6 @@ sub preprocess_inline (@) { } my $template=HTML::Template->new(@params) unless $raw; - my $discussionlink=lc(gettext("Discussion")) - if $config{discussion}; - foreach my $page (@list) { my $file = $pagesources{$page}; my $type = pagetype($file); @@ -374,14 +371,14 @@ sub preprocess_inline (@) { my $file = $pagesources{$page}; my $type = pagetype($file); if ($config{discussion}) { - if ($page !~ /.*\/\Q$discussionlink\E$/ && + if ($page !~ /.*\/\Q$config{discussionpage}\E$/ && (length $config{cgiurl} || - exists $links{$page."/".$discussionlink})) { + exists $links{$page."/".$config{discussionpage}})) { $template->param(have_actions => 1); $template->param(discussionlink => htmllink($page, $params{destpage}, - gettext("Discussion"), + $config{discussionpage}, noimageinline => 1, forcesubpage => 1)); } diff --git a/IkiWiki/Plugin/opendiscussion.pm b/IkiWiki/Plugin/opendiscussion.pm index 60b193eca..1bec4b013 100644 --- a/IkiWiki/Plugin/opendiscussion.pm +++ b/IkiWiki/Plugin/opendiscussion.pm @@ -23,8 +23,7 @@ sub canedit ($$) { my $cgi=shift; my $session=shift; - my $discussion=lc(gettext("Discussion")); - return "" if $page=~/(\/|^)\Q$discussion\E$/; + return "" if $page=~/(\/|^)\Q$config{discussionpage}\E$/; return undef; } diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index 7c938ef74..02f5d2524 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -34,7 +34,6 @@ sub preprocess (@) { } my @orphans; - my $discussion=lc(gettext("Discussion")); foreach my $page (pagespec_match_list( [ grep { ! $linkedto{$_} && $_ ne 'index' } keys %pagesources ], @@ -43,7 +42,7 @@ sub preprocess (@) { # indirectly linked to a page via that page's backlinks. next if grep { length $_ && - ($_ !~ /\/\Q$discussion\E$/i || ! $config{discussion}) && + ($_ !~ /\/\Q$config{discussionpage}\E$/i || ! $config{discussion}) && bestlink($page, $_) !~ /^(\Q$page\E|)$/ } @{$links{$page}}; push @orphans, $page; diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index fc8f287ce..d5e81f1b9 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -83,11 +83,10 @@ sub genpage ($$) { $actions++; } if ($config{discussion}) { - my $discussionlink=lc(gettext("Discussion")); - if ($page !~ /.*\/\Q$discussionlink\E$/ && + if ($page !~ /.*\/\Q$config{discussionpage}\E$/ && (length $config{cgiurl} || - exists $links{$page."/".$discussionlink})) { - $template->param(discussionlink => htmllink($page, $page, gettext("Discussion"), noimageinline => 1, forcesubpage => 1)); + exists $links{$page."/".$config{discussionpage}})) { + $template->param(discussionlink => htmllink($page, $page, $config{discussionpage}, noimageinline => 1, forcesubpage => 1)); $actions++; } } @@ -153,7 +152,7 @@ sub scan ($) { if ($config{discussion}) { # Discussion links are a special case since they're # not in the text of the page, but on its template. - $links{$page}=[ $page."/".lc(gettext("Discussion")) ]; + $links{$page}=[ $page."/".lc($config{discussionpage}) ]; } else { $links{$page}=[]; diff --git a/debian/changelog b/debian/changelog index ed7854e8a..5e5149927 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ ikiwiki (3.141593) UNRELEASED; urgency=low the old version, but continue. Closes: #541205 * inline: Avoid use of my $_ as it fails with older perls. Closes: #541215 + * Add discussionpage configuration setting. + * Small optimisations. -- Joey Hess Wed, 12 Aug 2009 12:25:30 -0400 -- cgit v1.2.3 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') 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 f486271009142ec7e04e1a62c1e94ad9e51b6d39 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 14 Aug 2009 00:51:52 -0400 Subject: orphans: Reuse backlinks info This plugin was building essentially the same data that is built to handle backlinks, so reuse that as an optimisation. --- IkiWiki/Plugin/orphans.pm | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index 02f5d2524..711226772 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -27,15 +27,9 @@ sub preprocess (@) { # register a dependency. add_depends($params{page}, $params{pages}); - my %linkedto; - foreach my $p (keys %links) { - map { $linkedto{bestlink($p, $_)}=1 if length $_ } - @{$links{$p}}; - } - my @orphans; foreach my $page (pagespec_match_list( - [ grep { ! $linkedto{$_} && $_ ne 'index' } + [ grep { ! IkiWiki::backlink_pages($_) && $_ ne 'index' } keys %pagesources ], $params{pages}, location => $params{page})) { # If the page has a link to some other page, it's -- cgit v1.2.3 From 82bb3af579db809b884c7be5f49012469902bf52 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 14 Aug 2009 01:11:53 -0400 Subject: optimise brokenlinks by gathering the data when calculating backlinks During backlink calulation, all links are examined and broken links can be detected for free, so store a list of broken links and have brokenlinks use it. Exposing the %brokenlinks structure is a bit ugly, but the speedup seems worth it: Around 1 second for wikis the size of the doc wiki that use brokenlinks. --- IkiWiki/Plugin/brokenlinks.pm | 30 +++++++++++++----------------- IkiWiki/Render.pm | 23 ++++++++++++++--------- debian/changelog | 3 ++- 3 files changed, 29 insertions(+), 27 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index 5ad4c917c..eb698b0be 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -27,31 +27,27 @@ sub preprocess (@) { # register a dependency. add_depends($params{page}, $params{pages}); - my %broken; - foreach my $page (pagespec_match_list([keys %links], - $params{pages}, location => $params{page})) { - my %seen; - foreach my $link (@{$links{$page}}) { - next if $seen{$link}; - $seen{$link}=1; - next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion}; - my $bestlink=bestlink($page, $link); - next if length $bestlink; - push @{$broken{$link}}, $page; + my @broken; + foreach my $link (keys %IkiWiki::brokenlinks) { + next if $link =~ /.*\/\Q$config{discussionpage}\E/i && $config{discussion}; + + my @pages; + foreach my $page (@{$IkiWiki::brokenlinks{$link}}) { + push @pages, $page + if pagespec_match($page, $params{pages}, location => $params{page}); } - } + next unless @pages; - my @broken; - foreach my $link (keys %broken) { - my $page=$broken{$link}->[0]; + my $page=$IkiWiki::brokenlinks{$link}->[0]; push @broken, sprintf(gettext("%s from %s"), htmllink($page, $params{destpage}, $link, noimageinline => 1), join(", ", map { htmllink($params{page}, $params{destpage}, $_, noimageinline => 1) - } @{$broken{$link}})); + } @pages) + ); } - return gettext("There are no broken links!") unless %broken; + return gettext("There are no broken links!") unless @broken; return "
    \n" .join("\n", map { diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index d5e81f1b9..578142d2e 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -8,26 +8,31 @@ use IkiWiki; use Encode; my %backlinks; -my $backlinks_calculated=0; +our %brokenlinks; +my $links_calculated=0; -sub calculate_backlinks () { - return if $backlinks_calculated; - %backlinks=(); +sub calculate_links () { + return if $links_calculated; + %backlinks=%brokenlinks=(); foreach my $page (keys %links) { foreach my $link (@{$links{$page}}) { my $bestlink=bestlink($page, $link); - if (length $bestlink && $bestlink ne $page) { - $backlinks{$bestlink}{$page}=1; + if (length $bestlink) { + $backlinks{$bestlink}{$page}=1 + if $bestlink ne $page; + } + else { + push @{$brokenlinks{$link}}, $page; } } } - $backlinks_calculated=1; + $links_calculated=1; } sub backlink_pages ($) { my $page=shift; - calculate_backlinks(); + calculate_links(); return keys %{$backlinks{$page}}; } @@ -416,7 +421,7 @@ sub refresh () { debug(sprintf(gettext("scanning %s"), $file)); scan($file); } - calculate_backlinks(); + calculate_links(); foreach my $file (@needsbuild) { debug(sprintf(gettext("building %s"), $file)); render($file); diff --git a/debian/changelog b/debian/changelog index 5e5149927..147d279bb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,7 +5,8 @@ ikiwiki (3.141593) UNRELEASED; urgency=low * inline: Avoid use of my $_ as it fails with older perls. Closes: #541215 * Add discussionpage configuration setting. - * Small optimisations. + * Several optimisations, including speedups to orphans and brokenlinks + calculation. -- Joey Hess Wed, 12 Aug 2009 12:25:30 -0400 -- cgit v1.2.3 From e0bb9675ce349c02fce1e835b5aaa6601d4254d2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Jun 2009 15:34:48 +0100 Subject: img: depend on absolute page name, not relative Previously, [[!img bar.jpg]] on foo, where foo/bar.jpg exists, would get a dependency equivalent to "glob(bar.jpg)" (which might not match anything), rather than the correct "glob(foo/bar.jpg)". (cherry picked from commit 85b2ec49ecd12dd23e5c432933457a72744ce7cb) --- IkiWiki/Plugin/img.pm | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 68b001671..5f97e3810 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -135,11 +135,15 @@ sub preprocess (@) { elsif ($params{link} =~ /^\w+:\/\//) { $imgtag=''.$imgtag.''; } - elsif (length bestlink($params{page}, $params{link})) { - add_depends($params{page}, $params{link}); - $imgtag=htmllink($params{page}, $params{destpage}, - $params{link}, linktext => $imgtag, - noimageinline => 1); + else { + my $b = bestlink($params{page}, $params{link}); + + if (length $b) { + add_depends($params{page}, $b); + $imgtag=htmllink($params{page}, $params{destpage}, + $params{link}, linktext => $imgtag, + noimageinline => 1); + } } if (exists $params{caption}) { -- cgit v1.2.3 From 97e9d99358a04ef0623e57e82e6a61d42b3f2a99 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Jun 2009 15:32:55 +0100 Subject: meta: depend on absolute page name, not relative Previously, [[!meta redir="foo"]] on bar, where bar/foo exists, would depend on "foo" (which matches nothing, probably) rather than "bar/foo". (cherry picked from commit f27ec09b72f886415e63fe394e18d9c3cb3913bf) --- IkiWiki/Plugin/meta.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index b2295923e..514b09369 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -191,11 +191,11 @@ sub preprocess (@) { if ($value !~ /^\w+:\/\//) { my ($redir_page, $redir_anchor) = split /\#/, $value; - add_depends($page, $redir_page); my $link=bestlink($page, $redir_page); if (! length $link) { error gettext("redir page not found") } + add_depends($page, $link); $value=urlto($link, $page); $value.='#'.$redir_anchor if defined $redir_anchor; -- cgit v1.2.3 From 6a2f3ef4bd0649608592331ae52ca6895abdd2c4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 15 Aug 2009 13:58:04 -0400 Subject: indentation --- IkiWiki/Plugin/calendar.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index fe4b16072..c25893f72 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -211,8 +211,8 @@ EOF # matching the pagespec are added or removed. add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so - # that if they are removed, the calendar will be sure to be updated. - add_depends($params{page}, join(" or ", @list)); + # that if they are removed, the calendar will be sure to be updated. + add_depends($params{page}, join(" or ", @list)); return $calendar; } -- 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') 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') 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') 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 8b99e6874353a1b981490de8d96ca1945fc0b752 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 16 Aug 2009 13:45:10 -0400 Subject: use pagespec_match_list for feedpages This is both faster, and propigates any error in processing the feedpages pagespec out to display on the page. Which may have been why I didn't use it before, but currently seems like a good thing to do, since it explains why your feeds are empty.. --- IkiWiki/Plugin/inline.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 704fa711d..3a2f4b7bc 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -254,7 +254,7 @@ sub preprocess_inline (@) { add_depends($params{page}, join(" or ", $#list >= $#feedlist ? @list : @feedlist)); if ($feeds && exists $params{feedpages}) { - @feedlist=grep { pagespec_match($_, $params{feedpages}, location => $params{page}) } @feedlist; + @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); } my ($feedbase, $feednum); -- 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') 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 b6fcb1cb0ef27e5a63184440675d465fad652acf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Jun 2009 15:55:55 +0100 Subject: calendar, inline, map: don't pre-join dependencies The new dependency handling works better (eliminates more duplicates) if dependencies are split up. On the same wiki mentioned in the previous commit, this saves about a second (i.e. 4%) on the same test. --- IkiWiki/Plugin/calendar.pm | 4 +++- IkiWiki/Plugin/inline.pm | 4 +++- IkiWiki/Plugin/map.pm | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c25893f72..5d16dff75 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -212,7 +212,9 @@ EOF add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. - add_depends($params{page}, join(" or ", @list)); + foreach my $p (@list) { + add_depends($params{page}, $p); + } return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 3a2f4b7bc..a501566b5 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -251,7 +251,9 @@ sub preprocess_inline (@) { # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. - add_depends($params{page}, join(" or ", $#list >= $#feedlist ? @list : @feedlist)); + foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { + add_depends($params{page}, $p); + } if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 826dbbd66..54146dc46 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -73,7 +73,9 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); # Explicitly add all currently shown pages, to detect when pages # are removed. - add_depends($params{page}, join(" or ", keys %mapitems)); + foreach my $item (keys %mapitems) { + add_depends($params{page}, $item); + } # Create the map. my $parent=""; -- cgit v1.2.3 From e4cd168ebedd95585290c97ff42234344bfed46c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 24 Aug 2009 23:16:15 +0100 Subject: Allow add_depends to take an arrayref --- IkiWiki.pm | 9 +++++++++ IkiWiki/Plugin/calendar.pm | 4 +--- IkiWiki/Plugin/inline.pm | 4 +--- IkiWiki/Plugin/map.pm | 4 +--- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index 21a74adce..35fee1aa7 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1730,6 +1730,15 @@ sub add_depends ($$) { my $page=shift; my $pagespec=shift; + if (ref $pagespec eq 'ARRAY') { + foreach my $ps (@$pagespec) { + if (pagespec_valid($ps)) { + $depends{$page}{$ps} = 1; + } + } + return; + } + return unless pagespec_valid($pagespec); $depends{$page}{$pagespec} = 1; diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 5d16dff75..ce0719404 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -212,9 +212,7 @@ EOF add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. - foreach my $p (@list) { - add_depends($params{page}, $p); - } + add_depends($params{page}, \@list); return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a501566b5..b566d960f 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -251,9 +251,7 @@ sub preprocess_inline (@) { # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. - foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { - add_depends($params{page}, $p); - } + add_depends($params{page}, $#list >= $#feedlist ? \@list : \@feedlist); if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 54146dc46..cc977024d 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -73,9 +73,7 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); # Explicitly add all currently shown pages, to detect when pages # are removed. - foreach my $item (keys %mapitems) { - add_depends($params{page}, $item); - } + add_depends($params{page}, [keys %mapitems]); # Create the map. my $parent=""; -- cgit v1.2.3 From 5bcdc39999025062d201ae16babc0eabc2f4d976 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 25 Aug 2009 17:11:29 -0400 Subject: Revert "Allow add_depends to take an arrayref" This reverts commit e4cd168ebedd95585290c97ff42234344bfed46c. There was no benefit to this change. --- IkiWiki.pm | 9 --------- IkiWiki/Plugin/calendar.pm | 4 +++- IkiWiki/Plugin/inline.pm | 4 +++- IkiWiki/Plugin/map.pm | 4 +++- 4 files changed, 9 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index 8a8695768..871170992 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1738,15 +1738,6 @@ sub add_depends ($$) { my $page=shift; my $pagespec=shift; - if (ref $pagespec eq 'ARRAY') { - foreach my $ps (@$pagespec) { - if (pagespec_valid($ps)) { - $depends{$page}{$ps} = 1; - } - } - return; - } - return unless pagespec_valid($pagespec); $depends{$page}{$pagespec} = 1; diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index ce0719404..5d16dff75 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -212,7 +212,9 @@ EOF add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. - add_depends($params{page}, \@list); + foreach my $p (@list) { + add_depends($params{page}, $p); + } return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index b566d960f..a501566b5 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -251,7 +251,9 @@ sub preprocess_inline (@) { # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. - add_depends($params{page}, $#list >= $#feedlist ? \@list : \@feedlist); + foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { + add_depends($params{page}, $p); + } if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index cc977024d..54146dc46 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -73,7 +73,9 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); # Explicitly add all currently shown pages, to detect when pages # are removed. - add_depends($params{page}, [keys %mapitems]); + foreach my $item (keys %mapitems) { + add_depends($params{page}, $item); + } # Create the map. my $parent=""; -- 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') 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') 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 4e70f2f0d20bbfc800aafb1b78cc6a41f4617d32 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Aug 2009 13:24:51 -0400 Subject: htmltidy: Print a warning message if tidy fails. Closes: #543722 --- IkiWiki/Plugin/htmltidy.pm | 5 ++++- debian/changelog | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm index 6f3379ef4..fc0d3b1d6 100644 --- a/IkiWiki/Plugin/htmltidy.pm +++ b/IkiWiki/Plugin/htmltidy.pm @@ -46,7 +46,10 @@ sub sanitize (@) { waitpid $pid, 0; $SIG{PIPE}="DEFAULT"; - return "" if $sigpipe || ! defined $ret; + if ($sigpipe || ! defined $ret) { + print STDERR gettext("warning: tidy failed")."\n"; + return ""; + } return $ret; } diff --git a/debian/changelog b/debian/changelog index 0d3f61e6f..69e197e37 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,7 @@ ikiwiki (3.1415926) UNRELEASED; urgency=low slower. (smcv) * Rebuild wikis on upgrade to this version to fix bloat caused by the dependency bug. + * htmltidy: Print a warning message if tidy fails. Closes: #543722 -- Joey Hess Wed, 12 Aug 2009 12:25:30 -0400 -- cgit v1.2.3 From 5eec60d4c6c34b6f3d0d2bc002f5d4158354910a 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. (cherry picked from commit 496e8523c6706d096f1b794e3f3ba5dd2fa260f3) --- IkiWiki/Plugin/po.pm | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 414906999..a9517adce 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -602,17 +602,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') 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') 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') 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 0c1a71896d792e3fb2fe6624a2dc9fdac30e1b80 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 27 Aug 2009 16:27:57 -0400 Subject: htmltidy: Return an error message if tidy fails. Closes: #543722 On second^Wthird^Wfourth thought, putting the message into the page seems better than using stderr. --- IkiWiki/Plugin/htmltidy.pm | 3 +-- debian/changelog | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm index fc0d3b1d6..e6d377f8a 100644 --- a/IkiWiki/Plugin/htmltidy.pm +++ b/IkiWiki/Plugin/htmltidy.pm @@ -47,8 +47,7 @@ sub sanitize (@) { $SIG{PIPE}="DEFAULT"; if ($sigpipe || ! defined $ret) { - print STDERR gettext("warning: tidy failed")."\n"; - return ""; + return gettext("htmltidy failed to parse this html"); } return $ret; diff --git a/debian/changelog b/debian/changelog index b4169c576..8cd5032cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,7 +28,7 @@ ikiwiki (3.1415926) UNRELEASED; urgency=low slower. (smcv) * Rebuild wikis on upgrade to this version to fix bloat caused by the dependency bug. - * htmltidy: Print a warning message if tidy fails. Closes: #543722 + * htmltidy: Return an error message if tidy fails. Closes: #543722 * po: Fix name of translated toplevel index page. (intrigeri) * po: Fix display of links from a translated page to itself (ntrigeri) -- 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') 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') 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') 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') 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 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(-) (limited to 'IkiWiki/Plugin') 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(-) (limited to 'IkiWiki/Plugin') 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') 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') 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 d92f767fb772c9b11293134bd67bc1261aea8f1e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 27 Aug 2009 23:30:41 +0100 Subject: inline: if using pagenames, don't add a dependency on "page1 or page2 or..." This is unnecessary and just slows us down (by a factor of 2, in the pessimal case where every page has an inline with pagenames); it's also not possible to optimize it into add_depends_exact calls. --- IkiWiki/Plugin/inline.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a501566b5..d5ad11d43 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -195,10 +195,10 @@ sub preprocess_inline (@) { @list = map { bestlink($params{page}, $_) } split ' ', $params{pagenames}; - - $params{pages} = join(" or ", @list); } else { + add_depends($params{page}, $params{pages}); + @list = pagespec_match_list( [ grep { $_ ne $params{page} } keys %pagesources ], $params{pages}, location => $params{page}); @@ -247,7 +247,6 @@ sub preprocess_inline (@) { @list=@list[0..$params{show} - 1]; } - add_depends($params{page}, $params{pages}); # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. -- 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') 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') 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 From 03449610d6c666ba24bea68f01d896613e522278 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 28 Aug 2009 23:23:06 -0400 Subject: img: Don't generate new verison of image if it is scaled to be larger in either dimension. Although imagemagick handles even really large sizes sanely, using a page file, doing so would just waste time and disk space, since the browser can be told to resize it larger. --- IkiWiki/Plugin/img.pm | 39 ++++++++++++++++++++++++++++++++++++--- debian/changelog | 2 ++ 2 files changed, 38 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 5f97e3810..9ae85c4e6 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -65,6 +65,8 @@ sub preprocess (@) { my $imglink; my $r; + my ($dwidth, $dheight); + if ($params{size} ne 'full') { add_depends($params{page}, $image); @@ -86,7 +88,15 @@ sub preprocess (@) { $r = $im->Read($srcfile); error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r; - $r = $im->Resize(geometry => "${w}x${h}"); + # don't resize any larger + my ($rw, $rh) = ($w, $h); + if ((length $rw && $rw > $im->Get("width")) || + (length $rh && $rh > $im->Get("height"))) { + $rw=$im->Get("width"); + $rh=$im->Get("height"); + } + + $r = $im->Resize(geometry => "${rw}x${rh}"); error sprintf(gettext("failed to resize: %s"), $r) if $r; # don't actually write file in preview mode @@ -98,11 +108,34 @@ sub preprocess (@) { $imglink = $file; } } + + # since we don't really resize larger, set the display + # size, so the browser can scale the image up if necessary + if (length $w && length $h) { + ($dwidth, $dheight)=($w, $h); + } + # avoid division by zero on 0x0 image + elsif ($im->Get("width") == 0 || $im->Get("height") == 0) { + ($dwidth, $dheight)=(0, 0); + } + # calculate unspecified size from the other one, preserving + # aspect ratio + elsif (length $w) { + $dwidth=$w; + $dheight=$w / $im->Get("width") * $im->Get("height"); + } + elsif (length $h) { + $dheight=$h; + $dwidth=$h / $im->Get("height") * $im->Get("width"); + } + } else { $r = $im->Read($srcfile); error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r; $imglink = $file; + $dwidth = $im->Get("width"); + $dheight = $im->Get("height"); } my ($fileurl, $imgurl); @@ -120,8 +153,8 @@ sub preprocess (@) { } my $imgtag=''.$params{alt}.' Wed, 12 Aug 2009 12:25:30 -0400 -- cgit v1.2.3 From 9f75d3b1f3c43820cff9ce554601f64c60d72b14 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 28 Aug 2009 23:07:27 -0700 Subject: teximg: Make TeX handle preventing unsafe things; remove insufficient blacklist TeX has configuration options that prevent unsafe things like shell escapes and insecure file reads/writes. Turn all of them on. teximg's regex-based blacklist does not suffice. For instance: [[!teximg code=""" \catcode`\%=0 %input{/etc/passwd} """]] Remove the blacklist, since the TeX configuration options seal off the underlying mechanisms more safely, and the blacklist blocks other TeX commands that can prove useful. --- IkiWiki/Plugin/teximg.pm | 40 ++-------------------------------------- debian/changelog | 5 +++++ 2 files changed, 7 insertions(+), 38 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/teximg.pm b/IkiWiki/Plugin/teximg.pm index dba5372b5..f92ed0132 100644 --- a/IkiWiki/Plugin/teximg.pm +++ b/IkiWiki/Plugin/teximg.pm @@ -69,13 +69,7 @@ sub preprocess (@) { if (! defined $code && ! length $code) { error gettext("missing tex code"); } - - if (check($code)) { - return create($code, check_height($height), \%params); - } - else { - error gettext("code includes disallowed latex commands") - } + return create($code, check_height($height), \%params); } sub check_height ($) { @@ -155,7 +149,7 @@ sub gen_image ($$$$) { my $tmp = eval { create_tmp_dir($digest) }; if (! $@ && writefile("$digest.tex", $tmp, $tex) && - system("cd $tmp; latex --interaction=nonstopmode $tmp/$digest.tex > /dev/null") == 0 && + system("cd $tmp; shell_escape=f openout_any=p openin_any=p latex --interaction=nonstopmode $digest.tex < /dev/null > /dev/null") == 0 && # ensure destination directory exists writefile("$imagedir/$digest.png", $config{destdir}, "") && (($config{teximg_dvipng} && @@ -191,34 +185,4 @@ sub create_tmp_dir ($) { return $tmpdir; } -sub check ($) { - # Check if the code is ok - my $code = shift; - - my @badthings = ( - qr/\$\$/, - qr/\\include/, - qr/\\includegraphic/, - qr/\\usepackage/, - qr/\\newcommand/, - qr/\\renewcommand/, - qr/\\def/, - qr/\\input/, - qr/\\open/, - qr/\\loop/, - qr/\\errorstopmode/, - qr/\\scrollmode/, - qr/\\batchmode/, - qr/\\read/, - qr/\\write/, - ); - - foreach my $thing (@badthings) { - if ($code =~ m/$thing/ ) { - return 0; - } - } - return 1; -} - 1 diff --git a/debian/changelog b/debian/changelog index 992692566..a5b07aac1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ ikiwiki (3.1415926) UNRELEASED; urgency=low + [ Joey Hess ] * po: Detect if nowrapi18n can't be passed to po4a, and warn about the old version, but continue. Closes: #541205 * inline: Avoid use of my $_ as it fails with older perls. @@ -40,6 +41,10 @@ ikiwiki (3.1415926) UNRELEASED; urgency=low * img: Don't generate new verison of image if it is scaled to be larger in either dimension. + [ Josh Triplett ] + * teximg: Replace the insufficient blacklist with the built-in security + mechanisms of TeX. + -- Joey Hess Wed, 12 Aug 2009 12:25:30 -0400 ikiwiki (3.141592) unstable; urgency=low -- cgit v1.2.3