From: Joey Hess Date: Sun, 18 Jul 2010 23:35:16 +0000 (-0400) Subject: Merge remote branch 'intrigeri/po' X-Git-Tag: 3.20100722~8^2~8 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/b45688e34e25a596dc19f6a2b94f3f342041da1e?hp=-c Merge remote branch 'intrigeri/po' --- b45688e34e25a596dc19f6a2b94f3f342041da1e diff --combined IkiWiki.pm index 2cf0ad819,1dc989b39..0c0b7bd4c --- a/IkiWiki.pm +++ b/IkiWiki.pm @@@ -823,17 -823,6 +823,17 @@@ sub prep_writefile ($$) if (-l "$destdir/$test") { error("cannot write to a symlink ($test)"); } + if (-f _ && $test ne $file) { + # Remove conflicting file. + foreach my $p (keys %renderedfiles, keys %oldrenderedfiles) { + foreach my $f (@{$renderedfiles{$p}}, @{$oldrenderedfiles{$p}}) { + if ($f eq $test) { + unlink("$destdir/$test"); + last; + } + } + } + } $test=dirname($test); } @@@ -887,36 -876,10 +887,36 @@@ sub will_render ($$;$) my $dest=shift; my $clear=shift; - # Important security check. + # Important security check for independently created files. if (-e "$config{destdir}/$dest" && ! $config{rebuild} && ! grep { $_ eq $dest } (@{$renderedfiles{$page}}, @{$oldrenderedfiles{$page}}, @{$wikistate{editpage}{previews}})) { - error("$config{destdir}/$dest independently created, not overwriting with version from $page"); + my $from_other_page=0; + # Expensive, but rarely runs. + foreach my $p (keys %renderedfiles, keys %oldrenderedfiles) { + if (grep { + $_ eq $dest || + dirname($_) eq $dest + } @{$renderedfiles{$p}}, @{$oldrenderedfiles{$p}}) { + $from_other_page=1; + last; + } + } + + error("$config{destdir}/$dest independently created, not overwriting with version from $page") + unless $from_other_page; + } + + # If $dest exists as a directory, remove conflicting files in it + # rendered from other pages. + if (-d _) { + foreach my $p (keys %renderedfiles, keys %oldrenderedfiles) { + foreach my $f (@{$renderedfiles{$p}}, @{$oldrenderedfiles{$p}}) { + if (dirname($f) eq $dest) { + unlink("$config{destdir}/$f"); + rmdir(dirname("$config{destdir}/$f")); + } + } + } } if (! $clear || $cleared{$page}) { @@@ -1118,6 -1081,15 +1118,15 @@@ sub urlto ($$;$) return beautify_urlpath($link); } + sub isselflink ($$) { + # Plugins can override this function to support special types + # of selflinks. + my $page=shift; + my $link=shift; + + return $page eq $link; + } + sub htmllink ($$$;@) { my $lpage=shift; # the page doing the linking my $page=shift; # the page that will contain the link (different for inline) @@@ -1143,7 -1115,7 +1152,7 @@@ } return "$linktext" - if length $bestlink && $page eq $bestlink && + if length $bestlink && isselflink($page, $bestlink) && ! defined $opts{anchor}; if (! $destsources{$bestlink}) { diff --combined doc/plugins/po.mdwn index 4158d7547,57f04a476..babdc1886 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@@ -54,10 -54,10 +54,10 @@@ Supported language `po_slave_languages` is used to set the list of supported "slave" languages, such as: - po_slave_languages => { 'fr' => 'Français', + po_slave_languages => [ 'fr' => 'Français', 'es' => 'Español', 'de' => 'Deutsch', - } + ] Decide which pages are translatable ----------------------------------- @@@ -274,29 -274,6 +274,29 @@@ to an array to support this. (If twere >> up if it is not.. and the value is marked safe so websetup can be >> used to modify it and break that way too. --[[Joey]] +>>> I have added a sanity check for the even array problem. This was +>>> the easy part. +>>> +>>> About the hash-like vs. dump and websetup issue, +>>> I can think of a few solutions: +>>> +>>> - keep the current hash-like pairs and unmark this setting as safe +>>> for websetup: this does not solve the dump setup issue, though; +>>> - replace the array of pairs with an array of +>>> "LANGUAGECODE|LANGUAGENAME" elements, using a pipe or whatever +>>> separator seems adequate; +>>> - add support for ordered hashes to `$config`, websetup and +>>> dumpsetup, using Tie-IxHash or any similar module; +>>> - replace the array of hash-like pairs with an array of real +>>> pairs, such as `[ ['de', 'Deutsch'], ['fr', 'Français'] ]`; this +>>> brings once again the need for `$config` to support arrays of +>>> arrays, which I have already implemented in my mirrorlist branch +>>> (see [[todo/mirrorlist_with_per-mirror_usedirs_settings]] for +>>> details). +>>> +>>> Joey, which of these solutions do you prefer? Or another one? +>>> I tend to prefer the last one. --[[intrigeri]] + Pagespecs --------- @@@ -351,16 -328,6 +351,16 @@@ update. --[[Joey] > * The ENCODING\n part is due to an inconsistency in po4a, which > I've just send a patch for. --[[intrigeri]] +New pages not translatable +-------------------------- + +Today I added a new English page to l10n.ikiwiki.info. When I saved, +the page did not have the translation links at the top. I waited until +the po plugin had, in the background, created the po files, and refreshed; +still did not see the translation links. Only when I touched the page +source and refreshed did it finally add the translation links. +I can reproduce this bug in a test site. --[[Joey]] + Ugly messages with empty files ------------------------------