respect origin author
This commit is contained in:
parent
63d6dde11e
commit
5ddc691dff
4 changed files with 37 additions and 34 deletions
|
@ -1,6 +0,0 @@
|
||||||
(ns activity-pub-poc.core)
|
|
||||||
|
|
||||||
(defn -main
|
|
||||||
"I don't do a whole lot ... yet."
|
|
||||||
[& args]
|
|
||||||
(println "Hello, World!"))
|
|
|
@ -1,10 +1,9 @@
|
||||||
(ns dda.activity-pub-poc.activitypub
|
(ns lambdaisland.souk.activitypub
|
||||||
"Interact with ActivityPub instances"
|
"Interact with ActivityPub instances"
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[dda.activity-pub-poc.json-ld :as ld]
|
[lambdaisland.souk.json-ld :as ld]
|
||||||
[lambdaisland.uri :as uri]
|
[lambdaisland.uri :as uri]))
|
||||||
[clojure.inspector :as ins]))
|
|
||||||
|
|
||||||
(def common-prefixes
|
(def common-prefixes
|
||||||
{"dcterms" "http://purl.org/dc/terms/"
|
{"dcterms" "http://purl.org/dc/terms/"
|
||||||
|
@ -50,7 +49,7 @@
|
||||||
"suspended" "toot:suspended"}])
|
"suspended" "toot:suspended"}])
|
||||||
|
|
||||||
(defn GET [url]
|
(defn GET [url]
|
||||||
(ld/internalize (ld/expand (ld/json-get url)) common-prefixes))
|
(ld/internalize (ld/expand (:body (ld/json-get url))) common-prefixes))
|
||||||
|
|
||||||
(defn kw->iri [kw]
|
(defn kw->iri [kw]
|
||||||
(if (string? kw)
|
(if (string? kw)
|
||||||
|
@ -77,5 +76,3 @@
|
||||||
(let [[username domain] (str/split (:path iri) #"@")]
|
(let [[username domain] (str/split (:path iri) #"@")]
|
||||||
{:domain domain
|
{:domain domain
|
||||||
:username username}))))
|
:username username}))))
|
||||||
|
|
||||||
(ins/inspect-tree (GET ld/team-url))
|
|
|
@ -1,22 +1,17 @@
|
||||||
(ns dda.activity-pub-poc.json-ld
|
(ns lambdaisland.souk.json-ld
|
||||||
(:require
|
"Interfacing with JSON-LD endpoints, and converting to and from idiomatic
|
||||||
[hato.client :as http]
|
Clojure data."
|
||||||
|
(:require [hato.client :as hato]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]))
|
||||||
[clojure.inspector :as ins]
|
|
||||||
))
|
|
||||||
|
|
||||||
(def team-url "https://social.meissa-gmbh.de/users/team")
|
|
||||||
|
|
||||||
;; TODO: use a real cacheing lib instead of simple atom?
|
|
||||||
(def context-cache (atom {}))
|
|
||||||
|
|
||||||
(defn json-get [url]
|
(defn json-get [url]
|
||||||
(:body
|
(hato/get url
|
||||||
(http/get url
|
|
||||||
{:headers {"Accept" "application/json"}
|
{:headers {"Accept" "application/json"}
|
||||||
:http-client {:redirect-policy :normal}
|
:http-client {:redirect-policy :normal}
|
||||||
:as :json-string-keys})))
|
:as :json-string-keys}))
|
||||||
|
|
||||||
|
(def context-cache (atom {})) ;; url -> context
|
||||||
|
|
||||||
(defn fetch-context [url]
|
(defn fetch-context [url]
|
||||||
(if-let [ctx (get @context-cache url)]
|
(if-let [ctx (get @context-cache url)]
|
||||||
|
@ -24,7 +19,7 @@
|
||||||
(get
|
(get
|
||||||
(swap! context-cache
|
(swap! context-cache
|
||||||
(fn [cache]
|
(fn [cache]
|
||||||
(assoc cache url (get (json-get url) "@context"))))
|
(assoc cache url (get (:body (json-get url)) "@context"))))
|
||||||
url)))
|
url)))
|
||||||
|
|
||||||
(defn expand-context
|
(defn expand-context
|
||||||
|
@ -170,6 +165,9 @@
|
||||||
(get iri->prop ?iri ?iri)))]
|
(get iri->prop ?iri ?iri)))]
|
||||||
(assoc (walk/postwalk convert-val v) "@context" context)))
|
(assoc (walk/postwalk convert-val v) "@context" context)))
|
||||||
|
|
||||||
(expand-context (get (json-get team-url) "@context"))
|
;; (compact
|
||||||
|
;; (expand (:body (json-get "https://toot.cat/users/plexus")))
|
||||||
|
;; common-prefixes)
|
||||||
|
|
||||||
(ins/inspect-tree (expand (json-get team-url)))
|
;; "name"
|
||||||
|
;; "profileName"
|
|
@ -0,0 +1,14 @@
|
||||||
|
(ns org.domaindrivenarchitecture.activity-pub-poc.core
|
||||||
|
(:require [lambdaisland.souk.activitypub :as ap]
|
||||||
|
[lambdaisland.souk.json-ld :as ld]
|
||||||
|
[clojure.inspector :as ins]) )
|
||||||
|
|
||||||
|
(def team-url "https://social.meissa-gmbh.de/users/team")
|
||||||
|
|
||||||
|
(def context (ld/expand-context (get (ld/json-get team-url) "@context")))
|
||||||
|
|
||||||
|
(def expanded-ld (ins/inspect-tree (ld/expand (ld/json-get team-url))))
|
||||||
|
|
||||||
|
(def ap-resource (ap/GET team-url))
|
||||||
|
|
||||||
|
(ins/inspect-tree ap-resource)
|
Loading…
Reference in a new issue