From cb0e38cd1209e5be201637953d56b48fdb1383cf Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Fri, 21 Dec 2018 15:29:36 +0100 Subject: [PATCH] Generate PTGbot index page dynamically Current system (where the index page is specified in the puppet-ptgbot module) requires that (some) links on the page are updated in puppet-ptgbot at the start of every event. That page should be dynamically generated from JSON data. That way the list of links can be provided in the JSON database and dynamically imported and updated using the ~fetchdb command. Change-Id: I7d82b38cba495e5837ba54fbe7a9b7e9c8e14259 --- README.rst | 2 +- html/index.html | 31 +++++++++++++++++++++++++++++++ html/index.js | 9 +++++++++ ptgbot/db.py | 3 ++- 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 html/index.html create mode 100644 html/index.js diff --git a/README.rst b/README.rst index 6e7d88b..b1a7392 100644 --- a/README.rst +++ b/README.rst @@ -183,7 +183,7 @@ In one terminal, run the bot:: Join that channel and give commands to the bot:: - ~fetchdb http://paste.openstack.org/raw/736003/ + ~fetchdb http://paste.openstack.org/raw/737820/ #swift now discussing ring placement (note, the bot currently only takes commands from Freenode identified users) diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..ea82154 --- /dev/null +++ b/html/index.html @@ -0,0 +1,31 @@ + + + + + Quick PTG Resources + + + + + +
+

Quick PTG Resources

+

Follow links to useful sites for the OpenStack Project Teams Gathering.

+ + +
+ + + + + + diff --git a/html/index.js b/html/index.js new file mode 100644 index 0000000..5277efb --- /dev/null +++ b/html/index.js @@ -0,0 +1,9 @@ +// sets variable source to the animalTemplate id in index.html +var source = document.getElementById("LinksTemplate").innerHTML; + +// Handlebars compiles the above source into a template +var template = Handlebars.compile(source); + +$.getJSON("ptg.json", function(json) { + document.getElementById("ExtraLinks").innerHTML = template(json); +}); diff --git a/ptgbot/db.py b/ptgbot/db.py index 338b176..46a62ab 100644 --- a/ptgbot/db.py +++ b/ptgbot/db.py @@ -24,7 +24,8 @@ class PTGDataBase(): BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {}, 'location': {}, 'schedule': {}, 'voice': 0, - 'motd': {'message': '', 'level': 'info'}} + 'motd': {'message': '', 'level': 'info'}, + 'links': {}} def __init__(self, config): self.filename = config['db_filename']