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
This commit is contained in:
Thierry Carrez 2018-12-21 15:29:36 +01:00
parent 052b575a4f
commit cb0e38cd12
4 changed files with 43 additions and 2 deletions

View File

@ -183,7 +183,7 @@ In one terminal, run the bot::
Join that channel and give commands to 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 #swift now discussing ring placement
(note, the bot currently only takes commands from Freenode identified users) (note, the bot currently only takes commands from Freenode identified users)

31
html/index.html Normal file
View File

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Quick PTG Resources</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="bootstrap-3.3.7.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h2>Quick PTG Resources</h2>
<p>Follow links to useful sites for the OpenStack Project Teams Gathering.</p>
<script id="LinksTemplate" type="text/x-handlebars-template">
{{#each links as |url title|}}
<li><a href="{{ url }}">{{ title }}</a></li>
{{/each}}
</script>
<ul>
<li><a href="https://www.openstack.org/ptg/">event details, overall schedule, travel info, FAQs</a></li>
<li><a href="ptg.html">current/next topics and room schedule</a></li>
<li><a href="https://git.openstack.org/cgit/openstack/ptgbot/tree/README.rst">instructions for interacting with the IRC bot</a></li>
<div id="ExtraLinks"></div>
</ul>
</div>
<script src="jquery-1.9.1.min.js"></script>
<script src="handlebars-4.0.6.js"></script>
<script src="index.js"></script>
</body>
</html>

9
html/index.js Normal file
View File

@ -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);
});

View File

@ -24,7 +24,8 @@ class PTGDataBase():
BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {}, BASE = {'tracks': [], 'slots': {}, 'now': {}, 'next': {}, 'colors': {},
'location': {}, 'schedule': {}, 'voice': 0, 'location': {}, 'schedule': {}, 'voice': 0,
'motd': {'message': '', 'level': 'info'}} 'motd': {'message': '', 'level': 'info'},
'links': {}}
def __init__(self, config): def __init__(self, config):
self.filename = config['db_filename'] self.filename = config['db_filename']