From 91350ee2083ad67afeeac13f4aa7bda12567a273 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Thu, 20 Apr 2017 17:21:11 +0200 Subject: [PATCH] Add basic HTML output system Needs to be served by a web server to work. "cd html && python -m SimpleHTTPServer" should do the trick. --- .gitignore | 1 + config.ini.sample | 2 +- html/ptg.html | 44 ++++++++++++++++++++++++++++++++++++++++++++ html/ptg.js | 10 ++++++++++ ptgbot/db.py | 6 +++--- 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 html/ptg.html create mode 100644 html/ptg.js diff --git a/.gitignore b/.gitignore index 20851cc..194defd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ build/* AUTHORS ChangeLog config.ini +html/ptg.json diff --git a/config.ini.sample b/config.ini.sample index ab10d4b..e1518bb 100644 --- a/config.ini.sample +++ b/config.ini.sample @@ -4,4 +4,4 @@ pass=PASSWORD server=irc.freenode.net port=6667 channels=foo,bar -db=/tmp/db.json +db=html/ptg.json diff --git a/html/ptg.html b/html/ptg.html new file mode 100644 index 0000000..68783c1 --- /dev/null +++ b/html/ptg.html @@ -0,0 +1,44 @@ + + + + + Currently at the PTG + + + + + +
+

OpenStack Project Teams Gathering

+

See what is being discussed currently at the PTG, and what's coming next.

+

+
+

Content on this page is being driven by room operators through the ptgbot on the #openstack-ptg IRC channel.

+
+ + + + + + + + + diff --git a/html/ptg.js b/html/ptg.js new file mode 100644 index 0000000..3aec321 --- /dev/null +++ b/html/ptg.js @@ -0,0 +1,10 @@ +// sets variable source to the animalTemplate id in index.html +var source = document.getElementById("PTGtemplate").innerHTML; + +// Handlebars compiles the above source into a template +var template = Handlebars.compile(source); + +$.getJSON("ptg.json", function(json) { + console.log(json); + document.getElementById("PTGsessions").innerHTML = template(json); +}); diff --git a/ptgbot/db.py b/ptgbot/db.py index 0eb52a4..124a004 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -29,9 +29,9 @@ class PTGDataBase(): self.data = {} def add(self, room, adverb, hour, msg): - if room not in self.data: - self.data[room] = {} - self.data[room][adverb] = {'msg': msg, 'expiry': hour} + if adverb not in self.data: + self.data[adverb] = {} + self.data[adverb][room] = {'msg': msg, 'expiry': hour} self.save() def expire(self, now):