Add arg to masto-html for mode

This commit is contained in:
erik 2024-05-29 15:09:01 +02:00
parent fd72cdecfa
commit 47126a7b75
2 changed files with 10 additions and 5 deletions

View file

@ -75,7 +75,7 @@
(filter #(or (not filter-favorited) (:favorited %))) (filter #(or (not filter-favorited) (:favorited %)))
(reverse) (reverse)
(map :status) (map :status)
(th/masto->html) (th/masto->html "replies-mode")
(render-html) (render-html)
(b/render-to-document))))) (b/render-to-document)))))
@ -89,6 +89,6 @@
(filter #(= nil (:reblog %))) (filter #(= nil (:reblog %)))
(filter #(= nil (:in_reply_to_account_id %))) (filter #(= nil (:in_reply_to_account_id %)))
(take 4) (take 4)
(th/masto->html) (th/masto->html "account-mode")
(render-html) (render-html)
(b/render-to-document))))) (b/render-to-document)))))

View file

@ -98,14 +98,19 @@
(cm/replace-all-matching-values-by-new-value "REBLOGS_COUNT" reblogs_count) (cm/replace-all-matching-values-by-new-value "REBLOGS_COUNT" reblogs_count)
(cm/replace-all-matching-values-by-new-value "FAVOURITES_COUNT" favourites_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)] (let [html (b/post-html-hiccup)]
(map (fn [status] (map (fn [status]
(let [{:keys [account created_at content media_attachments replies_count reblogs_count favourites_count card url]} 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-header->html account created_at url)
(masto-content->html content) (masto-content->html content)
(masto-media->html media_attachments) (masto-media->html media_attachments)
(masto-link-prev->html card) (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))) statuses)))