changeset 923:8b95d2865643

subserver shows real submasters, stays live. pretty sweet Ignore-this: 1eefab7d67bb6d8e386003a990e6f5c5
author drewp@bigasterisk.com
date Tue, 11 Jun 2013 00:02:35 +0000
parents 4def29403ac7
children dcab422615ca
files bin/subserver light9/subserver/gui.coffee light9/subserver/index.jade light9/subserver/style.css
diffstat 4 files changed, 67 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bin/subserver	Mon Jun 10 23:28:46 2013 +0000
+++ b/bin/subserver	Tue Jun 11 00:02:35 2013 +0000
@@ -9,6 +9,8 @@
 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 @@
         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 @@
 
     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)
--- a/light9/subserver/gui.coffee	Mon Jun 10 23:28:46 2013 +0000
+++ b/light9/subserver/gui.coffee	Tue Jun 11 00:02:35 2013 +0000
@@ -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 <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.subs(msg.subs) if msg.subs?
 
--- a/light9/subserver/index.jade	Mon Jun 10 23:28:46 2013 +0000
+++ b/light9/subserver/index.jade	Tue Jun 11 00:02:35 2013 +0000
@@ -4,10 +4,23 @@
     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")
--- a/light9/subserver/style.css	Mon Jun 10 23:28:46 2013 +0000
+++ b/light9/subserver/style.css	Tue Jun 11 00:02:35 2013 +0000
@@ -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