sub some_auth_required {
my $r = Plack::Request->new($_[0]);
- return 1 if $r->path eq '/action/passwd';
+ my $word = qr,(\w+),a;
+ return 1 if $r->path eq '/action/passwd' || $r->path =~ m,/pb/$word/submit$,;
0
}
use Plack::Request;
sub generate{
- my ($self, $format, $env, $ct, $job, $ext) = @_;
+ my ($self, $format, $env) = @_;
my $r = Plack::Request->new($env);
my ($oldpass, $newpass, $confirm) = map {scalar $r->param($_)} 'password', 'new_password', 'confirm_new_password';
</div>
<div class="col-md-3">
-<dl class="dl-horizontal">
+<dl>
<dt>Author</dt> <dd><tmpl_var author></dd>
<dt>Owner</dt> <dd><tmpl_var owner></dd>
</dl>
<tmpl_if cansubmit>
<h1>Submit solution</h1>
-<form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data" role="form">
+<form action="<tmpl_var id>/submit" method="POST" enctype="multipart/form-data" role="form">
<input type="hidden" name="problem" value="<tmpl_var id>">
<tmpl_if_defined contest><input type="hidden" name="contest" value="<tmpl_var contest>"></tmpl_if_defined>
-<div class="form-group"><label for="prog">File:</label><input id="prog" name="prog" required type="file"></div>
+<div class="form-group"><label for="prog">File:</label><input id="prog" name="prog" type="file"></div>
<div class="form-group"><label for="source_code">Source code:</label> <textarea class="form-control" id="source_code" name="source_code"></textarea></div>
<div class="form-group"><label for="prog_format">File format:</label><select id="prog_format" name="prog_format" class="form-control" required>
<tmpl_loop formats><option value="<tmpl_var _>"><tmpl_var _></option>
HTML
};
+use constant FORMATS => [qw/C CPP MONO JAVA PASCAL PERL PYTHON/];
+
sub _generate{
my ($self, $htc, $lang, $env, $contest, $id) = @_;
debug $env => "language is '$lang', contest is '$contest', id is '$id'";
$htc->param(cansubmit => time <= contest_end $contest);
$htc->param(contest => $contest);
}
- $htc->param(formats => Gruntmaster::Page::Submit::FORMATS);
+ $htc->param(formats => FORMATS);
$htc->param(id => $id);
local $Gruntmaster::Data::contest = $contest if $contest;
$htc->param(name => problem_name $id);
use Plack::Request;
sub generate{
- my ($self, $format, $env, $ct, $job, $ext) = @_;
+ my ($self, $format, $env) = @_;
my $r = Plack::Request->new($env);
my ($username, $password, $confirm_password, $name, $email, $phone, $town, $university, $level) = map { die if length > 200; $_ } map {scalar $r->param($_)} qw/username password confirm_password name email phone town university level/;
use 5.014000;
use strict;
use warnings;
-use Gruntmaster::Page::Base submit => 'Submit job';
+use Gruntmaster::Page::Base;
our @ISA = qw/Gruntmaster::Page::Base/;
our $VERSION = '0.001';
-use constant FORMATS => [qw/C CPP JAVA PERL PYTHON/];
+use Apache2::Authen::Passphrase qw/pwcheck pwset USER_REGEX/;
+use File::Slurp qw/read_file/;
+use Plack::Request;
-use constant TEMPLATES => {
- en => <<'HTML',
-<form action="https://gm.ieval.ro/action/submit" method="POST" enctype="multipart/form-data">
-<label>Problem:<br>
-<select name="problem" required>
-<tmpl_loop problems><option value="<tmpl_var id>"><tmpl_var name></option>
-</tmpl_loop></select></label><p>
+use constant FORMAT_EXTENSION => {
+ C => 'c',
+ CPP => 'cpp',
+ MONO => 'cs',
+ JAVA => 'java',
+ PASCAL => 'pas',
+ PERL => 'pl',
+ PYTHON => 'py',
+};
-<label>File:<br>
-<input name="prog" required type="file"></label><p>
+sub generate{
+ 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';
+ my $upload = $r->upload('prog');
+ if (defined $upload) {
+ my $temp = read_file $upload->filename;
+ $prog = $temp if $temp
+ }
+ die if defined $contest && $contest !~ /^\w+$/ ;
+ die if defined $contest && (time > contest_end $contest);
+ return reply 'A required parameter was not supplied' if grep { !defined } $problem, $format, $prog;
-<label>File format:<br>
-<select name="prog_format" required>
-<tmpl_loop formats><option value="<tmpl_var _>"><tmpl_var _></option>
-</tmpl_loop></select></label><p>
+ local $Gruntmaster::Data::contest = $contest;
-<input type="submit" value="Submit job">
-HTML
-};
+ my $job = push_job (
+ date => time,
+ problem => $problem,
+ user => $r->user,
+ defined $private ? (private => $private) : (),
+ defined $contest ? (contest => $contest, private => 1) : (),
+ filesize => length $prog,
+ extension => FORMAT_EXTENSION->{$format},
+ );
-sub _generate{
- my ($self, $htc, $path, $lang) = @_;
+ set_job_inmeta $job, {
+ files => {
+ prog => {
+ format => $format,
+ name => 'prog.' . FORMAT_EXTENSION->{$format},
+ content => $prog,
+ }
+ }
+ };
- my @problems = map +{ id => $_, name => problem_name }, problems;
- $htc->param(problems => \@problems);
- $htc->param(formats => FORMATS);
+ $contest //= '';
+ PUBLISH 'jobs', "$contest.$job";
+ [303, [Location => $r->path =~ s,/pb/\w+/submit$,/log/,r], ['']]
}
+sub variants{ [[reply => 1, undef, undef, undef, undef, undef]] }
+
1
get qr,$ct/log/st, => 'St';
get qr,$ct/log/job/$word, => 'Log::Entry';
get qr,$ct/log/src/$word\.$word, => 'Src';
- get qr,$ct/submit, => 'Submit';
get qr,$ct/pb/, => 'Pb';
get qr,$ct/pb/$word, => 'Pb::Entry';
+ post qr,$ct/pb/$word/submit, => 'Submit';
post qr,/action/register, => 'Register';
post qr,/action/passwd, => 'Passwd';