From 8e451ecda4573284467c95a0b66ade3014fd1bd8 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 20:13:14 +0100 Subject: po: now uses inject --- doc/plugins/contrib/po.mdwn | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'doc/plugins') diff --git a/doc/plugins/contrib/po.mdwn b/doc/plugins/contrib/po.mdwn index f60b8fbea..98cc07178 100644 --- a/doc/plugins/contrib/po.mdwn +++ b/doc/plugins/contrib/po.mdwn @@ -52,10 +52,13 @@ Any thoughts on this? >>> [[plugins/write]]. I think you can just inject wrappers about a few ikiwiki >>> functions, rather than adding hooks. The `inject` function is pretty >>> insane^Wlow level, but seems to work great. --[[Joey]] ->> +>>> >>>> Thanks a lot, it seems to be a nice interface for what I was trying to achieve. >>>> I may be forced to wait two long weeks before I have a chance to confirm >>>> this. Stay tuned. --[[intrigeri]] +>>>> +>>>>> I've updated the plugin to use `inject`. It is now fully self-contained, +>>>>> and does not modify the core anymore. --[[intrigeri]] >> >> The Discussion pages issue is something I am not sure about yet. But I will >> probably decide that "slave" pages, being only translations, don't deserve -- cgit v1.2.3 From b2aa69762d7f1950281d838ad0f13092f62f3962 Mon Sep 17 00:00:00 2001 From: neale Date: Mon, 3 Nov 2008 22:07:58 -0500 Subject: --- doc/plugins/img/discussion.mdwn | 2 ++ 1 file changed, 2 insertions(+) (limited to 'doc/plugins') diff --git a/doc/plugins/img/discussion.mdwn b/doc/plugins/img/discussion.mdwn index 02d46e380..7a70da65f 100644 --- a/doc/plugins/img/discussion.mdwn +++ b/doc/plugins/img/discussion.mdwn @@ -5,3 +5,5 @@ logo link to \[[hurd/logo]] / instead of linking to the PNG image file. --[[tschwinge]] > Done, use link=somepage --[[Joey]] + +It would be handy if the `class` and `id` tags were passed through to the surrounding `table` in the case of `caption` being present. Would this break anything? --[[Nea -- cgit v1.2.3 From 8903776a0938c0bec03b864b1aa63672ed096298 Mon Sep 17 00:00:00 2001 From: neale Date: Mon, 3 Nov 2008 22:08:49 -0500 Subject: trackpad registered a click on save --- doc/plugins/img/discussion.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'doc/plugins') diff --git a/doc/plugins/img/discussion.mdwn b/doc/plugins/img/discussion.mdwn index 7a70da65f..5bf340c56 100644 --- a/doc/plugins/img/discussion.mdwn +++ b/doc/plugins/img/discussion.mdwn @@ -6,4 +6,4 @@ instead of linking to the PNG image file. --[[tschwinge]] > Done, use link=somepage --[[Joey]] -It would be handy if the `class` and `id` tags were passed through to the surrounding `table` in the case of `caption` being present. Would this break anything? --[[Nea +It would be handy if the `class` and `id` tags were passed through to the surrounding `table` in the case of `caption` being present. Would this break anything? --[[neale]] -- cgit v1.2.3 From 61c4129aaaa5ce1849023aa9f12f32ff98eb52fb Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 4 Nov 2008 19:24:37 +0100 Subject: po plugin: updated doc/todo Signed-off-by: intrigeri --- doc/plugins/po.mdwn | 70 ++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 41 deletions(-) (limited to 'doc/plugins') diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index fe6b6b562..6aa63b429 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -185,12 +185,12 @@ Automatic PO files update Committing changes to a "master" page: -1. updates the POT file and the PO files for the supported languages - (this is done in the `needsbuild` hook); the updated PO files are - then put under version control +1. updates the POT file, as well as the PO files for the "slave" + languages (this is done in the `needsbuild` hook); the updated PO + files are then put under version control; 2. triggers a refresh of the corresponding HTML slave pages (this is achieved by making any "slave" page dependent on the corresponding - "master" page, in the `needsbuild` hook) + "master" page, in the `needsbuild` hook). Also, when the plugin has just been enabled, or when a page has just been declared as being translatable, the needed POT and PO files are @@ -199,33 +199,23 @@ created, and the PO files are checked into version control. Discussion pages ---------------- -Discussion should happen in the language in which the pages are written for -real, *i.e.* the "master" one. If discussion pages are enabled, "slave" pages -therefore link to the "master" page's discussion page. +Discussion should happen in the language in which the pages are +written for real, *i.e.* the "master" one. If discussion pages are +enabled, "slave" pages therefore link to the "master" page's +discussion page. Translating ----------- -One can edit the PO files using ikiwiki's CGI (a message-by-message interface -could also be implemented at some point). +One can edit the PO files using ikiwiki's CGI (a message-by-message +interface could also be implemented at some point). -If [[tips/untrusted_git_push]] is setup, one can edit the PO files in her -preferred `$EDITOR`, without needing to be online. +If [[tips/untrusted_git_push]] is setup, one can edit the PO files in +her preferred `$EDITOR`, without needing to be online. TODO ==== -OTHERLANGUAGES dependencies ---------------------------- - -Pages using `OTHERLANGUAGES` depend on any "master" and "slave" pages -whose status is being displayed. It is supposed to trigger dependency -loops, but no practical bugs were noticed yet. - -Should pages using the `OTHERLANGUAGES` template loop be declared as -linking to the same page in other versions? To be rigorous, they -should, but this may clutter the backlinks. - Security checks --------------- @@ -243,29 +233,27 @@ gettext/po4a rough corners changes bla.fr.po in repo1; then pushing repo1 to repo2 triggers a PO update, that changes bla.fr.po in repo2; etc.; fixed in `629968fc89bced6727981c0a1138072631751fee`? -- new translations created in the web interface must get proper charset/encoding - gettext metadata, else the next automatic PO update removes any non-ascii - chars; possible solution: put such metadata into the Pot file, and let it - propagate; should be fixed in `773de05a7a1ee68d2bed173367cf5e716884945a`, time - will tell. +- new translations created in the web interface must get proper + charset/encoding gettext metadata, else the next automatic PO update + removes any non-ascii chars; possible solution: put such metadata + into the Pot file, and let it propagate; should be fixed in + `773de05a7a1ee68d2bed173367cf5e716884945a`, time will tell. Misc. improvements ------------------ -### preview - -preview does not work for PO files. - ### automatic POT/PO update -Use the `change` hook instead of `needsbuild`? +- Use the `change` hook instead of `needsbuild`? +- Fix (apparently harmless) undefined values that pollute logs when + saving a master page in the CGI ### page titles -Use nice page titles from meta plugin in links, as inline already does. This is -actually a duplicate for -[[bugs/pagetitle_function_does_not_respect_meta_titles]], which might be fixed -by something like [[todo/using_meta_titles_for_parentlinks]]. +Use nice page titles from meta plugin in links, as inline already +does. This is actually a duplicate for +[[bugs/pagetitle_function_does_not_respect_meta_titles]], which might +be fixed by something like [[todo/using_meta_titles_for_parentlinks]]. ### websetup @@ -274,15 +262,15 @@ Which configuration settings are safe enough for websetup? ### parentlinks When the wiki home page is translatable, the parentlinks plugin sets -`./index.html` as its translations' single parent link. Ideally, the home page's -translations should get no parent link at all, just like the version written in -the master language. +`./index.html` as its translations' single parent link. Ideally, the +home page's translations should get no parent link at all, just like +the version written in the master language. ### backlinks If a given translatable `sourcepage.mdwn` links to \[[destpage]], -`sourcepage.LL.po` also link to \[[destpage]], and the latter has the master -page *and* all its translations listed in the backlinks. +`sourcepage.LL.po` also link to \[[destpage]], and the latter has the +master page *and* all its translations listed in the backlinks. Translation quality assurance ----------------------------- -- cgit v1.2.3 From bc5b875de85419d38688b47e0d40ff808f0ebd86 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 4 Nov 2008 20:05:21 +0100 Subject: po plugin: remove broken parentlinks for home page's translations Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 17 +++++++++++------ doc/plugins/po.mdwn | 7 ------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'doc/plugins') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index cc8e9b2ed..a5bf4fb54 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -38,7 +38,7 @@ sub import { hook(type => "needsbuild", id => "po", call => \&needsbuild); hook(type => "filter", id => "po", call => \&filter); hook(type => "htmlize", id => "po", call => \&htmlize); - hook(type => "pagetemplate", id => "po", call => \&pagetemplate); + hook(type => "pagetemplate", id => "po", call => \&pagetemplate, last => 1); hook(type => "editcontent", id => "po", call => \&editcontent); inject(name => "IkiWiki::bestlink", call => \&mybestlink); inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); @@ -398,9 +398,10 @@ sub otherlanguages ($) { #{{{ sub pagetemplate (@) { #{{{ my %params=@_; - my $page=$params{page}; - my $destpage=$params{destpage}; - my $template=$params{template}; + my $page=$params{page}; + my $destpage=$params{destpage}; + my $template=$params{template}; + my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/) if istranslation($page); if (istranslation($page) && $template->query(name => "percenttranslated")) { $template->param(percenttranslated => percenttranslated($page)); @@ -419,7 +420,6 @@ sub pagetemplate (@) { #{{{ } } elsif (istranslation($page)) { - my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/); add_depends($page, $masterpage); foreach my $translation (values %{$translations{$masterpage}}) { add_depends($page, $translation); @@ -434,7 +434,6 @@ sub pagetemplate (@) { #{{{ # prevent future breakage when ikiwiki internals change. # Known limitations are preferred to future random bugs. if ($template->param('discussionlink') && istranslation($page)) { - my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/); $template->param('discussionlink' => htmllink( $page, $destpage, @@ -444,6 +443,12 @@ sub pagetemplate (@) { #{{{ linktext => gettext("Discussion"), )); } + # remove broken parentlink to ./index.html on home page's translations + if ($template->param('parentlinks') + && istranslation($page) + && $masterpage eq "index") { + $template->param('parentlinks' => []); + } } # }}} sub editcontent () { #{{{ diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 6aa63b429..61ed9e107 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -259,13 +259,6 @@ be fixed by something like [[todo/using_meta_titles_for_parentlinks]]. Which configuration settings are safe enough for websetup? -### parentlinks - -When the wiki home page is translatable, the parentlinks plugin sets -`./index.html` as its translations' single parent link. Ideally, the -home page's translations should get no parent link at all, just like -the version written in the master language. - ### backlinks If a given translatable `sourcepage.mdwn` links to \[[destpage]], -- cgit v1.2.3 From 225e21f6c5da40f3beea27e084515daf83471d95 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Tue, 4 Nov 2008 23:32:32 +0100 Subject: po plugin: redesign refresh mechanism after master page update manually triggering IkiWiki::refresh() was at least dubious, and more or less buggy (it randomly broke the whole backlinks feature); thinking a bit more to add the necessary bits to @needsbuild seems like a better way. don't play with ikiwiki's internals if not absolutely needed. Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 20 ++++++++++++-------- doc/plugins/po.mdwn | 6 ------ 2 files changed, 12 insertions(+), 14 deletions(-) (limited to 'doc/plugins') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index a5bf4fb54..936fe3c49 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -112,14 +112,16 @@ sub checkconfig () { #{{{ sub potfile ($) { #{{{ my $masterfile=shift; (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/); - return File::Spec->catfile($dir, $name . ".pot"); + $dir='' if $dir eq './'; + return File::Spec->catpath('', $dir, $name . ".pot"); } #}}} sub pofile ($$) { #{{{ my $masterfile=shift; my $lang=shift; (my $name, my $dir, my $suffix) = fileparse($masterfile, qr/\.[^.]*/); - return File::Spec->catfile($dir, $name . "." . $lang . ".po"); + $dir='' if $dir eq './'; + return File::Spec->catpath('', $dir, $name . "." . $lang . ".po"); } #}}} sub refreshpot ($) { #{{{ @@ -173,17 +175,22 @@ sub needsbuild () { #{{{ # refresh/create POT and PO files as needed my $updated_po_files=0; foreach my $page (keys %pagesources) { - my $pageneedsbuild = grep { $_ eq $pagesources{$page} } @$needsbuild; if (istranslatable($page)) { + my $pageneedsbuild = grep { $_ eq $pagesources{$page} } @$needsbuild; + my $updated_pot_file=0; my $file=srcfile($pagesources{$page}); if ($pageneedsbuild || ! -e potfile($file)) { refreshpot($file); + $updated_pot_file=1; } my @pofiles; foreach my $lang (keys %{$config{po_slave_languages}}) { my $pofile=pofile($file, $lang); - if ($pageneedsbuild || ! -e $pofile) { + my $pofile_rel=pofile($pagesources{$page}, $lang); + if ($pageneedsbuild || $updated_pot_file || ! -e $pofile) { push @pofiles, $pofile; + push @$needsbuild, $pofile_rel + unless grep { $_ eq $pofile_rel } @$needsbuild; } } if (@pofiles) { @@ -194,7 +201,7 @@ sub needsbuild () { #{{{ } } - # check staged changes in and trigger a wiki refresh. + # check staged changes in if ($updated_po_files) { if ($config{rcs}) { IkiWiki::disable_commit_hook(); @@ -203,8 +210,6 @@ sub needsbuild () { #{{{ IkiWiki::enable_commit_hook(); IkiWiki::rcs_update(); } - IkiWiki::refresh(); - IkiWiki::saveindex(); # refresh module's private variables undef %filtered; undef %translations; @@ -213,7 +218,6 @@ sub needsbuild () { #{{{ } } - # make existing translations depend on the corresponding master page foreach my $master (keys %translations) { foreach my $slave (values %{$translations{$master}}) { diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index 61ed9e107..173a26ac4 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -242,12 +242,6 @@ gettext/po4a rough corners Misc. improvements ------------------ -### automatic POT/PO update - -- Use the `change` hook instead of `needsbuild`? -- Fix (apparently harmless) undefined values that pollute logs when - saving a master page in the CGI - ### page titles Use nice page titles from meta plugin in links, as inline already -- cgit v1.2.3