Mercurial > code > home > repos > light9
changeset 1928:1cb63991eb19
asco use cyclone templating instead of genshi
Ignore-this: 1f66e01d6e3a11c5abad8f594027f514
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 02 Jun 2019 06:43:07 +0000 |
parents | 4718ca6f812e |
children | b4beb35bc454 |
files | light9/ascoltami/index.html light9/ascoltami/webapp.py |
diffstat | 2 files changed, 18 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/ascoltami/index.html Sun Jun 02 00:07:42 2019 +0000 +++ b/light9/ascoltami/index.html Sun Jun 02 06:43:07 2019 +0000 @@ -4,7 +4,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/"> <head> - <title>ascoltami on ${host}</title> + <title>ascoltami on {{host}}</title> <script type="text/javascript" src="/lib/jquery/dist/jquery.min.js"></script> <script type="text/javascript" src="/lib/jquery-ui/jquery-ui.min.js"></script> <link rel="Stylesheet" type="text/css" href="/lib/jquery-ui/themes/smoothness/jquery-ui.min.css"/> @@ -15,7 +15,7 @@ </style> </head> <body> - <h1>ascoltami on ${host}</h1> + <h1>ascoltami on {{host}}</h1> <div class="songs"/> <div class="dimStalled"> @@ -68,10 +68,7 @@ } $("#updateReq").text(updateFreq); - var times = { // need to get these from server - intro: 4, - post: 4 - }; + var times = {% raw times %}; var currentDuration = 0; var currentHighlightedSong = "";
--- a/light9/ascoltami/webapp.py Sun Jun 02 00:07:42 2019 +0000 +++ b/light9/ascoltami/webapp.py Sun Jun 02 06:43:07 2019 +0000 @@ -1,15 +1,17 @@ -import json, socket, subprocess, cyclone.web -from twisted.python.util import sibpath +import json, socket, subprocess, os + +from cyclone import template +from rdflib import URIRef +import cyclone.web + +from cycloneerr import PrettyErrorHandler from light9.namespaces import L9 from light9.showconfig import getSongsFromShow, songOnDisk -from rdflib import URIRef -from web.contrib.template import render_genshi -render = render_genshi([sibpath(__file__, ".")], auto_reload=True) - -from cycloneerr import PrettyErrorHandler _songUris = {} # locationUri : song +loader = template.Loader(os.path.dirname(__file__)) + def songLocation(graph, songUri): loc = URIRef("file://%s" % songOnDisk(songUri)) @@ -25,9 +27,12 @@ def get(self): self.set_header("Content-Type", "application/xhtml+xml") - # todo: use a template; embed the show name and the intro/post - # times into the page - self.write(render.index(host=socket.gethostname())) + self.write( + loader.load('index.html').generate(host=socket.gethostname(), + times=json.dumps({ + 'intro': 4, + 'post': 4 + }))) def playerSongUri(graph, player):