# HG changeset patch # User Heiko Schlittermann # Date 1450914568 -3600 # Node ID e3d6e4095a2ca17d9eab95be5652d9e2ddf30c14 # Parent ade26fe6ecbb35ccb43087de53f8afd34108b053 Do header processing in template diff -r ade26fe6ecbb -r e3d6e4095a2c once.pl --- a/once.pl Thu Dec 24 00:31:53 2015 +0100 +++ b/once.pl Thu Dec 24 00:49:28 2015 +0100 @@ -55,6 +55,11 @@ my $rxVIEW = qr/[a-z\d]{6}-[a-z\d]+/i; # date-userhash my $rxFILE = qr/[a-z\d]{6}-[a-z\d]+-./i; # date-filehash-deletemode +my $TT_CONFIG = { + INCLUDE_PATH => [ map { catfile($RealBin, $_) } + qw(var templates.override templates) ] + }; + umask 077; # The working (var) directory gets passed to us via ONCE_VAR environment @@ -225,15 +230,9 @@ } # create the view - print header(-charset => "UTF-8"); - my %tt = (view => $view); - my $tt = Template->new( - { - INCLUDE_PATH => => - [map { catfile($RealBin, $_) } 'var', 'templates.override', 'templates'] - } - ) or die $Template::ERROR; + my $tt = Template->new($TT_CONFIG) + or die $Template::ERROR; # List the current content if (my @files = map { deslash $_ } glob "$user_dir/*-*/*") { @@ -323,22 +322,14 @@ sub confirm { my ($base, $mimetype) = @_; - print header(-charset => "UTF-8"), - start_html(-title => "once"), - h1 "Download bestätigen"; - print hr, p <<__; - Die Datei `$base' ($mimetype), die Sie herunterladen möchten, wird nach Abschluß des - Downloads gelöscht. Virenscanner oder andere Programme, die den Link - möglicherweise automatisiert aufrufen, könnten eine versehentliche - Löschung der Datei auslösen. Bestätigen Sie deshalb bitte den Download - per Knopfdruck. -__ - print start_form, - hidden('confirmed', 'yes'), - submit(-value => 'Bestätigung'), - end_form, - @footer, - end_html; + my %tt = ( + file => { name => $base, + mimetype => $mimetype + } + ); + my $tt = Template->new($TT_CONFIG) + or die $Template::ERROR; + $tt->process('confirm.html' => \%tt); exit 0; } diff -r ade26fe6ecbb -r e3d6e4095a2c templates/header.tt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/templates/header.tt Thu Dec 24 00:49:28 2015 +0100 @@ -0,0 +1,8 @@ +Content-Type: text/html; charset=utf-8 + +[%# keep the empty line above! %] +[% USE date %] +[% PROCESS version.tt %] +[% + product = 'ONCE' +%] diff -r ade26fe6ecbb -r e3d6e4095a2c templates/inventory.html --- a/templates/inventory.html Thu Dec 24 00:31:53 2015 +0100 +++ b/templates/inventory.html Thu Dec 24 00:49:28 2015 +0100 @@ -1,6 +1,5 @@ +[% PROCESS header.tt -%] - -[% PROCESS once.tt -%] [% product %] diff -r ade26fe6ecbb -r e3d6e4095a2c templates/once.tt --- a/templates/once.tt Thu Dec 24 00:31:53 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -[% USE date %] -[% PROCESS version.tt %] -[% - product = 'ONCE' -%]