X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster%2FHTML.pm;fp=lib%2FPlack%2FApp%2FGruntmaster%2FHTML.pm;h=b4abd19f5194fbe28f40bcd41e9794b237119f8b;hb=54de918a932a0f580994da0c80ef7cbc82314b3a;hp=427b197002a5fff16c0dc299f85fde0e88003c95;hpb=1b5b61ae2f2a6aa57397e2f3dd9c324c2fa0d22e;p=gruntmaster-page.git diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index 427b197..b4abd19 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -4,6 +4,7 @@ use parent qw/Exporter/; our @EXPORT = qw/render render_article/; use File::Slurp qw/read_file/; +use List::Util qw[min max]; use HTML::Element::Library; use HTML::TreeBuilder; use POSIX qw//; @@ -277,7 +278,9 @@ sub process_log { my $str = join '&', map { $_ . '=' . $args{args}{$_} } keys %{$args{args}}; $elem->find('a')->edit_href(sub{s/$/&$str/}) if $str; } - $tree->fclass('current')->replace_content("Page $args{current_page} of $args{last_page}"); + + my $total_pages = max(1, $args{last_page}); + $tree->fclass('current')->replace_content("Page $args{current_page} of $total_pages"); } sub process_st {