X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/779c5214f330269fa95a5fed5b16fe8d65730102..0ebb44955aaf454974b9e92f23539bd0e83aee59:/IkiWiki/Plugin/progress.pm diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm index 6cb21a916..26c537a84 100644 --- a/IkiWiki/Plugin/progress.pm +++ b/IkiWiki/Plugin/progress.pm @@ -3,25 +3,25 @@ package IkiWiki::Plugin::progress; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; my $percentage_pattern = qr/[0-9]+\%?/; # pattern to validate percentages -sub import { #{{{ +sub import { hook(type => "getsetup", id => "progress", call => \&getsetup); hook(type => "preprocess", id => "progress", call => \&preprocess); hook(type => "format", id => "progress", call => \&format); -} # }}} +} -sub getsetup () { #{{{ +sub getsetup () { return plugin => { safe => 1, rebuild => undef, }, -} #}}} +} -sub preprocess (@) { #{{{ +sub preprocess (@) { my %params=@_; my $fill; @@ -29,16 +29,15 @@ sub preprocess (@) { #{{{ if (defined $params{percent}) { $fill = $params{percent}; ($fill) = $fill =~ m/($percentage_pattern)/; # fill is untainted now + $fill=~s/%$//; if (! defined $fill || ! length $fill || $fill > 100 || $fill < 0) { - error("illegal percent value $params{percent}"); - } - elsif ($fill !~ /%$/) { - $fill.="%"; + error(sprintf(gettext("illegal percent value %s"), $params{percent})); } + $fill.="%"; } elsif (defined $params{totalpages} and defined $params{donepages}) { - add_depends($params{page}, $params{totalpages}); - add_depends($params{page}, $params{donepages}); + add_depends($params{page}, $params{totalpages}, presence => 1); + add_depends($params{page}, $params{donepages}, presence => 1); my @pages=keys %pagesources; my $totalcount=0; @@ -57,7 +56,7 @@ sub preprocess (@) { #{{{ } } else { - error("need either `percent` or `totalpages` and `donepages` parameters"); + error(gettext("need either `percent` or `totalpages` and `donepages` parameters")); } return <$fill EODIV -} # }}} +} -sub format(@) { #{{{ +sub format(@) { my %params = @_; # If HTMLScrubber has removed the style attribute, then bring it back @@ -75,6 +74,6 @@ sub format(@) { #{{{ $params{content} =~ s!
($percentage_pattern)
!
$1
!g; return $params{content}; -} #}}} +} 1