X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster%2FHTML.pm;h=b4abd19f5194fbe28f40bcd41e9794b237119f8b;hb=refs%2Fheads%2Fnewmc;hp=de27579a5a1a2f7cead908df5ec0d86863da515f;hpb=e85f5f172aa05e8fd509e2fad2ace9b2375719d2;p=plack-app-gruntmaster.git diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index de27579..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//; @@ -82,7 +83,7 @@ sub render_article { $lang //= 'en'; my $title = read_file "a/$art.$lang.title"; chomp $title; - my $meat = read_file "a/$art.$lang"; + my $meat = read_file "a/$art.$lang", binmode => ':utf8'; _render('skel', $lang, title => $title , meat => $meat, %args) } @@ -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 {