# HG changeset patch # User drewp@bigasterisk.com # Date 2013-06-11 00:02:35 # Node ID 8b95d286564329afbdbe0f9fc690fd6fc2b52b58 # Parent 4def29403ac78fc58709f7d6ba9e9c1716368e60 subserver shows real submasters, stays live. pretty sweet Ignore-this: 1eefab7d67bb6d8e386003a990e6f5c5 diff --git a/bin/subserver b/bin/subserver --- a/bin/subserver +++ b/bin/subserver @@ -9,6 +9,8 @@ import twisted.internet.error import sys, optparse, logging, json, os, subprocess import cyclone.web, cyclone.httpclient, cyclone.websocket from light9.rdfdb.syncedgraph import SyncedGraph +from rdflib import RDF +from light9.namespaces import L9 import pyjade.utils try: @@ -41,7 +43,6 @@ class Live(cyclone.websocket.WebSocketHa self.sendMessage(message) class Static(PrettyErrorHandler, cyclone.web.StaticFileHandler): - # .xhtml pages can be get() without .xhtml on them def get(self, path, *args, **kw): if path == '': return self.respondStaticJade("light9/subserver/index.jade") @@ -79,8 +80,17 @@ if __name__ == "__main__": d = {} def updateSubs(): + + subs = [] + for sub in graph.subjects(RDF.type, L9['Submaster']): + rec = {'uri' : sub} + rec['isLocal'] = graph.contains((sub, RDF.type, + L9['LocalSubmaster'])) + rec['label'] = graph.label(sub) + subs.append(rec) + d.clear() - d.update({'subs':['a', 'b']}) + d.update({'subs': subs}) sendToLiveClients(d=d) def onNewClient(): sendToLiveClients(d=d) diff --git a/light9/subserver/gui.coffee b/light9/subserver/gui.coffee --- a/light9/subserver/gui.coffee +++ b/light9/subserver/gui.coffee @@ -1,10 +1,16 @@ - class Model constructor: -> @subs = ko.observable([]) + @showLocal = ko.observable(false) model = new Model() +# this sort of works to stop clicks in 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.subs(msg.subs) if msg.subs? diff --git a/light9/subserver/index.jade b/light9/subserver/index.jade --- a/light9/subserver/index.jade +++ b/light9/subserver/index.jade @@ -4,10 +4,23 @@ html title subserver link(rel='stylesheet', href='style.css') body - h1 subserver + h1 Submasters + div + input(type='checkbox', data-bind='checked: showLocal', id='showLocal') + label(for='showLocal') show local + div(data-bind="foreach: subs") - div(data-bind="text: JSON.stringify($data)") + // ko if: $parent.showLocal() || !isLocal + a(class='sub', data-bind="css: {local: isLocal}, + attr: {href: uri}") + div(data-bind="if: isLocal") (local) + div + | Label + input(type="text", data-bind="value: label") + div + img() + // /ko script(src="jquery-1.7.2.min.js") script(src="knockout-2.2.1.js") diff --git a/light9/subserver/style.css b/light9/subserver/style.css --- a/light9/subserver/style.css +++ b/light9/subserver/style.css @@ -1,3 +1,35 @@ body { - font-family: sans; + font-family: sans; + background: rgb(0, 0, 0); + color: rgb(163, 163, 163); +} + +a.sub { + color: inherit; + text-decoration: none; +} + +.sub { + border: 1px solid gray; + border-radius: 15px; + padding: 5px; + margin: 5px; + background: rgb(66, 66, 66); + display: inline-block; + vertical-align: top; +} +.sub.local { + background: rgb(44, 44, 44); +} +.sub img { + width: 180px; + height: 90px; + margin: 6px; + background: -webkit-gradient(linear,right top,left bottom,color-stop(0,rgb(121, 120, 120)),color-stop(1,rgb(54, 54, 54))); +} + +input[type=text] { + border: 1px inset rgb(177, 177, 177); + background: rgb(230, 230, 230); + padding: 3px; } \ No newline at end of file