]> iEval git - gruntmaster-page.git/blobdiff - lib/Plack/App/Gruntmaster/HTML.pm
Actually use AUTH_TIMEOUT
[gruntmaster-page.git] / lib / Plack / App / Gruntmaster / HTML.pm
index 26669c7da1c520d5b88d6b7b4b7aec55d9917f05..3306be2100508109375494120dfba633ef897bdd 100644 (file)
@@ -79,6 +79,7 @@ sub process_skel {
 sub process_us_entry {
        my ($tree, %args) = @_;
        $tree->fid($_)->attr('href', "/$_/?owner=$args{id}") for qw/log pb/;
+       $tree->fid('track_user')->attr('data-user', $args{id});
        my @solved = map { $_->{solved} ? ($_->{problem}) : () } @{$args{problems}};
        my @attempted = map { !$_->{solved} ? ($_->{problem}) : () } @{$args{problems}};
 
@@ -137,22 +138,25 @@ sub process_pb_entry {
        $tree->fid('owner')->edit_href(sub{s/owner_id/$args{owner}/});
        $tree->fid('job_log')->edit_href(sub{s/problem_id/$args{id}/});
        $tree->fid('solution')->edit_href(sub{s/problem_id/$args{id}/});
+       $tree->fid('job_log')->edit_href(sub{$_ .= "&private=$args{private}"}) if $args{private};
        $tree->content_handler(
                statement => literal $args{statement},
+               level     => ucfirst $args{level},
                author    =>         $args{author},
                owner     =>         $args{owner_name} || $args{owner});
        if ($args{contest_stop}) {
                $tree->fid('solution')->detach;
                $tree->fid('solution_modal')->detach;
                my $countdown = $tree->fid('countdown');
-               $countdown->attr('data-start' => $args{contest_start});
+               $countdown->attr('data-start' => $args{open_time});
                $countdown->attr('data-stop' => $args{contest_stop});
                $countdown->attr('data-time' => $args{time});
                my $left = $args{contest_stop} - $args{time};
                $countdown->replace_content(sprintf '%02d:%02d:%02d', $left/60/60, $left/60%60, $left%60);
                $tree->fid('score')->attr('data-value' => $args{value});
-               $tree->fid('score')->replace_content(Gruntmaster::Data::calc_score($args{value}, $args{time} - $args{contest_start}, 0, $args{contest_stop} - $args{contest_start}));
+               $tree->fid('score')->replace_content(Gruntmaster::Data::Result::Contest::calc_score($args{value}, $args{time} - $args{open_time}, 0, $args{contest_stop} - $args{contest_start}));
        } else {
+               $tree->fid('solution')->detach unless $args{solution};
                $_->detach for $tree->fclass('rc'); # requires contest
                $tree->fid('solution_modal')->fclass('modal-body')->replace_content(literal $args{solution});
        }
@@ -191,6 +195,17 @@ sub process_pb {
 
 sub process_log_entry {
        my ($tree, %args) = @_;
+       $tree->fid('problem')->namedlink(@args{qw/problem problem_name/});
+       $tree->fid('owner')->namedlink(@args{qw/owner owner_name/});
+       $tree->fid('source')->namedlink("$args{id}.$args{extension}", sprintf '%.2fKB', $args{size}/1024);
+       if ($args{contest}) {
+               $tree->fid('contest')->namedlink(@args{qw/contest contest_name/});
+               $tree->fid('problem')->find('a')->edit_href(sub {$_.="?contest=$args{contest}"});
+       } else {
+               $tree->fid('contest')->left->detach;
+               $tree->fid('contest')->detach;
+       }
+
        $args{errors} ? $tree->fid('errors')->find('pre')->replace_content($args{errors}) : $tree->fid('errors')->detach;
        my $iter = sub {
                my ($data, $tr) = @_;
@@ -198,7 +213,8 @@ sub process_log_entry {
                $tr->defmap(class => $data);
                $tr->fclass('result_text')->attr(class => "r$data->{result}")
        };
-       @{$args{results}} ? $tree->fid('results')->find('tbody')->find('tr')->iter3($args{results}, $iter) : $tree->fid('results')->detach;
+       $args{results} ? $tree->fid('results')->find('tbody')->find('tr')->iter3($args{results}, $iter) : $tree->fid('results')->detach;
+       $tree->fid('no_results')->detach if $tree->fid('results') || $tree->fid('errors');
 }
 
 sub process_log {
@@ -216,8 +232,15 @@ sub process_log {
                $tr->fclass('result_text')->attr(class => "r$data->{result}");
        };
        $tree->find('table')->find('tbody')->find('tr')->iter3($args{log}, $iter);
-       $args{next_page} ? $tree->fclass('next')->namedlink($args{next_page}, 'Next') : $tree->fclass('next')->attr(class => 'next disabled');
-       $args{previous_page} ? $tree->fclass('previous')->namedlink($args{previous_page}, 'Previous') : $tree->fclass('previous')->attr(class => 'previous disabled');
+       $args{next_page} ? $tree->fclass('next')->namedlink($args{next_page}, 'Next') : $tree->fclass('next')->detach;
+       $args{previous_page} ? $tree->fclass('previous')->namedlink($args{previous_page}, 'Previous') : $tree->fclass('previous')->detach;
+       for my $cls (qw/next previous/) {
+               my $elem = $tree->fclass($cls);
+               next unless $elem;
+               delete $args{args}{page};
+               my $str = join '&', map { $_ . '=' . $args{args}{$_} } keys $args{args};
+               $elem->find('a')->edit_href(sub{s/$/&$str/});
+       }
        $tree->fclass('current')->replace_content("Page $args{current_page} of $args{last_page}");
 }
 
@@ -227,7 +250,7 @@ sub process_st {
        my $pbiter = sub {
                my ($data, $th) = @_;
                $th->attr(class => undef);
-               $th->namedlink($data->id, $data->name);
+               $th->namedlink(@$data);
        };
        $tree->fclass('problem')->iter3($args{problems}, $pbiter);
        my $iter = sub {
This page took 0.02874 seconds and 4 git commands to generate.