*{"${caller}::TITLE"} = sub () { $title };
*{"${caller}::debug"} = sub {
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
- $_[0]->({qw/level debug message/ => $_[1]})
+ $_[0]->{'psgix.logger'}->({qw/level debug message/ => $_[1]})
};
}
use CSS::Minifier::XS qw/minify/;
sub generate{
- my ($self, $format, $logger, $theme) = @_;
- debug $logger => "theme is $theme";
+ my ($self, $format, $env, $theme) = @_;
+ debug $env => "theme is $theme";
return [404, ['Content-Type' => 'text/plain'], [ 'Not found' ]] unless -e "css/themes/$theme.css";
my $css = read_file "css/themes/$theme.css";
$css .= read_file $_ for <css/*.css>;
};
sub _generate{
- my ($self, $htc, $lang, $logger) = @_;
- debug $logger => "language is '$lang'";
+ my ($self, $htc, $lang, $env) = @_;
+ debug $env => "language is '$lang'";
my (@running, @pending, @finished);
for (contests) {
};
sub _generate{
- my ($self, $htc, $lang, $logger, $id) = @_;
- debug $logger => "language is '$lang' and id is '$id'";
+ my ($self, $htc, $lang, $env, $id) = @_;
+ debug $env => "language is '$lang' and id is '$id'";
$htc->param(id => $id);
$htc->param(name => contest_name $id);
use JavaScript::Minifier::XS qw/minify/;
sub generate{
- my ($self, $format, $logger) = @_;
- debug $logger => "";
+ my ($self, $format, $env) = @_;
+ debug $env => "";
my $js;
$js .= read_file $_ for <js/*.js>;
[200, ['Content-Type' => 'application/javascript', 'Cache-Control' => 'public, max-age=604800'], [$js] ]
};
sub _generate{
- my ($self, $htc, $lang, $logger, $ct, $page) = @_;
- debug $logger => "language is '$lang', contest is '$ct' and page is '$page'";
+ my ($self, $htc, $lang, $env, $ct, $page) = @_;
+ debug $env => "language is '$lang', contest is '$ct' and page is '$page'";
local $Gruntmaster::Data::contest = $ct if $ct;
my $pages = POSIX::floor (jobcard / PAGE_SIZE);
};
sub _generate{
- my ($self, $htc, $lang, $logger, $ct, $id) = @_;
- debug $logger => "language is '$lang', contest is '$ct' and id is '$id'";
+ my ($self, $htc, $lang, $env, $ct, $id) = @_;
+ debug $env => "language is '$lang', contest is '$ct' and id is '$id'";
local $Gruntmaster::Data::contest = $ct;
my @tests = ();
};
sub _generate{
- my ($self, $htc, $lang, $logger, $ct) = @_;
- debug $logger => "language is '$lang' and contest is '$ct'";
+ my ($self, $htc, $lang, $env, $ct) = @_;
+ debug $env => "language is '$lang' and contest is '$ct'";
local $Gruntmaster::Data::contest = $ct if $ct;
my @problems = sort { $b->{name} cmp $a->{name} } map +{
};
sub _generate{
- my ($self, $htc, $lang, $logger, $contest, $id) = @_;
- debug $logger => "language is '$lang', contest is '$contest', id is '$id'";
+ my ($self, $htc, $lang, $env, $contest, $id) = @_;
+ debug $env => "language is '$lang', contest is '$contest', id is '$id'";
$htc->param(cansubmit => 1);
if ($contest) {
};
sub generate{
- my ($self, $format, $logger, $ct, $job, $ext) = @_;
- debug $logger => "Contest is $ct, job is $job and extension is $ext";
+ my ($self, $format, $env, $ct, $job, $ext) = @_;
+ debug $env => "Contest is $ct, job is $job and extension is $ext";
local $Gruntmaster::Data::contest = $ct if $ct;
[200, ['Content-Type' => CONTENT_TYPES->{$ext}, 'Cache-Control' => 'max-age=604800'], [job_inmeta($job)->{files}{prog}{content}] ]
}
sub _generate{
- my ($self, $htc, $lang, $logger, $ct) = @_;
- debug $logger => "language is '$lang' and contest is '$ct'";
+ my ($self, $htc, $lang, $env, $ct) = @_;
+ debug $env => "language is '$lang' and contest is '$ct'";
my ($totaltime, $start);
local $Gruntmaster::Data::contest;
};
sub _generate{
- my ($self, $htc, $lang, $logger) = @_;
- debug $logger => "language is '$lang'";
+ my ($self, $htc, $lang, $env) = @_;
+ debug $env => "language is '$lang'";
$htc->param(users => [ sort { lc $a->{name} cmp lc $b->{name} }
map { {id => $_, name => user_name} }
};
sub _generate{
- my ($self, $htc, $lang, $logger, $us) = @_;
- debug $logger => "language is '$lang', user is '$us'";
+ my ($self, $htc, $lang, $env, $us) = @_;
+ debug $env => "language is '$lang', user is '$us'";
local $_ = $us;
$htc->param(name => user_name);
my @args;
next unless @args = $r->path =~ m/^$re$/a;
my $format = choose $obj->variants, $r->headers;
- return $obj->generate($format, $env->{'psgix.logger'}, map { $_ // '' } @args);
+ return $obj->generate($format, $env, map { $_ // '' } @args);
}
if ($r->method eq 'GET' || $r->method eq 'HEAD') {