Use Template Wrapper
authorHeiko Schlittermann <hs@schlittermann.de>
Thu, 24 Dec 2015 01:26:00 +0100
changeset 61 81fc1e7ce91b
parent 60 e3d6e4095a2c
child 62 e9add840d228
Use Template Wrapper
once.pl
templates.override/README
templates/README
templates/confirm.html
templates/footer.html
templates/header.tt
templates/inventory.html
templates/once.tt
--- a/once.pl	Thu Dec 24 00:49:28 2015 +0100
+++ b/once.pl	Thu Dec 24 01:26:00 2015 +0100
@@ -277,26 +277,8 @@
             push @{ $tt{files} }, \%file;
         }
 
-        $tt->process('inventory.html', \%tt) or die $tt->error();
-        return 0;
-
     }
-
-    print start_multipart_form, start_table,
-      Tr(td("Dateiname: "),
-        td(filefield(-name => "upload", -default => "nothing")),
-      ),
-      Tr(
-        td("Löschen in: "),
-        td(textfield(-name => "expires", -default => 0)),
-        td("Tagen (0: unmittelbar nach Download; -1: nur manuell)")
-      ),
-      Tr(td(), td(submit(-value => "Hochladen")),),
-      end_table,
-      end_multipart_form,
-      @footer,
-      end_html;
-
+    $tt->process('inventory.html', \%tt) or die $tt->error();
     return 0;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates.override/README	Thu Dec 24 01:26:00 2015 +0100
@@ -0,0 +1,2 @@
+Put templates here. The templates in this directory will override the
+templates from the ../templates directory.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/README	Thu Dec 24 01:26:00 2015 +0100
@@ -0,0 +1,2 @@
+Do not overwrite the files here. If you want to modify something,
+put your versions to ../template.override/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/confirm.html	Thu Dec 24 01:26:00 2015 +0100
@@ -0,0 +1,11 @@
+[% WRAPPER once.tt %]
+<h1>Download bestätigen</h1>
+<hr />
+Die Datei <em>[% file.name %]</em> ([% file.mimetype %]) 
+wird nach Abschluß des Downloads gelöscht werden
+
+<form method='post'>
+    <input type='hidden' name='confirmed' value='yes' />
+    <input type='submit' name='.submit' value='Download' />
+</form>
+[% END %]
--- a/templates/footer.html	Thu Dec 24 00:49:28 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-[%# to be included %]
-<hr />
-<div align=right>[% vcs.version %] | Scripting Heiko Schlittermann</div>
--- a/templates/header.tt	Thu Dec 24 00:49:28 2015 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-Content-Type: text/html; charset=utf-8
-
-[%# keep the empty line above! %]
-[% USE date %]
-[% PROCESS version.tt %]
-[%
-    product = 'ONCE'
-%]
--- a/templates/inventory.html	Thu Dec 24 00:49:28 2015 +0100
+++ b/templates/inventory.html	Thu Dec 24 01:26:00 2015 +0100
@@ -1,36 +1,45 @@
-[% PROCESS header.tt -%]
-<html>
-<head>
-<title>[% product %]</title>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<style type="text/css">
-    th { text-align: left; }
-</style>
-</head>
-<body>
+[% WRAPPER once.tt %]
 <h1>Ansicht: [% view %]</h1>
-<p>
-Der gültige Download-Link ist die Link-Adresse, die sich hinter
-dem Datei-Namen verbirgt. (Firefox: Rechte Maustaste,
-Link-Location).  Nach Ablauf des <a href="http://de.wikipedia.org/wiki/Mindesthaltbarkeitsdatum">MHD</a>
-wird die Datei automatisch gelöscht.
-</p>
+
+[% IF files %]
+    <p>
+    Der gültige Download-Link ist die Link-Adresse, die sich hinter
+    dem Datei-Namen verbirgt. (Firefox: Rechte Maustaste,
+    Link-Location).  Nach Ablauf des <a href="http://de.wikipedia.org/wiki/Mindesthaltbarkeitsdatum">MHD</a>
+    wird die Datei automatisch gelöscht.
+    </p>
+
+    <hr />
+
+    [%# Table for the files, our repository %]
 
-<hr />
+    <table>
+    <tr><th>Name</th><th>Größe</th><th>Hochgeladen</th><th>Löschung</hr><th>Aktion</th>
+    </tr>
+    [% FOREACH file IN files %]
+	<tr>
+	<td><a href="[% file.link %]">[% file.name %]</a></td>
+	<td align="right">[% file.size %]</td>
+	<td>[% date.format(file.uploaded, "%c") %]</td>
+	<td>[% file.removal.type %]</td>
+	<td><a href="[% file.removal.link %]">remove</a></td>
+	</td>
+    [% END # foreach %]
+    </table>
+[% END # files %]
 
+[%# Formular for upload %]
+<form enctype="multipart/form-data">
 <table>
-<tr><th>Name</th><th>Größe</th><th>Hochgeladen</th><th>Löschung</hr><th>Aktion</th>
+<tr><td>Dateiname: </td>
+    <td><input type="file" name="upload" value="nothing" /></td>
+</tr><tr>
+    <td>Löschen in: </td><td><input type="text" name="expires" value="0" /></td>
+    <td>Tagen (0: unmittelbar nach Download, -1: manuell)</td>
+</tr><tr>
+    <td /><td><input type="submit" name=".submit" value="Hochladen" /></td>
 </tr>
-[% FOREACH file IN files %]
-<tr>
-    <td><a href="[% file.link %]">[% file.name %]</a></td>
-    <td align="right">[% file.size %]</td>
-    <td>[% date.format(file.uploaded, "%c") %]</td>
-    <td>[% file.removal.type %]</td>
-    <td><a href="[% file.removal.link %]">remove</a></td>
-</td>
+</table>
+</form>
+
 [% END %]
-</table>
-[% INCLUDE footer.html %]
-</body>
-</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/once.tt	Thu Dec 24 01:26:00 2015 +0100
@@ -0,0 +1,22 @@
+Content-Type: text/html; charset=utf-8
+
+<html>
+[%-
+    USE date;
+    PROCESS version.tt;
+-%]
+<head>
+<title>Once</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<style type="text/css">
+    th { text-align: left; }
+</style>
+</head>
+<body>
+[% content %]
+<hr />
+<div align="right">
+    <font size=1>[% vcs.version %] | Scripting: Matthias Förste, Heiko Schlittermann</font>
+</div>
+</body>
+</html>