]> iEval git - plack-app-gruntmaster.git/blobdiff - lib/Gruntmaster/Page/Log.pm
Close form element in Pb::Entry
[plack-app-gruntmaster.git] / lib / Gruntmaster / Page / Log.pm
index b12d7795b25b53664f4116944347f5bd8646300a..c92bf4d82ab962cfbab64f9df3a31b1ddd6db562 100644 (file)
@@ -14,7 +14,7 @@ use HTML::Template::Compiled;
 use IO::File;
 use POSIX qw/strftime/;
 use YAML::Any qw/LoadFile/;
-use Gruntmaster::Page qw/header footer/;
+use Gruntmaster::Page::Common qw/header footer/;
 
 my %templates = (
   en => <<'HTML',
@@ -36,22 +36,24 @@ $templates{$_}  = header($_, TITLE) . $templates{$_} for keys %templates;
 $templates{$_} .= footer $_ for keys %templates;
 
 sub generate{
-  my $template = $templates{$_[1]};
+  my ($path, $lang) = @_;
+  $path =~ s,/index\.html$,,;
+  my $template = $templates{$lang};
   my $htc = HTML::Template::Compiled->new(scalarref => \$template);
-  IO::File->new('>log/meta.yml')->close unless -f 'log/meta.yml';
-  flock my $metafh = IO::File->new('<log/meta.yml'), LOCK_SH;
-  my $meta = LoadFile 'log/meta.yml';
+  IO::File->new(">$path/meta.yml")->close unless -f "$path/meta.yml";
+  flock my $metafh = IO::File->new("<$path/meta.yml"), LOCK_SH;
+  my $meta = LoadFile "$path/meta.yml";
   my @log = sort { $b->{id} <=> $a->{id} } map {
-       my $meta = LoadFile "log/$_/meta.yml";
+       my $meta = LoadFile "$path/$_/meta.yml";
        +{ id => $_,
-          date => strftime ('%c' => localtime $meta->{date}),
+          date => (exists $meta->{date} ? strftime ('%c' => localtime $meta->{date}) : '?'),
           user => $meta->{user},
           result => $meta->{result},
           name => $meta->{name},
           problem => $meta->{problem},
           filename => $meta->{files}{prog}{name},
           (defined $meta->{private} ? (private => $meta->{private}) : ()),
-          size => sprintf ("%.2f KiB", (-s "log/$_/in/" . $meta->{files}{prog}{name}) / 1024),
+          size => sprintf ("%.2f KiB", (-s "$path/$_/in/" . $meta->{files}{prog}{name}) / 1024),
           result_text => $meta->{result_text}} } 1 .. $meta->{last};
   $htc->param(log => \@log);
   $htc->output
This page took 0.020846 seconds and 4 git commands to generate.