Skip to content

Commit

Permalink
adding remote.clj
Browse files Browse the repository at this point in the history
  • Loading branch information
rosejn committed Jul 13, 2011
1 parent 56daa78 commit 8eb8272
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
3 changes: 3 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* add the ability for construct to take a seq of maps for a node entry, and then
when pointed to in edges have an edge created per node.

* start using transactions

* Add a (graph-event-channel [g]) which will publish an event any time the graph
Expand Down
5 changes: 4 additions & 1 deletion src/plasma/construct.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
; * map (a new node's properties)
; * keyword (a new node's :label property)
; * path expression (select nodes to link with other nodes)
; * a seq of node UUIDs or node maps

(defn- make-nodes
"Convert a node-spec to a node-id map."
Expand All @@ -48,7 +49,9 @@
[sym (cond
(uuid? props) props
(q/query? props) (map :id (q/query props))
(map? props) (make-node props))])
(map? props) (make-node props)
(or (seq? props)
(vector? props)) (map make-node props))])
(:nodes spec))
node-map (into {} id-mapped)
node-map (assoc node-map 'ROOT-ID ROOT-ID)]
Expand Down
19 changes: 19 additions & 0 deletions src/plasma/remote.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
(ns plasma.remote)

(defn- url-map [url]
(let [match (re-find #"(.*)://([0-9a-zA-Z-_.]*)(:([0-9]+))?(.*)" url)
[_ proto host _ port path] match]
{:proto proto
:host host
:port (if port
(Integer. port)
nil)
:path path}))

(defmulti remote-query-fn
"Given a URL, return a function that accepts a query plan and returns a query channel
onto which the results will be enqueued. This is the mechanism used to traverse
from one graph to another, possibly over the network. Dispatch is based on the
protocol as a keyword (e.g. :http, :plasma, :jiraph, etc...)"
(fn [url]
(keyword (:proto (url-map url)))))
8 changes: 5 additions & 3 deletions src/plasma/viz.clj
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
(str "-Nfontsize=" node-font-size)
"-o" out))))

(def APP "evince")
(def APP "open")

(defn show-dot-graph
([g] (show-dot-graph g {}))
Expand All @@ -126,15 +126,17 @@
out (str "/tmp/plasma-graph." out-format)]
(save-dot-graph g "/tmp/plasma-graph.dot" options)
(save-graph-image "/tmp/plasma-graph.dot" out options)
(sh app out))))
(if-let [sub-app (:sub-app options)]
(sh app sub-app out)
(sh app out)))))

(defn graph->ps
[g & [options]]
(show-dot-graph g options))

(defn graph->browser
[g & [options]]
(show-dot-graph g (merge options {:out-format "svg" :app "chromium-browser"})))
(show-dot-graph g (merge options {:out-format "svg" :app "open" :sub-app "/Applications/Google\\ Chrome.app"})))

(defn- label-table
[top bottom]
Expand Down

0 comments on commit 8eb8272

Please sign in to comment.