...
 
Commits (2)
......@@ -114,41 +114,39 @@
(.getElementById js/document "app")
cpub-get-data!))
;; Load some stuff to play around
;; how to like something:
;; (-> (activitypub/like (rdf/iri "http://openengiadina.net/"))
;; (cpub/post-rdf (str actor-id "/outbox") auth))
;; (cpub-get-data!)
(geopub.state/add-rdf-graph! state (get-rdf "https://inqlab.net/"
{:with-credentials? false}))
;; NOTE: The mystery why the size of the store increases when loading the ontology: Blank Nodes. N3.js gives new ids so blank nodes (and thing refering those blank nodes) are duplicted...need metadata
;; (load-ontologies)
(geopub.state/add-rdf-graph! state (get-rdf "https://openengiadina.net/"
{:with-credentials? false}))
;; (geopub.state/reset-graph! state)
;; (geopub.state/add-rdf-graph! state (get-rdf "https://openengiadina.net/"
;; {:with-credentials? false}))
(geopub.state/add-rdf-graph! state (get-rdf "https://ruben.verborgh.org/"
{:with-credentials? false}))
;; (geopub.state/add-triples! state (get-rdf "https://inqlab.net/"
;; {:with-credentials? false}))
(geopub.state/add-rdf-graph! state (get-rdf "https://chaos.social/users/pukkamustard"
{:with-credentials? false}))
;; Load some stuff to play around
(geopub.state/add-rdf-graph! state (get-rdf "https://chaos.social/users/pukkamustard/outbox?page=true"
{:with-credentials? false}))
(geopub.state/add-triples! state (get-rdf "https://ruben.verborgh.org"
(geopub.state/add-rdf-graph! state (get-rdf "https://mastodon.social/users/sl007"
{:with-credentials? false}))
(geopub.state/add-triples! state (get-rdf "https://chaos.social/users/pukkamustard"
(geopub.state/add-rdf-graph! state (get-rdf "https://mastodon.social/users/sl007/outbox?page=true"
{:with-credentials? false}))
(geopub.state/add-triples! state (get-rdf "https://chaos.social/users/bumbleblue"
(geopub.state/add-rdf-graph! state (get-rdf "https://framapiaf.org/users/framasoft"
{:with-credentials? false}))
(geopub.state/add-triples! state (get-rdf "https://mastodon.social/users/sl007"
(geopub.state/add-rdf-graph! state (get-rdf "https://framapiaf.org/users/framasoft/outbox?page=true"
{:with-credentials? false}))
(geopub.state/add-triples! state (get-rdf "https://framapiaf.org/users/srosset"
(geopub.state/add-rdf-graph! state (get-rdf "https://literatur.social/users/buechergefahr"
{:with-credentials? false}))
(geopub.state/add-triples! state (get-rdf "https://literatur.social/users/buechergefahr"
(geopub.state/add-rdf-graph! state (get-rdf "https://literatur.social/users/buechergefahr/outbox?page=true"
{:with-credentials? false}))
......
......@@ -14,29 +14,19 @@
"Takes RDF graph from a channel and merge with stategraph."
[state chan]
(go
(let [input-graph (<! chan)
;; merge graph in state with input-graph
new-graph (rdf/graph-merge (:graph @state) input-graph)]
;; swap in new graph
(swap! state (fn [state]
(assoc state :graph new-graph))))))
;; get the input from channel
(let [input (<! chan)]
(defn add-triples!
"Takes triples from a channel and adds them to the graph. The input channel must be closed before changes are applied."
[state chan]
(go
(let [input-graph (<! (async/reduce
;; read sequence of triples and add to graph
(fn [graph input]
(reduce rdf/graph-add graph (rdf/triple-seq input)))
;; initialize a fresh graph
(rdf.graph.map/graph)
chan))
;; merge graph in state with input-graph
new-graph (rdf/graph-merge (:graph @state) input-graph)]
;; swap in new graph
(swap! state (fn [state]
(assoc state :graph new-graph))))))
;; if input is a graph
(if (rdf/graph? input)
;; swap state graph with graph merged with input graph
(swap! state (fn [state]
(assoc state :graph
(rdf/graph-merge (:graph state) input))))
;; else return whatever input is (probably an error)
input))))
(defn reset-graph! [state]
(swap! state #(assoc % :graph (rdf.graph.map/graph))))