aboutsummaryrefslogtreecommitdiffstats
path: root/generate_html.py
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2012-09-21 17:57:53 +0200
committerMatěj Cepl <mcepl@redhat.com>2012-09-21 18:01:08 +0200
commit94a7b1706026911fb868a0e568060d6ea5e4d14f (patch)
treeb869e777d28ddadb8c9771d8fd16b44e26a7cc74 /generate_html.py
parent7db43f05a951c49c67f292a830a5ef3bafb2a7b6 (diff)
downloadhesla-94a7b1706026911fb868a0e568060d6ea5e4d14f.tar.gz
The proper event is pageshow, not load (because of Firefox caching)
Also, properly use app caching, and switch to lxml (generated HTML is ugly) See https://developer.mozilla.org/en-US/using_firefox_1.5_caching for explanation.
Diffstat (limited to 'generate_html.py')
-rw-r--r--generate_html.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/generate_html.py b/generate_html.py
index 3859509..ab4e436 100644
--- a/generate_html.py
+++ b/generate_html.py
@@ -1,7 +1,7 @@
#!/usr/bin/python
import re
import codecs
-from xml.etree import ElementTree as et
+import lxml.etree as et
import sys
import logging
#logging.basicConfig(level=logging.DEBUG)
@@ -66,7 +66,9 @@ def parse_one(elem):
def parse_file(filename):
tree = et.parse(filename).getroot()
- doc = et.Element("html")
+ doc = et.Element("html", attrib={
+ "manifest": "hesla.appcache"
+ })
head = et.SubElement(doc, "head")
et.SubElement(head, "meta", attrib={"charset": "utf-8"})
et.SubElement(head, "meta", attrib={
@@ -97,7 +99,8 @@ def parse_file(filename):
for los in tree.getiterator("LOSUNG"):
body.append(parse_one(los))
- return "<!DOCTYPE html>\n" + et.tostring(doc, encoding="utf-8")
+ return et.tostring(doc, encoding="utf-8", pretty_print=True,
+ doctype="<!DOCTYPE html>")
if __name__ == "__main__":
print(parse_file(sys.argv[1]))