Add basic HTML output system

Needs to be served by a web server to work.
"cd html && python -m SimpleHTTPServer" should do the trick.
This commit is contained in:
Thierry Carrez 2017-04-20 17:21:11 +02:00
parent b486192b23
commit 91350ee208
5 changed files with 59 additions and 4 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ build/*
AUTHORS
ChangeLog
config.ini
html/ptg.json

View File

@ -4,4 +4,4 @@ pass=PASSWORD
server=irc.freenode.net
port=6667
channels=foo,bar
db=/tmp/db.json
db=html/ptg.json

44
html/ptg.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Currently at the PTG</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h2>OpenStack Project Teams Gathering</h2>
<p>See what is being discussed currently at the PTG, and what's coming next.<p>
<div id="PTGsessions">
</div>
<p class="text-muted">Content on this page is being driven by room operators through the ptgbot on the #openstack-ptg IRC channel.</p>
</div>
<script id="PTGtemplate" type="text/x-handlebars-template">
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Currently playing</h3></div>
<ul class="list-group">
{{#each until}}
<li class="list-group-item"><span class="label label-primary">{{@key}}</span> {{this.msg}}</li>
{{/each}}
</ul>
</div>
<div class="panel panel-default">
<div class="panel-heading"><h3 class="panel-title">Next discussions</h3></div>
<ul class="list-group">
{{#each at}}
<li class="list-group-item"><span class="label label-primary">{{@key}}</span> {{this.msg}}</li>
{{/each}}
</ul>
</div>
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.6/handlebars.js"></script>
<script src="ptg.js"></script>
</body>
</html>

10
html/ptg.js Normal file
View File

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

View File

@ -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):