From 616fb9074509a2c7545784d1811ef8668cebe0c4 Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 27 Jan 2012 22:01:00 +0530 Subject: [PATCH] added print generator --- print/css/print.css | 28 ++++++++++++++++++++++++++++ print/make_html.py | 16 ++++++++++++++++ print/template.html | 29 +++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 print/css/print.css create mode 100644 print/make_html.py create mode 100644 print/template.html diff --git a/print/css/print.css b/print/css/print.css new file mode 100644 index 0000000..c4e4978 --- /dev/null +++ b/print/css/print.css @@ -0,0 +1,28 @@ +body { + font-family: "Courier New"; + font-size: 14px; +} + +.sub { + margin-top: 6px; + margin-bottom: 6px; +} + +.inpoint { + font-style: italic; + font-size: 12px; +} + +.title { + font-size: 18px; + margin: 0; + margin-bottom: 4px; +} + +.datetime { + font-weight: bold; +} + +.fileWrapper { + margin-bottom: 16px; +} diff --git a/print/make_html.py b/print/make_html.py new file mode 100644 index 0000000..8c9d8c0 --- /dev/null +++ b/print/make_html.py @@ -0,0 +1,16 @@ +from jinja2 import Template +from os.path import join +import json +import codecs + +def do(): + data = json.load(open("chronoPrint.json")) + i = 1 + for d in data: + d['serial'] = i + i += 1 + t = Template(open("template.html").read()) + s = t.render({'files': data}) + out = codecs.open("out.html", "w", encoding="utf-8") + out.write(s) + out.close() diff --git a/print/template.html b/print/template.html new file mode 100644 index 0000000..43a1db3 --- /dev/null +++ b/print/template.html @@ -0,0 +1,29 @@ + + + + + + {% for f in files %} +
+

{{ f.serial }}. {{ f.title }}

+
+ {{ f.date }} + {{ f.time }} +
+
+ {% for s in f.subs %} +
+
{{ s.in }}
+
{{ s.text }}
+
+ {% endfor %} + +
+
+ + {% endfor %} + + + + +