From 41a1387bdbe4f0a45528f8f23cc6eb1ecf9ca717 Mon Sep 17 00:00:00 2001 From: jem Date: Sat, 25 Apr 2020 14:26:33 +0200 Subject: [PATCH] get input from html --- public/index.html | 3 ++- src/main/dda/masto_embed/app.cljs | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 3abd878..5d22a58 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,8 @@ masto-embed -
+
Here the timeline will appear.
diff --git a/src/main/dda/masto_embed/app.cljs b/src/main/dda/masto_embed/app.cljs index f5b9240..8f52211 100644 --- a/src/main/dda/masto_embed/app.cljs +++ b/src/main/dda/masto_embed/app.cljs @@ -18,15 +18,22 @@ [dda.masto-embed.api :as api] [clojure.pprint :as pprint :refer [pprint]])) -(def mastodon-config - (api/create-config "2" "https://social.meissa-gmbh.de")) +(def masto-embed "masto-embed") + +(defn mastodon-config-from-document [] + (let [masto-embed (.getElementById js/document masto-embed) + host-url (.getAttribute masto-embed "host_url") + account-id (.getAttribute masto-embed "account_id")] + (api/create-config account-id host-url))) (defn render-to-document [input] (-> js/document - (.getElementById "mastodon-timeline") + (.getElementById masto-embed) (.-innerHTML) (set! input))) (defn init [] - (api/get-mastodon-timeline mastodon-config render-to-document)) \ No newline at end of file + (api/get-mastodon-timeline + (mastodon-config-from-document) + render-to-document)) \ No newline at end of file