comparison bin/subserver @ 953:891f2d75c686

subserver now also serves some premade subterms with the defined chases Ignore-this: dbf877dc234795252e5c913d7489aa11
author drewp@bigasterisk.com
date Fri, 14 Jun 2013 05:30:45 +0000
parents dd896321faee
children cfc748f4ad2e
comparison
equal deleted inserted replaced
952:59f1898cec60 953:891f2d75c686
43 log.info("got message %s" % message) 43 log.info("got message %s" % message)
44 self.sendMessage(message) 44 self.sendMessage(message)
45 45
46 class Static(PrettyErrorHandler, cyclone.web.StaticFileHandler): 46 class Static(PrettyErrorHandler, cyclone.web.StaticFileHandler):
47 def get(self, path, *args, **kw): 47 def get(self, path, *args, **kw):
48 if path == '': 48 if path in ['', 'chases']:
49 return self.respondStaticJade("light9/subserver/index.jade") 49 return self.respondStaticJade("light9/subserver/%s.jade" %
50 50 (path or 'index'))
51 if path == 'gui.js':
52 return self.responseStaticCoffee('light9/subserver/gui.coffee')
53 51
54 oddlyPlaced = { 52 oddlyPlaced = {
55 "websocket.js": "light9/rdfdb/web/websocket.js", 53 "websocket.js": "light9/rdfdb/web/websocket.js",
56 "jquery-1.7.2.min.js": "light9/rdfdb/web/lib/jquery-1.7.2.min.js", 54 "jquery-1.7.2.min.js": "light9/rdfdb/web/lib/jquery-1.7.2.min.js",
57 } 55 }
58 if path in oddlyPlaced: 56 if path in oddlyPlaced:
59 self.write(open(oddlyPlaced[path]).read()) 57 self.write(open(oddlyPlaced[path]).read())
60 return 58 return
59
60 if path.endswith(".js") and path not in ['knockout-2.2.1.js']:
61 return self.responseStaticCoffee(
62 'light9/subserver/%s' %
63 path.replace(".js", ".coffee")) # potential security hole
61 64
62 cyclone.web.StaticFileHandler.get(self, path, *args, **kw) 65 cyclone.web.StaticFileHandler.get(self, path, *args, **kw)
63 66
64 def respondStaticJade(self, src): 67 def respondStaticJade(self, src):
65 html = pyjade.utils.process(open(src).read()) 68 html = pyjade.utils.process(open(src).read())
119 rec['img'] = newestImage(sub) 122 rec['img'] = newestImage(sub)
120 subs.append(rec) 123 subs.append(rec)
121 124
122 d.clear() 125 d.clear()
123 d.update({'subs': subs}) 126 d.update({'subs': subs})
127
128 d['chases'] = []
129 for chase in sorted(graph.subjects(RDF.type, L9['Chase'])):
130 fakeLabel = chase.rsplit('/', 1)[-1]
131 d['chases'].append({
132 'uri': chase,
133 'label': fakeLabel,
134 })
135
124 sendToLiveClients(d=d) 136 sendToLiveClients(d=d)
125 def onNewClient(): 137 def onNewClient():
126 sendToLiveClients(d=d) 138 sendToLiveClients(d=d)
127 139
128 graph.addHandler(updateSubs) 140 graph.addHandler(updateSubs)