diff options
-rw-r--r-- | generate_html.py | 9 | ||||
-rw-r--r-- | hesla.appcache | 2 | ||||
-rw-r--r-- | hesla.js | 21 | ||||
-rw-r--r-- | hesla.webapp | 2 | ||||
-rw-r--r-- | test_generate_html.py | 3 |
5 files changed, 19 insertions, 18 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])) diff --git a/hesla.appcache b/hesla.appcache index c173743..875a701 100644 --- a/hesla.appcache +++ b/hesla.appcache @@ -1,5 +1,5 @@ CACHE MANIFEST -# v5 - 2012-09-21 +# v12 - 2012-09-21 hesla.js icon-128.png index.html @@ -1,6 +1,6 @@ -if ( !Date.prototype.toISODateString ) { +if (!Date.prototype.toISODateString) { - ( function() { + (function() { function pad(number) { var r = String(number); @@ -11,18 +11,17 @@ if ( !Date.prototype.toISODateString ) { } Date.prototype.toISODateString = function() { - return this.getFullYear() - + '-' + pad( this.getMonth() + 1 ) - + '-' + pad( this.getDate() ) + return this.getFullYear() + + '-' + pad( this.getMonth() + 1 ) + + '-' + pad( this.getDate() ); }; - }() ); + }()); } var today_id = new Date().toISODateString(); -console.log("today_id = " + today_id); -document.addEventListener("DOMContentLoaded", function() { - var today_losungen = document.getElementById(today_id); - today_losungen.style.display = "block"; -}); +window.addEventListener("pageshow", function() { + var today_losungen = document.getElementById(today_id); + today_losungen.style.display = "block"; +}, false); diff --git a/hesla.webapp b/hesla.webapp index 7461089..ea5d47f 100644 --- a/hesla.webapp +++ b/hesla.webapp @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "0.2.0", "name": "Hesla", "description": "Display today's Hesla (Losungen, Watchwords) from Bilble.", "icons": { diff --git a/test_generate_html.py b/test_generate_html.py index 05e956e..3507b20 100644 --- a/test_generate_html.py +++ b/test_generate_html.py @@ -29,8 +29,7 @@ class TestProcessLosungen(unittest.TestCase): proc = subprocess.Popen(["tidy", "-e", "-f", "/dev/null"], stdin=subprocess.PIPE, bufsize=-1, close_fds=True) proc.communicate(self.los_elements) - # Generated HTML is missing DOCTYPE, so we get some warnings - self.assertLessEqual(proc.returncode, 1) + self.assertEqual(proc.returncode, 0) def test_attributes_on_articles(self): # Every article has to have id attribute |