This commit is contained in:
jem 2020-06-19 11:05:45 +02:00
parent c4f62a9b4d
commit 85ef9b8667
4 changed files with 53 additions and 10 deletions

View file

@ -5,7 +5,9 @@
<title>masto-embed</title>
</head>
<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">
Here the timeline will appear.
</div>

View file

@ -5,7 +5,7 @@
"src/test"]
:dependencies
[[orchestra "2018.12.06-2"]]
[[orchestra "2019.02.06-1"]]
:dev-http {8080 "public"}
:builds
{:test

View file

@ -58,6 +58,13 @@
(str "directory?local=true")
#js {})
#(let [response (-> % .-data js->edn)]
(if-let [error (:error response)]
(exit-with-error error)
(callback response)))))
(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))))

View file

@ -16,6 +16,8 @@
(ns dda.masto-embed.app
(:require
[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]]))
(def masto-embed "masto-embed")
@ -24,8 +26,8 @@
(-> js/document
(.getElementById masto-embed)
(.getAttribute "host_url")))
(defn account-name-from-document []
(-> js/document
(.getElementById masto-embed)
(.getAttribute "account_name")))
@ -42,8 +44,40 @@
(.-innerHTML)
(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 []
(api/get-account-statuses
(host-url-from-document)
(account-id-from-document)
render-to-document))
(go
(let [account-id (or
(account-id-from-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))