# HG changeset patch # User drewp@bigasterisk.com # Date 2012-09-30 07:10:51 # Node ID 6f984ce851e2e7216895ff2e0808459c80e75a83 # Parent 5ff9d9e264bb8f5021c74719b9bf578fb9232fa4 refactor rdfdb web ui Ignore-this: e94d7c4e2379ebae4d87d5cfa6f627c2 diff --git a/light9/rdfdb/web/graphView.xhtml b/light9/rdfdb/web/graphView.xhtml new file mode 100644 --- /dev/null +++ b/light9/rdfdb/web/graphView.xhtml @@ -0,0 +1,46 @@ + + + + + graphview + + + + + + +

status: starting...

+ +
+ Messages +
+
+ +

URI substring:

+ + + + + + + + + +
subject predicate object context
+ + + + + + + \ No newline at end of file diff --git a/light9/rdfdb.xhtml b/light9/rdfdb/web/index.xhtml rename from light9/rdfdb.xhtml rename to light9/rdfdb/web/index.xhtml --- a/light9/rdfdb.xhtml +++ b/light9/rdfdb/web/index.xhtml @@ -4,42 +4,7 @@ rdfdb - +

rdfdb

@@ -57,7 +22,8 @@ color: white;
- + + diff --git a/lib/jquery-1.7.2.min.js b/light9/rdfdb/web/lib/jquery-1.7.2.min.js rename from lib/jquery-1.7.2.min.js rename to light9/rdfdb/web/lib/jquery-1.7.2.min.js diff --git a/light9/rdfdb/web/style.css b/light9/rdfdb/web/style.css new file mode 100644 --- /dev/null +++ b/light9/rdfdb/web/style.css @@ -0,0 +1,32 @@ +body { + background: black; + color: white; +} +#patches { /* wants flex box */ + max-height: 27em; + overflow-y: scroll; +} +.patch { + border: 1px solid gray; + padding: 2px; + margin: 4px; +} +.patch > div { + font-family: monospace; + font-size: 90%; + white-space: pre-wrap; +} +.patch .adds { + color: #3AEA38; +} +.patch .deletes { + color: #FF2828; +} +#out { + white-space: pre-wrap; +} +.patch fieldset { + color: gray; + font-family: arial; + font-size: 75%; +} diff --git a/light9/rdfdb/web/syncedgraph.js b/light9/rdfdb/web/syncedgraph.js new file mode 100644 --- /dev/null +++ b/light9/rdfdb/web/syncedgraph.js @@ -0,0 +1,27 @@ +function SyncedGraph(label) { + /* + like python SyncedGraph but talks over a websocket to + rdfdb. This one has an API more conducive to reading and + querying. + */ + var self = this; + + + + self.patch = function (p) { + throw; + } + self.nodesWithSubstring = function (subString) { + + } + self.quads = function (s, p, o, c) { + // any args can be null for wildcard + } + + + function onMessage(d) { + $('#out').append($('
').text(JSON.stringify(d))); + } + + reconnectingWebSocket("ws://localhost:8051/liveSyncedGraph", onMessage); +} diff --git a/light9/rdfdb/web/websocket.js b/light9/rdfdb/web/websocket.js new file mode 100644 --- /dev/null +++ b/light9/rdfdb/web/websocket.js @@ -0,0 +1,20 @@ +function reconnectingWebSocket(url, onMessage) { + var pong = 0; + function connect() { + var ws = new WebSocket(url); + + ws.onopen = function() { $("#status").text("connected"); }; + ws.onerror = function(e) { $("#status").text("error: "+e); }; + ws.onclose = function() { + pong = 1 - pong; + $("#status").text("disconnected (retrying "+(pong ? "😼":"😺")+")"); + // this should be under a requestAnimationFrame to + // save resources + setTimeout(connect, 2000); + }; + ws.onmessage = function (evt) { + onMessage(JSON.parse(evt.data)); + }; + } + connect(); +} \ No newline at end of file