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"
|
||||
(:require
|
||||
[clojure.string :as str]
|
||||
[dda.activity-pub-poc.json-ld :as ld]
|
||||
[lambdaisland.uri :as uri]
|
||||
[clojure.inspector :as ins]))
|
||||
[lambdaisland.souk.json-ld :as ld]
|
||||
[lambdaisland.uri :as uri]))
|
||||
|
||||
(def common-prefixes
|
||||
{"dcterms" "http://purl.org/dc/terms/"
|
||||
|
@ -50,7 +49,7 @@
|
|||
"suspended" "toot:suspended"}])
|
||||
|
||||
(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]
|
||||
(if (string? kw)
|
||||
|
@ -77,5 +76,3 @@
|
|||
(let [[username domain] (str/split (:path iri) #"@")]
|
||||
{:domain domain
|
||||
:username username}))))
|
||||
|
||||
(ins/inspect-tree (GET ld/team-url))
|
|
@ -1,22 +1,17 @@
|
|||
(ns dda.activity-pub-poc.json-ld
|
||||
(:require
|
||||
[hato.client :as http]
|
||||
[clojure.string :as str]
|
||||
[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 {}))
|
||||
(ns lambdaisland.souk.json-ld
|
||||
"Interfacing with JSON-LD endpoints, and converting to and from idiomatic
|
||||
Clojure data."
|
||||
(:require [hato.client :as hato]
|
||||
[clojure.string :as str]
|
||||
[clojure.walk :as walk]))
|
||||
|
||||
(defn json-get [url]
|
||||
(:body
|
||||
(http/get url
|
||||
{:headers {"Accept" "application/json"}
|
||||
:http-client {:redirect-policy :normal}
|
||||
:as :json-string-keys})))
|
||||
(hato/get url
|
||||
{:headers {"Accept" "application/json"}
|
||||
:http-client {:redirect-policy :normal}
|
||||
:as :json-string-keys}))
|
||||
|
||||
(def context-cache (atom {})) ;; url -> context
|
||||
|
||||
(defn fetch-context [url]
|
||||
(if-let [ctx (get @context-cache url)]
|
||||
|
@ -24,7 +19,7 @@
|
|||
(get
|
||||
(swap! context-cache
|
||||
(fn [cache]
|
||||
(assoc cache url (get (json-get url) "@context"))))
|
||||
(assoc cache url (get (:body (json-get url)) "@context"))))
|
||||
url)))
|
||||
|
||||
(defn expand-context
|
||||
|
@ -170,6 +165,9 @@
|
|||
(get iri->prop ?iri ?iri)))]
|
||||
(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