diff 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
line wrap: on
line diff
--- a/bin/subserver	Fri Jun 14 05:29:55 2013 +0000
+++ b/bin/subserver	Fri Jun 14 05:30:45 2013 +0000
@@ -45,11 +45,9 @@
         
 class Static(PrettyErrorHandler, cyclone.web.StaticFileHandler):
     def get(self, path, *args, **kw):
-        if path == '':
-            return self.respondStaticJade("light9/subserver/index.jade")
-
-        if path == 'gui.js':
-            return self.responseStaticCoffee('light9/subserver/gui.coffee')
+        if path in ['', 'chases']:
+            return self.respondStaticJade("light9/subserver/%s.jade" %
+                                          (path or 'index'))
             
         oddlyPlaced = {
             "websocket.js":        "light9/rdfdb/web/websocket.js",
@@ -59,6 +57,11 @@
             self.write(open(oddlyPlaced[path]).read())
             return
 
+        if path.endswith(".js") and path not in ['knockout-2.2.1.js']:
+            return self.responseStaticCoffee(
+                'light9/subserver/%s' %
+                path.replace(".js", ".coffee")) # potential security hole
+
         cyclone.web.StaticFileHandler.get(self, path, *args, **kw)
 
     def respondStaticJade(self, src):
@@ -121,6 +124,15 @@
         
         d.clear()
         d.update({'subs': subs})
+
+        d['chases'] = []
+        for chase in sorted(graph.subjects(RDF.type, L9['Chase'])):
+            fakeLabel = chase.rsplit('/', 1)[-1]
+            d['chases'].append({
+                'uri': chase,
+                'label': fakeLabel,
+            })
+        
         sendToLiveClients(d=d)
     def onNewClient():
         sendToLiveClients(d=d)