...
 
Commits (4)
@prefix : <http://www.w3.org/ns/activitystreams#> .
@prefix as: <http://www.w3.org/ns/activitystreams#> .
@prefix : <https://www.w3.org/ns/activitystreams#> .
@prefix as: <https://www.w3.org/ns/activitystreams#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
......@@ -7,7 +7,7 @@
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.w3.org/ns/activitystreams> .
<http://www.w3.org/ns/activitystreams#> a owl:Ontology ;
<https://www.w3.org/ns/activitystreams#> a owl:Ontology ;
rdfs:comment "Extended Activity Streams 2.0 Vocabulary"@en ;
rdfs:label "Activity Streams 2.0"@en ;
owl:imports <http://www.w3.org/ns/prov#> .
......
(ns activitypub.core
(ns geopub.activitypub
"Helpers to deal with ActivityPub data"
(:require-macros [cljs.core.logic :refer [run* fresh]])
(:require [rdf.core :as rdf]
......
......@@ -25,6 +25,7 @@
[geopub.ui.browse]
[geopub.data.rdf :refer [get-rdf]]
[geopub.cpub :as cpub]
[geopub.routes]
[reitit.core :as rc]
[reitit.frontend :as rf]
[reitit.frontend.easy :as rfe]))
......@@ -78,30 +79,6 @@
(def default-view geopub.ui.activity/view)
(def routes
[["activity"
{:name ::activity
:view geopub.ui.activity/view}]
["browse/description/:iri"
{:name ::browse
:view geopub.ui.browse/description-view
:parameters {:path {:iri string?}}}]
["browse/type/:iri"
{:name ::browse-type
:view geopub.ui.browse/type-view
:parameters {:path {:iri string?}}}]
["store"
{:name ::store
:view geopub.ui.store/view}]
["map"
{:name ::map
:view geopub.ui.map/view}]])
(defn ui [state]
[:div#container
......@@ -112,9 +89,10 @@
[:nav
[:ul
[:li [:a {:href (rfe/href ::activity)} "Activity"]]
[:li [:a {:href (rfe/href ::store)} "Store"]]
[:li [:a {:href (rfe/href ::map)} "Map"]]]]]
[:li [:a {:href (rfe/href :geopub.routes/activity)} "Activity"]]
[:li [:a {:href (rfe/href :geopub.routes/browse)} "Browse"]]
[:li [:a {:href (rfe/href :geopub.routes/store)} "Store"]]
[:li [:a {:href (rfe/href :geopub.routes/map)} "Map"]]]]]
(let [view (get-in @state [:current-route :data :view])]
(if view
......@@ -124,7 +102,7 @@
(defn init! []
(load-ontologies)
(rfe/start!
(rf/router routes)
(rf/router geopub.routes/routes)
(fn [match]
(swap! state #(assoc % :current-route match)))
;; set to false to enable HistoryAPI
......
......@@ -21,6 +21,7 @@
(:require [cljs.core.async :refer [<!]]
[rdf.core :as rdf]
[geopub.data.rdf :refer [get-rdf]]
[geopub.activitypub :as activitypub]
[goog.Uri :as uri]))
(defn public-timeline-url [server-url]
......@@ -35,11 +36,7 @@
(get-rdf {:with-credentials? false})))
;; (defn post-rdf [data url auth]
;; (go
;; (let [body (<! (n3/encode data))]
;; (http/post url
;; {:with-credentials? false
;; :basic-auth auth
;; :headers {"Content-type" "text/turtle"}
;; :body body}))))
(defn like! [what]
(-> (activitypub/like what)
(geopub.data.rdf/post-rdf "http://localhost:4000/users/alice/outbox"
{:basic-auth {:username "alice" :password "123"}})))
......@@ -96,6 +96,14 @@
;; HTTP request failed. Return an error.
(ex-info "HTTP request failed" response)))))
;; Data posting
(defn post-rdf [data url & [opts]]
(go
(let [body (<! (n3/encode data))]
(http/post url (merge
{:headers {"Content-type" "text/turtle"}
:body body} opts)))))
;; Reagent components
......@@ -109,7 +117,7 @@
[:span
{:class class}
[:a
{:href (rfe/href :geopub.core/browse
{:href (rfe/href :geopub.routes/description
{:iri (goog.string.urlEncode (rdf/iri-value iri))})}
(rdf/iri-value iri)]]
......@@ -177,10 +185,8 @@
[:dl
(for
[triple (rdf/triple-seq object)]
;; TODO add unique key
^{:key (prn-str (rdf/triple-predicate triple))}
^{:key (hash triple)}
[:div.object-property-list
;; TODO: add key
[:dt [rdf-term-component (rdf/triple-predicate triple)]]
[:dd [rdf-term-component (rdf/triple-object triple)]]])])
......
......@@ -21,7 +21,7 @@
;; Commonly used namespaces
(defns as "http://www.w3.org/ns/activitystreams#")
(defns as "https://www.w3.org/ns/activitystreams#")
(defns rdfs "http://www.w3.org/2000/01/rdf-schema#")
(defns schema "http://schema.org/")
(defns geo "http://www.w3.org/2003/01/geo/wgs84_pos#")
(ns geopub.routes
(:require [reitit.frontend.easy :as rfe]
[goog.string]
[geopub.ui.activity]
[geopub.ui.browse]
[geopub.ui.store]
[geopub.ui.map]))
(def routes
[["activity"
{:name ::activity
:view geopub.ui.activity/view}]
["browse/description/:iri"
{:name ::description
:view geopub.ui.browse/description-view
:parameters {:path {:iri string?}}}]
["browse"
{:name ::browse
:view geopub.ui.browse/browse-view
:parameters {:query {:type string?}}}]
["store"
{:name ::store
:view geopub.ui.store/view}]
["map"
{:name ::map
:view geopub.ui.map/view}]])
......@@ -21,7 +21,7 @@
[geopub.data.rdf :refer [iri-component
literal-component
description-component]]
[activitypub.core :as activitypub]
[geopub.activitypub :as activitypub]
[rdf.core :as rdf]
[rdf.description :as rd]
[rdf.ns :as ns]
......
......@@ -4,21 +4,49 @@
[reagent.core :as r]
[goog.string]
[geopub.state]
[geopub.data.rdf :refer [description-header-component
[geopub.ns :as ns]
[geopub.cpub]
[geopub.data.rdf :refer [rdf-term-component
description-header-component
description-component]]
[reitit.frontend.easy :as rfe]))
[cljs.core.logic :as l]
[rdf.logic :as rdf-logic]
[reitit.frontend.easy :as rfe])
(:require-macros [cljs.core.logic :refer [run* fresh]]))
(defn browse-href [type]
(rfe/href :geopub.routes/browse {} {:type (goog.string.urlEncode
(rdf/iri-value type))}))
(defn go-to-url []
(let [input (r/atom "")]
(fn []
[:div
[:input {:type "text"
:on-change #(reset! input (-> % .-target .-value))}]
[:button
{:on-click #(rfe/push-state :geopub.routes/description
{:iri (goog.string.urlEncode @input)})}
"Go"]])))
(defn sidebar []
[:div.sidebar
[:nav
[:h3 "Types"]
[:p "TODO Here you can select type of data to browse."]
[:ul
[:li [:a {:href "#"} "Notes"]]
[:li [:a {:href "#"} "Events"]]
[:li [:a {:href "#"} "Websites"]]
[:li [:a {:href "#"} "Actors"]]
[:li [:a {:href "#"} "Ontologies"]]]]])
[:li [:a {:href (browse-href (ns/as "Note"))} "Notes"]]
[:li [:a {:href (browse-href (ns/as "Article"))} "Articles"]]
[:li [:a {:href (browse-href (ns/as "Person"))} "Person"]]
[:li [:a {:href (browse-href (ns/as "Like"))} "Likes"]]
[:li [:a {:href (browse-href (ns/schema "Event"))} "Events"]]
[:li [:a {:href (browse-href (ns/schema "WebPage"))} "Web Page"]]
[:li [:a {:href (browse-href (ns/rdfs "Class"))} "Class"]]
]
[:h3 "Enter URL"]
[go-to-url]
]])
(defn get-iri [state]
(-> @state
......@@ -26,22 +54,14 @@
(goog.string.urlDecode)
(rdf/iri)))
(defn go-to-url []
(let [input (r/atom "")]
(fn []
[:span
[:input {:type "text"
:on-change #(reset! input (-> % .-target .-value))}]
[:button
{:on-click #(rfe/push-state :geopub.core/browse
{:iri (goog.string.urlEncode @input)})}
"Go"]])))
(defn toolbar [state]
[:div.toolbar
[go-to-url]
[:button
{:on-click
#(geopub.cpub/like! (get-iri state))} "Like"]
[:button
{:on-click
......@@ -61,8 +81,33 @@
[:main
[description-component @description]]]]))
(defn get-type [state]
(-> @state
(get-in [:current-route :query-params :type] "")
(goog.string.urlDecode)
(rdf/iri)))
(defn type-view [state]
[:div.ui-page
[sidebar]
[:main "ylo"]])
(defn get-descriptions
"Returns sequence of descriptions that have the specified type."
[graph type]
;; TODO implement RDFs subClass
(map
#(rdf-description/description % graph)
(run* [subject] (rdf-logic/graph-typeo graph subject type))))
(defn browse-view [state]
(let [type (get-type state)]
[:div.ui-page
[sidebar]
[:div.main-container
[:main
[:h1 [rdf-term-component type]]
[:table
[:tbody
(for [desc (get-descriptions (:graph @state) type)]
^{:key (hash desc)}
[:tr
[:td [rdf-term-component
(rdf-description/description-subject desc)]]]
)]]
]]]))
......@@ -28,3 +28,8 @@
(run* [o]
(rl/graph-tripleo (:graph description)
(rdf/triple (:subject description) key o))))
(defn description-predications [description]
(run* [p o]
(rl/graph-tripleo (:graph description)
(rdf/triple (:subject description) p o))))