jans-mob
This commit is contained in:
parent
c4f62a9b4d
commit
85ef9b8667
4 changed files with 53 additions and 10 deletions
|
@ -5,7 +5,9 @@
|
||||||
<title>masto-embed</title>
|
<title>masto-embed</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="masto-embed" account_name="team" account_id="2"
|
<div id="masto-embed"
|
||||||
|
account_name="team"
|
||||||
|
xaccount_id="2"
|
||||||
host_url="https://social.meissa-gmbh.de">
|
host_url="https://social.meissa-gmbh.de">
|
||||||
Here the timeline will appear.
|
Here the timeline will appear.
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"src/test"]
|
"src/test"]
|
||||||
|
|
||||||
:dependencies
|
:dependencies
|
||||||
[[orchestra "2018.12.06-2"]]
|
[[orchestra "2019.02.06-1"]]
|
||||||
:dev-http {8080 "public"}
|
:dev-http {8080 "public"}
|
||||||
:builds
|
:builds
|
||||||
{:test
|
{:test
|
||||||
|
|
|
@ -58,6 +58,13 @@
|
||||||
(str "directory?local=true")
|
(str "directory?local=true")
|
||||||
#js {})
|
#js {})
|
||||||
#(let [response (-> % .-data js->edn)]
|
#(let [response (-> % .-data js->edn)]
|
||||||
(if-let [error (:error response)]
|
(callback response))))
|
||||||
(exit-with-error error)
|
|
||||||
(callback response)))))
|
(defn-spec get-directory2 any?
|
||||||
|
[host-url ::host-url]
|
||||||
|
(go (let [result (<p! (.get (mastodon-client host-url)
|
||||||
|
(str "directory?local=true")
|
||||||
|
#js {}))]
|
||||||
|
(-> result
|
||||||
|
.-data
|
||||||
|
js->edn))))
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
(ns dda.masto-embed.app
|
(ns dda.masto-embed.app
|
||||||
(:require
|
(:require
|
||||||
[dda.masto-embed.api :as api]
|
[dda.masto-embed.api :as api]
|
||||||
|
[cljs.core.async :refer [go close! put! take! timeout chan <! >!]]
|
||||||
|
[cljs.core.async.interop :refer-macros [<p!]]
|
||||||
[clojure.pprint :as pprint :refer [pprint]]))
|
[clojure.pprint :as pprint :refer [pprint]]))
|
||||||
|
|
||||||
(def masto-embed "masto-embed")
|
(def masto-embed "masto-embed")
|
||||||
|
@ -24,8 +26,8 @@
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById masto-embed)
|
(.getElementById masto-embed)
|
||||||
(.getAttribute "host_url")))
|
(.getAttribute "host_url")))
|
||||||
|
|
||||||
(defn account-name-from-document []
|
(defn account-name-from-document []
|
||||||
|
|
||||||
(-> js/document
|
(-> js/document
|
||||||
(.getElementById masto-embed)
|
(.getElementById masto-embed)
|
||||||
(.getAttribute "account_name")))
|
(.getAttribute "account_name")))
|
||||||
|
@ -42,8 +44,40 @@
|
||||||
(.-innerHTML)
|
(.-innerHTML)
|
||||||
(set! input)))
|
(set! input)))
|
||||||
|
|
||||||
|
(defn debug [elem]
|
||||||
|
(print elem)
|
||||||
|
elem)
|
||||||
|
|
||||||
|
|
||||||
|
(defn find-account-id [host-url account-name]
|
||||||
|
(let [in (chan)
|
||||||
|
out (chan)]
|
||||||
|
(go
|
||||||
|
(->>
|
||||||
|
(<! in)
|
||||||
|
(filter #(= account-name (:acct %)))
|
||||||
|
(map :id)
|
||||||
|
first
|
||||||
|
debug
|
||||||
|
(>! out))
|
||||||
|
(do (close! in)
|
||||||
|
(close! out))
|
||||||
|
)
|
||||||
|
;(api/get-directory host-url #(go (>! in %)))
|
||||||
|
out))
|
||||||
|
|
||||||
(defn init []
|
(defn init []
|
||||||
(api/get-account-statuses
|
(go
|
||||||
(host-url-from-document)
|
(let [account-id (or
|
||||||
(account-id-from-document)
|
(account-id-from-document)
|
||||||
render-to-document))
|
(<! (find-account-id "https://social.meissa-gmbh.de" "team")))]
|
||||||
|
(print account-id)
|
||||||
|
(api/get-account-statuses
|
||||||
|
(host-url-from-document)
|
||||||
|
account-id
|
||||||
|
render-to-document))))
|
||||||
|
|
||||||
|
(go
|
||||||
|
(let
|
||||||
|
[result (<p! (api/get-directory "https://social.meissa-gmbh.de"))]
|
||||||
|
result))
|
Loading…
Reference in a new issue