From 47126a7b75bf53a9e83dffd67b0a00832de66fb1 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 29 May 2024 15:09:01 +0200 Subject: [PATCH] Add arg to masto-html for mode --- src/main/dda/masto_embed/modes.cljs | 4 ++-- src/main/dda/masto_embed/to_html.cljs | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/dda/masto_embed/modes.cljs b/src/main/dda/masto_embed/modes.cljs index 6692274..05687cc 100644 --- a/src/main/dda/masto_embed/modes.cljs +++ b/src/main/dda/masto_embed/modes.cljs @@ -75,7 +75,7 @@ (filter #(or (not filter-favorited) (:favorited %))) (reverse) (map :status) - (th/masto->html) + (th/masto->html "replies-mode") (render-html) (b/render-to-document))))) @@ -89,6 +89,6 @@ (filter #(= nil (:reblog %))) (filter #(= nil (:in_reply_to_account_id %))) (take 4) - (th/masto->html) + (th/masto->html "account-mode") (render-html) (b/render-to-document))))) diff --git a/src/main/dda/masto_embed/to_html.cljs b/src/main/dda/masto_embed/to_html.cljs index a2cf7f1..759d813 100644 --- a/src/main/dda/masto_embed/to_html.cljs +++ b/src/main/dda/masto_embed/to_html.cljs @@ -98,14 +98,19 @@ (cm/replace-all-matching-values-by-new-value "REBLOGS_COUNT" reblogs_count) (cm/replace-all-matching-values-by-new-value "FAVOURITES_COUNT" favourites_count))) -(defn masto->html [statuses] +(defn insert-mode [html mode] + (-> html + (cm/replace-all-matching-values-by-new-value "section MODE" (str "section " mode)))) + +(defn masto->html [mode statuses] (let [html (b/post-html-hiccup)] (map (fn [status] (let [{:keys [account created_at content media_attachments replies_count reblogs_count favourites_count card url]} status] - (-> html + (-> html (masto-header->html account created_at url) (masto-content->html content) (masto-media->html media_attachments) (masto-link-prev->html card) - (masto-footer->html replies_count reblogs_count favourites_count)))) + (masto-footer->html replies_count reblogs_count favourites_count) + (insert-mode mode)))) statuses)))