]> iEval git - gruntmaster-page.git/blobdiff - lib/Gruntmaster/Page/Ct/Entry.pm
Make all generators inherit from a common base
[gruntmaster-page.git] / lib / Gruntmaster / Page / Ct / Entry.pm
index 50ee0c2b259d1879f77e5233cea04e91df776b38..6266661e39c288d4112c2a5c475ec87224968857 100644 (file)
@@ -3,49 +3,31 @@ package Gruntmaster::Page::Ct::Entry;
 use 5.014000;
 use strict;
 use warnings;
-use parent qw/Exporter/;
-our @EXPORT_OK = qw/generate/;
+use Gruntmaster::Page::Base ct_entry => '<tmpl_var name>';
+our @ISA = qw/Gruntmaster::Page::Base/;
 our $VERSION = '0.001';
 
-use Fcntl qw/:flock/;
-use HTML::Template::Compiled;
-use IO::File;
-use POSIX qw/strftime/;
-use YAML::Any qw/LoadFile/;
-use File::Basename qw/fileparse/;
-use File::Slurp qw/slurp/;
-use Gruntmaster::Page::Common qw/header footer/;
-
-use constant TITLE => '<tmpl_var name>';
-
-my %templates = (
-  en => <<'HTML',
+use constant TEMPLATES => {
+       en => <<'HTML',
 Contest start time: <tmpl_var start><br>
 Contest end time: <tmpl_var end><p>
 
 <tmpl_if started><a href="pb/">Problems</a><br>
 <a href="log/">Job log</a><br>
-<a href="st/">Standings</a></tmpl_if>
+<a href="log/st.var">Standings</a></tmpl_if>
 HTML
-);
+};
 
-$templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
-$templates{$_} .= footer $_ for keys %templates;
+sub _generate{
+       my ($self, $htc, $path, $lang) = @_;
 
-sub generate{
-  my ($path, $lang) = @_;
-  $path = ($path =~ m,ct/(.*)/index,)[0];
-  my $template = $templates{$lang};
-  my $htc = HTML::Template::Compiled->new(scalarref => \$template);
-  flock my $metafh = IO::File->new("<ct/$path/meta.yml"), LOCK_SH;
-  my $meta = LoadFile "ct/$path/meta.yml";
+       $path = ($path =~ m,ct/(.*)/index,)[0];
 
-  $htc->param(id => $path);
-  $htc->param(name => $meta->{name});
-  $htc->param(start => strftime '%c', localtime $meta->{start});
-  $htc->param(end => strftime '%c', localtime $meta->{end});
-  $htc->param(started => time >= $meta->{start});
-  $htc->output
+       $htc->param(id => $path);
+       $htc->param(name => contest_name $path);
+       $htc->param(start => strftime '%c', contest_start);
+       $htc->param(end => strftime '%c', contest_end);
+       $htc->param(started => time >= contest_start);
 }
 
 1
This page took 0.024207 seconds and 4 git commands to generate.