my $htc = HTML::Template::Compiled->new(scalarref => \$templates{$self}{$lang}, default_escape => 'HTML', use_perl => 1);
$self->_generate($htc, $lang, @args);
my $out = $htc->output;
- utf8::downgrade($out);
+ utf8::encode($out);
my $vary = 'Accept-Language, ' . $self->vary;
[200, ['Content-Type' => 'text/html', 'Content-Language' => $_[1], 'Vary' => $vary, 'X-Forever' => 1, 'Cache-Control' => 'max-age=' . $self->max_age], [ $out ] ]
}
@params{'page', 'pages'} = ($page, $pages);
$rs = $rs->search(undef, {offset => ($page - 1) * PAGE_SIZE, ($page == $pages ? () : (rows => PAGE_SIZE))});
}
- $rs = $rs->search(undef, {prefetch => $thing{prefetch}}) if exists $thing{prefetch};
+ $rs = $rs->search(undef, {
+ exists $thing{prefetch} ? (prefetch => $thing{prefetch}) : (),
+ exists $thing{columns} ? (columns => $thing{columns}) : (),
+ });
my @thing = map +{rs => $_, $_->get_columns}, $rs->all;
@thing = map { $thing{mangle}->(); $_ } @thing if exists $thing{mangle};
@thing = grep { $thing{choose}->() } @thing if exists $thing{choose};
sub group (&);
sub mangle (&);
sub prefetch;
+sub columns;
sub thing (&){
my %thing;
local *{"group"} = sub { $thing{group} = shift };
local *{"makers"} = sub { $thing{makers} = shift };
local *{"prefetch"} = sub { $thing{prefetch} = \@_ };
+ local *{"columns"} = sub { $thing{columns} = \@_ };
use strict 'refs';
shift->();
my ($self, $frm, $env) = @_;
my $r = Plack::Request->new($env);
my ($problem, $format, $contest, $private, $prog) = map {scalar $r->param($_)} 'problem', 'prog_format', 'contest', 'private', 'source_code';
+ $problem //= $env->{'gruntmaster.problem'};
+ $contest //= $env->{'gruntmaster.contest'};
my $upload = $r->upload('prog');
if (defined $upload) {
my $temp = read_file $upload->path;
return reply 'A required parameter was not supplied' if grep { !defined } $problem, $format, $prog;
return reply 'Maximum source size is 10KB' if length $prog > 25 * 1024;
return reply 'You must wait 30 seconds between jobs' unless time > db($env)->user($r->user)->lastjob + 30;
- db($env)->user($r->user)->lastjob(time)->update;
+ db($env)->user($r->user)->update({lastjob => time});
db($env)->jobs->create({
defined $contest ? (contest => $contest) : (),
extension => FORMAT_EXTENSION->{$format},
format => $format,
defined $private ? (private => $private) : (),
- probem => $problem,
+ problem => $problem,
source => $prog,
- user => $r->user
+ owner => $r->user
});
$contest //= '';
generic qw/us ct pb log/;
get qr,/log/src/$number\.$word, => 'Src';
- post qr,/pb/$word/submit, => 'Submit';
+ post qr,/submit, => 'Submit';
post qr,/action/register, => 'Register';
post qr,/action/passwd, => 'Passwd';