X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/aff9bf5a7ab21ea303c4882272e76630d05d40f2..ca9e45c3ba2ad852123aeb8783eed07ed73ce00c:/IkiWiki/Plugin/po.pm diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index b07384514..6f716a91f 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -70,7 +70,7 @@ sub import { # 2. Injected functions # 3. Blackboxes for private data # 4. Helper functions -# 5. PageSpec's +# 5. PageSpecs # ,---- @@ -126,6 +126,13 @@ sub getsetup () { safe => 1, rebuild => 1, }, + po_strictly_refresh_backlinks => { + type => "boolean", + example => 1, + description => "refresh a page when a backlinked page is changed (can hit performance)", + safe => 1, + rebuild => 1, + }, } sub checkconfig () { @@ -166,6 +173,10 @@ sub checkconfig () { ! defined $config{po_translation_status_in_links}) { $config{po_translation_status_in_links}=1; } + if (! exists $config{po_strictly_refresh_backlinks} || + ! defined $config{po_strictly_refresh_backlinks}) { + $config{po_strictly_refresh_backlinks}=1; + } push @{$config{wiki_file_prune_regexps}}, qr/\.pot$/; } @@ -250,8 +261,8 @@ sub htmlize (@) { # force content to be htmlize'd as if it was the same type as the master page return IkiWiki::htmlize($page, $page, - pagetype(srcfile($pagesources{masterpage($page)})), - $content); + pagetype(srcfile($pagesources{masterpage($page)})), + $content); } sub pagetemplate (@) { @@ -266,7 +277,7 @@ sub pagetemplate (@) { $template->param(percenttranslated => percenttranslated($page)); } if ($template->query(name => "istranslation")) { - $template->param(istranslation => istranslation($page)); + $template->param(istranslation => scalar istranslation($page)); } if ($template->query(name => "istranslatable")) { $template->param(istranslatable => istranslatable($page)); @@ -287,13 +298,13 @@ sub pagetemplate (@) { # Known limitations are preferred to future random bugs. if ($template->param('discussionlink') && istranslation($page)) { $template->param('discussionlink' => htmllink( - $page, - $destpage, - $masterpage . '/' . gettext("Discussion"), - noimageinline => 1, - forcesubpage => 0, - linktext => gettext("Discussion"), - )); + $page, + $destpage, + $masterpage . '/' . gettext("Discussion"), + noimageinline => 1, + forcesubpage => 0, + linktext => gettext("Discussion"), + )); } # Remove broken parentlink to ./index.html on home page's translations. # It works because this hook has the "last" parameter set, to ensure it @@ -307,8 +318,10 @@ sub pagetemplate (@) { sub postscan (@) { my %params = @_; - my $page = $params{page}; + return unless $config{po_strictly_refresh_backlinks}; + + my $page = $params{page}; # backlinks involve back-dependencies, so that nicepagetitle effects, # such as translation status displayed in links, are updated use IkiWiki::Render; @@ -442,19 +455,19 @@ sub checkcontent (@) { return undef; } -sub canremove ($$$) { - my ($page, $cgi, $session) = (shift, shift, shift); +sub canremove (@) { + my %params = @_; - if (istranslation($page)) { + if (istranslation($params{page})) { return gettext("Can not remove a translation. Removing the master page, ". "though, removes its translations as well."); } return undef; } -sub canrename ($$@) { - my ($cgi, $session) = (shift, shift); +sub canrename (@) { my %params = @_; + my $session = $params{session}; if (istranslation($params{src})) { my $masterpage = masterpage($params{src}); @@ -535,11 +548,6 @@ sub formbuilder (@) { my @types = grep { $_ ne 'po' } $field->options; $field->options(\@types) if @types; } - else { - # make sure the default value is not po; - # does this case actually happen? - debug "po(formbuilder) ".gettext("type field is not selected - not implemented yet"); - } } } } @@ -1116,13 +1124,10 @@ sub isvalidpo ($) { } # ,---- -# | PageSpec's +# | PageSpecs # `---- package IkiWiki::PageSpec; -use warnings; -use strict; -use IkiWiki 2.00; sub match_istranslation ($;@) { my $page=shift;