diff --git a/.gitignore b/.gitignore index c6f18bc..5cf60e1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ pom.xml.asc .lein-plugins/ .lein-failures .nrepl-port +package-lock.json +output.calva-repl .cpcache/ .shadow-cljs/ node_modules/ diff --git a/src/main/dda/masto_embed/api.cljs b/src/main/dda/masto_embed/api.cljs index a5842bf..4de34c9 100644 --- a/src/main/dda/masto_embed/api.cljs +++ b/src/main/dda/masto_embed/api.cljs @@ -41,8 +41,40 @@ (str "accounts/" account-id "/statuses") #js {})) +; https://mastodon.example/api/v1/statuses/:id/context +; for parent and child statuses +; "descendants" +(defn get-replies + [host-url + status-id] + (.get (mastodon-client host-url) + (str "statuses/" status-id "/context") + #js {})) + +(defn get-filtered-replies + [host-url + status-id + account] + (->> (.get (mastodon-client host-url) + (str "statuses/" status-id "/context") + #js {}) + mastojs->edn + (:descendants))) + +(defn get-favorited-by + [host-url + status-id] + (.get (mastodon-client host-url) + (str "statuses/" status-id "/favourited_by") + #js {})) + (defn-spec get-directory any? [host-url ::host-url] (.get (mastodon-client host-url) (str "directory?local=true") #js {})) + +; TODO: +; 1. ID of status with reply: 107655615528722482 +; 2. Get replies to status +; 3. Filter by favorited and or tags \ No newline at end of file diff --git a/src/main/dda/masto_embed/app.cljs b/src/main/dda/masto_embed/app.cljs index d42acae..3c15b9a 100644 --- a/src/main/dda/masto_embed/app.cljs +++ b/src/main/dda/masto_embed/app.cljs @@ -25,20 +25,19 @@ (def masto-embed "masto-embed") -(defn host-url-from-document [] +(defn element-from-document-by-name [name] (-> js/document (.getElementById masto-embed) - (.getAttribute "host_url"))) + (.getAttribute name))) + +(defn host-url-from-document [] + (element-from-document-by-name "host_url")) (defn account-name-from-document [] - (-> js/document - (.getElementById masto-embed) - (.getAttribute "account_name"))) + (element-from-document-by-name "account_name")) (defn account-id-from-document [] - (-> js/document - (.getElementById masto-embed) - (.getAttribute "account_id"))) + (element-from-document-by-name "account_id")) (defn render-to-document [input] @@ -60,20 +59,45 @@ first))) out)) +(defn favorited-replies? [host-url reply-id account-name] + (let [out (chan)] + (go (>! out + (->> + (
edn + (filter #(= account-name (:acct %))) + ))) + out)) + (defn init [] (go (let [host-url (host-url-from-document) account-name (account-name-from-document) - account-id (or + account-id (or (account-id-from-document) ( (
edn) + test-status (-> + (
edn) + filtered (filter #(go (> statuus - (take 4) - (rb/masto->html) - (render-html) - (render-to-document)) + ;(->> statuus + ; (take 4) + ; (rb/masto->html) + ; (render-html) + ; (render-to-document)) + ;(go (infra/debug (edn (
> filtered + ; (infra/debug) + ; (rb/masto->html) + ; (render-html) + ; (render-to-document)) ))) + +