X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FPlack%2FApp%2FGruntmaster%2FHTML.pm;h=5ea06265ec9d3b11980ba9147a6e5b431d97ed25;hb=4f3b70b7d2366e68014ca2eec7d4c051f3418031;hp=2ae8a4410626037942da16ff01399768760f934e;hpb=dc6ca3bcf2500c25510068b38af7e040f23b2dde;p=plack-app-gruntmaster.git diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index 2ae8a44..5ea0626 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -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}}; @@ -102,13 +103,12 @@ sub process_us_entry { sub process_us { my ($tree, %args) = @_; - my $item = $tree->fclass('list-group-item'); - $item->replace_with(map { - my $new = $item->clone; - $new->attr(href => $_->{id}); - $new->replace_content($_->{name} || $_->{id}); - $new - } @{$args{us}}); + my $iter = sub { + my ($data, $tr) = @_; + $tr->fclass('user')->namedlink($data->{id}, $data->{name}); + $tr->fclass($_)->replace_content($data->{$_}) for qw/solved attempted contests/; + }; + $tree->find('tbody')->find('tr')->iter3($args{us}, $iter); } sub process_ct_entry { @@ -138,8 +138,10 @@ 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}) { @@ -157,6 +159,7 @@ sub process_pb_entry { $_->detach for $tree->fclass('rc'); # requires contest $tree->fid('solution_modal')->fclass('modal-body')->replace_content(literal $args{solution}); } + $tree->fid('solution')->detach unless $args{solution}; if ($args{cansubmit}) { $tree->look_down(name => 'problem')->attr(value => $args{id}); my $contest = $tree->look_down(name => 'contest'); @@ -192,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) = @_; @@ -199,7 +213,7 @@ 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; } sub process_log { @@ -217,8 +231,8 @@ 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; $tree->fclass('current')->replace_content("Page $args{current_page} of $args{last_page}"); }