Use plain HTML::Element::Library instead of HTML::Seamstress
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster / HTML.pm
index f2b4ec9cead19e8e98af996ff35a3e0f4f8bc83f..ebbc145e22cd3bd9f328c3e3a8da27b749d9e9c8 100644 (file)
@@ -4,7 +4,8 @@ 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/;
 
@@ -45,7 +46,7 @@ sub HTML::Element::namedlink {
 my %page_cache;
 for (<tmpl/*>) {
        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 +75,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;
 }
 
@@ -266,6 +267,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 {
This page took 0.010074 seconds and 4 git commands to generate.