X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster%2FHTML.pm;h=8ddd9e1971b3170e9b8380be1a3d606ec2319d6c;hb=7cbc093ea2bc5b60c8882ea2358af8cb200e58fc;hp=b4a080042f20dd55e3215e045e374e8432aa5e95;hpb=f40a7dec896bd2f5a2d09d155ac20090ca0bcbef;p=gruntmaster-page.git diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index b4a0800..8ddd9e1 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -4,12 +4,18 @@ use parent qw/Exporter/; our @EXPORT = qw/render render_article/; use File::Slurp qw/read_file/; -use HTML::Seamstress; +use HTML::Element::Library; +use HTML::TreeBuilder; use POSIX qw//; use Data::Dumper qw/Dumper/; sub ftime ($) { POSIX::strftime '%c', localtime shift } -sub literal ($) { HTML::Element::Library::super_literal shift // '' } +sub literal ($) { + my $b = HTML::TreeBuilder->new; + $b->ignore_unknown(0); + $b->parse(shift // ''); + HTML::Element::Library::super_literal $b->guts->as_HTML; +} sub HTML::Element::edit_href { my ($self, $sub) = @_; @@ -45,7 +51,7 @@ sub HTML::Element::namedlink { my %page_cache; for () { my ($tmpl, $lang) = m,tmpl/(\w+)\.(\w+),; - my $builder = HTML::Seamstress->new; + my $builder = HTML::TreeBuilder->new; $builder->ignore_unknown(0); $page_cache{$tmpl, $lang} = $builder->parse_file($_); } @@ -74,7 +80,7 @@ sub _render { $process->($tree, %args) if $process; $_->detach for $tree->look_down(static => $args{static} ? 'no' : 'yes'); $_->attr('static', undef) for $tree->look_down(sub {$_[0]->attr('static')}); - $_->attr('smap', undef) for $tree->look_down(sub {$_[0]->attr('defmap')}); + $_->attr('smap', undef) for $tree->look_down(sub {$_[0]->attr('smap')}); $tree->as_HTML; } @@ -268,6 +274,10 @@ sub process_log { $elem->find('a')->edit_href(sub{s/$/&$str/}) if $str; } $tree->fclass('current')->replace_content("Page $args{current_page} of $args{last_page}"); + + my @detach; + push @detach, $args{args}{$_} ? $tree->fclass($_) : () for qw/problem contest owner/; + $_->detach for @detach; } sub process_st {