X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FPage%2FLog.pm;h=d276f558b0b38313440da4cc5e850fa8a30caec7;hb=fe78f0c128c35e68e65850b02057997bad6717fe;hp=b12d7795b25b53664f4116944347f5bd8646300a;hpb=42546e6c1b709dc4c8d8e7048becc14278b6cdf0;p=plack-app-gruntmaster.git diff --git a/lib/Gruntmaster/Page/Log.pm b/lib/Gruntmaster/Page/Log.pm index b12d779..d276f55 100644 --- a/lib/Gruntmaster/Page/Log.pm +++ b/lib/Gruntmaster/Page/Log.pm @@ -36,13 +36,15 @@ $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('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}), user => $meta->{user}, @@ -51,7 +53,7 @@ sub generate{ 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