From 37220f63b3da2607b803e74e647298472bd5f5e0 Mon Sep 17 00:00:00 2001 From: Sergiu Puscas Date: Mon, 10 Apr 2017 00:39:39 +0300 Subject: [PATCH] fixed "Page 1 of 0" in job log --- lib/Plack/App/Gruntmaster/HTML.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index 7a98073..40b47a7 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//; @@ -276,7 +277,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 { -- 2.39.2