Add static mode
[plack-app-gruntmaster.git] / lib / Plack / App / Gruntmaster / HTML.pm
index 57b4e50a5f2069bfcde733c0e10fe965ee7d1649..3195b623170da4c58059fd9f2cc8fcfe4e31d94b 100644 (file)
@@ -50,11 +50,11 @@ sub render {
 }
 
 sub render_article {
-       my ($art, $lang) = @_;
+       my ($art, $lang, %args) = @_;
        $lang //= 'en';
        my $title = read_file "a/$art.$lang.title";
        my $meat  = read_file "a/$art.$lang";
-       _render('skel', $lang, title => $title , meat => $meat)
+       _render('skel', $lang, title => $title , meat => $meat, %args)
 }
 
 sub _render {
@@ -66,6 +66,8 @@ sub _render {
        $tree->defmap(smap => \%args);
        my $process = __PACKAGE__->can("process_$tmpl");
        $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')});
        $tree->as_HTML;
 }
 
@@ -171,8 +173,8 @@ sub process_pb_entry {
                $tree->fid('nosubmit')->detach;
                $tree->look_down(name => 'problem')->attr(value => $args{id});
                my $contest = $tree->look_down(name => 'contest');
-               $contest->attr(value => $args{contest}) if $args{contest};
-               $contest->detach unless $args{contest}
+               $contest->attr(value => $args{args}{contest}) if $args{args}{contest};
+               $contest->detach unless $args{args}{contest}
        } else {
                $tree->fid('nosubmit')->find('a')->edit_href(sub{s/id/$args{id}/});
                $tree->fid('submit')->detach
@@ -236,7 +238,7 @@ sub process_log {
                my ($data, $tr) = @_;
                $tr->fclass('id')->namedlink($data->{id});
                $tr->fclass('problem')->namedlink($data->{problem}, $data->{problem_name});
-               $tr->fclass('problem')->find('a')->edit_href(sub{$_ .= "?contest=$args{contest}"}) if $args{contest};
+               $tr->fclass('problem')->find('a')->edit_href(sub{$_ .= "?contest=$args{args}{contest}"}) if $args{args}{contest};
                $tr->fclass('contest')->namedlink($data->{contest}, $data->{contest_name}) if $data->{contest};
                $tr->fclass('contest')->replace_content('None') unless $data->{contest};
                $tr->fclass('date')->replace_content(ftime $data->{date});
This page took 0.011378 seconds and 4 git commands to generate.