progress: Display an error if the progress cannot be parsed, and allow the percent parameter to only optionally end with "%".
parent
cc3b946c8f
commit
779c5214f3
|
@ -5,7 +5,7 @@ use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use IkiWiki 2.00;
|
use IkiWiki 2.00;
|
||||||
|
|
||||||
my $percentage_pattern = qr/[0-9]+\%/; # pattern to validate percentages
|
my $percentage_pattern = qr/[0-9]+\%?/; # pattern to validate percentages
|
||||||
|
|
||||||
sub import { #{{{
|
sub import { #{{{
|
||||||
hook(type => "getsetup", id => "progress", call => \&getsetup);
|
hook(type => "getsetup", id => "progress", call => \&getsetup);
|
||||||
|
@ -29,6 +29,12 @@ sub preprocess (@) { #{{{
|
||||||
if (defined $params{percent}) {
|
if (defined $params{percent}) {
|
||||||
$fill = $params{percent};
|
$fill = $params{percent};
|
||||||
($fill) = $fill =~ m/($percentage_pattern)/; # fill is untainted now
|
($fill) = $fill =~ m/($percentage_pattern)/; # fill is untainted now
|
||||||
|
if (! defined $fill || ! length $fill || $fill > 100 || $fill < 0) {
|
||||||
|
error("illegal percent value $params{percent}");
|
||||||
|
}
|
||||||
|
elsif ($fill !~ /%$/) {
|
||||||
|
$fill.="%";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif (defined $params{totalpages} and defined $params{donepages}) {
|
elsif (defined $params{totalpages} and defined $params{donepages}) {
|
||||||
add_depends($params{page}, $params{totalpages});
|
add_depends($params{page}, $params{totalpages});
|
||||||
|
|
|
@ -5,6 +5,8 @@ ikiwiki (2.65) UNRELEASED; urgency=low
|
||||||
* editdiff: Broken since 2.62 due to wrong syntax, now fixed.
|
* editdiff: Broken since 2.62 due to wrong syntax, now fixed.
|
||||||
* aggregate: Support atom feeds with only a summary element, and no content
|
* aggregate: Support atom feeds with only a summary element, and no content
|
||||||
elements.
|
elements.
|
||||||
|
* progress: Display an error if the progress cannot be parsed, and allow
|
||||||
|
the percent parameter to only optionally end with "%".
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Wed, 17 Sep 2008 14:26:56 -0400
|
-- Joey Hess <joeyh@debian.org> Wed, 17 Sep 2008 14:26:56 -0400
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,11 @@ Anyone can confirm the bug? --[[Paweł|ptecza]]
|
||||||
>> that '%' sign is confusing here and should be dropped. I hope it's clear for all
|
>> that '%' sign is confusing here and should be dropped. I hope it's clear for all
|
||||||
>> people that "percent" parameter passes values in percentages. --[[Paweł|ptecza]]
|
>> people that "percent" parameter passes values in percentages. --[[Paweł|ptecza]]
|
||||||
|
|
||||||
|
>>> [[fixed|done]] --[[Joey]]
|
||||||
|
|
||||||
>>> I've forgotten to add that now the HTML code is OK, but I can see only
|
>>> I've forgotten to add that now the HTML code is OK, but I can see only
|
||||||
>>> "75%" string on white background wihout any border. I need to look closer
|
>>> "75%" string on white background wihout any border. I need to look closer
|
||||||
>>> at CSS styles for the progress bar. --[[Paweł|ptecza]]
|
>>> at CSS styles for the progress bar. --[[Paweł|ptecza]]
|
||||||
|
|
||||||
|
>>>> You need the `div.progress` and `div.progress-done` from ikiwiki's
|
||||||
|
>>>> default `style.css`. --[[Joey]]
|
||||||
|
|
Loading…
Reference in New Issue