Mercurial > code > home > repos > light9
changeset 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 | 59f1898cec60 |
children | 8152b1dd8a2f |
files | bin/subserver light9/subserver/chases.coffee light9/subserver/chases.jade light9/subserver/index.jade light9/subserver/style.css |
diffstat | 5 files changed, 97 insertions(+), 16 deletions(-) [+] |
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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/light9/subserver/chases.coffee Fri Jun 14 05:30:45 2013 +0000 @@ -0,0 +1,29 @@ +class Model + constructor: -> + @chases = ko.observable([]) + + subtermLink: (label, expr) => + "http://chase?"+$.param({ + subtermName: label + subtermExpr: expr + curve: label + }) + subtermExprs: (chase) => + [ + 'LABEL(t) * chase(t, names=LABEL, ontime=0.5, offset=0.2)'.replace(/LABEL/g, chase.label) + ] + + +model = new Model() + +# this sort of works to stop clicks in <input> from following the +# submaster hyperlink, but it may make certain clicks act wrong +$('a').live('click', (ev) -> + return false if ev.target.tagName == 'INPUT' +) + +reconnectingWebSocket "ws://localhost:8052/live", (msg) -> + model.chases(msg.chases) if msg.chases? + + +ko.applyBindings(model) \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/light9/subserver/chases.jade Fri Jun 14 05:30:45 2013 +0000 @@ -0,0 +1,22 @@ +doctype html +html + head + title subserver + link(rel='stylesheet', href='style.css') + body + h1 Chases + + div(data-bind="foreach: chases") + div.resource.chase + | Chase + a(data-bind="attr: {href: uri}, text: label") + h2 Subterms + ul(data-bind="foreach: $parent.subtermExprs($data)") + li: a.resource(data-bind="attr: {href: $root.subtermLink($parent.label, $data)}, text: $data") + + #status + + script(src="jquery-1.7.2.min.js") + script(src="knockout-2.2.1.js") + script(src="websocket.js") + script(src="chases.js") \ No newline at end of file
--- a/light9/subserver/index.jade Fri Jun 14 05:29:55 2013 +0000 +++ b/light9/subserver/index.jade Fri Jun 14 05:30:45 2013 +0000 @@ -12,8 +12,7 @@ div(data-bind="foreach: subs") // ko if: $parent.showLocal() || !isLocal - a(class='sub', data-bind="css: {local: isLocal}, - attr: {href: uri}") + a.resource.sub(data-bind="css: {local: isLocal}, attr: {href: uri}") div(data-bind="if: isLocal") (local) div | Label
--- a/light9/subserver/style.css Fri Jun 14 05:29:55 2013 +0000 +++ b/light9/subserver/style.css Fri Jun 14 05:30:45 2013 +0000 @@ -3,18 +3,34 @@ background: rgb(0, 0, 0); color: rgb(163, 163, 163); } - -a.sub { +h2 { + margin: 0; + padding: 0; + font-size: 100%; +} +ul { + margin: 0; +} +.vari { + color: white; +} +a.resource { color: inherit; text-decoration: none; } - -.sub { + +.resource { border: 1px solid gray; - border-radius: 15px; + border-radius: 5px; padding: 5px; margin: 5px; background: rgb(66, 66, 66); + display: block; +} +.resource a { + color: rgb(150, 150, 255); +} +.sub { display: inline-block; vertical-align: top; } @@ -34,7 +50,10 @@ padding: 3px; } #status { -position: fixed; -bottom: 10px; -right: 10px; - } \ No newline at end of file + position: fixed; + bottom: 10px; + right: 10px; +} +.chase { + background: rgb(75, 57, 72); +} \ No newline at end of file