remove unused functions

This commit is contained in:
Clemens 2024-05-22 12:14:26 +02:00
parent 430911272e
commit e0a735e9bc
2 changed files with 16 additions and 68 deletions

View file

@ -38,31 +38,6 @@
{:type :element, :attrs {:class "mastodon-post-link-description"}, :tag :div, :content ["LINK_PREVIEW_DESC"]}
{:type :element, :attrs {:class "mastodon-post-link-url"}, :tag :div, :content ["LINK_PREVIEW_URL"]}]}])
(defn mastocard->html [card]
(when (some? card)
(let [{:keys [title description image url]} card]
[:div {:class "card" :url url}
(when (some? image)
[:img {:class "card-img-top" :src image}])
[:h3 {:class "card-title"} title]
[:p {:class "card-body"} description]])))
(defn masto->html [statuses]
[:ul {:class "list-group"}
(map (fn [status]
(let [{:keys [created_at card]} status
date (t/parse created_at)]
[:li {:class "list-group-item, card"}
[:div {:class "card-body"}
[:h2 {:class "card-title"}
[:a {:href (get-in status [:url])}
(t/unparse (t/formatters :date) date) " "
(t/unparse (t/formatters :hour-minute-second) date)]]
[:p {:class "card-text"}
(:content status)
(mastocard->html card)]]]))
statuses)])
(defn masto-header->html [html account created_at url]
(let [{:keys [username display_name avatar_static]} account
date (t/parse created_at)]
@ -122,7 +97,7 @@
(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->html2 [statuses]
(defn masto->html [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]
@ -149,14 +124,14 @@
(defn account-mode [host-url account-name]
(go
(let [account-id (<! (find-account-id host-url account-name))
statuus (->
status (->
(<p! (api/get-account-statuses host-url account-id))
api/mastojs->edn)]
(->> statuus
(->> status
(filter #(= nil (:reblog %)))
(filter #(= nil (:in_reply_to_account_id %)))
(take 4)
(masto->html2)
(masto->html)
(render-html)
(b/render-to-document)))))
@ -164,10 +139,10 @@
(defn account-mode-debug [host-url account-name]
(go
(let [account-id (<! (find-account-id host-url account-name))
statuus (->
status (->
(<p! (api/get-account-statuses host-url account-id))
api/mastojs->edn)]
(->> statuus
(->> status
(filter #(= nil (:reblog %)))
(filter #(= nil (:in_reply_to_account_id %)))
(take 1)

View file

@ -20,6 +20,7 @@
[dda.masto-embed.account-mode :as sut]
[dda.masto-embed.hiccs :as hic]
[hickory.core :as h]
[hickory.convert :as hc]
[shadow.resource :as rc]))
(def media_attachments
@ -200,14 +201,15 @@
:created_at "2020-05-17T10:12:10.403Z"
:spoiler_text ""}])
(deftest test-mastodon->html
(is (= [:ul {:class "list-group"}
'([:li {:class "list-group-item, card"}
[:div {:class "card-body"}
[:h2 {:class "card-title"} [:a {:href "https://social.meissa-gmbh.de/users/team/statuses/104183256213204298/activity"} "2020-05-17" " " "10:12:10"]]
[:p {:class "card-text"} "<p>We&apos;ve a new asciicast ... </p>"
nil]]])]
(sut/masto->html statuses))))
; TODO: Replace this test
;(deftest test-mastodon->html
; (is (= [:ul {:class "list-group"}
; '([:li {:class "list-group-item, card"}
; [:div {:class "card-body"}
; [:h2 {:class "card-title"} [:a {:href "https://social.meissa-gmbh.de/users/team/statuses/104183256213204298/activity"} "2020-05-17" " " "10:12:10"]]
; [:p {:class "card-text"} "<p>We&apos;ve a new asciicast ... </p>"
; nil]]])]
; (sut/masto->html statuses))))
(deftest test-masto-media->html
(is (= hic/post-with-img
@ -221,32 +223,3 @@
(is (= hic/filled-post-with-prev
(sut/masto-link-prev->html hic/post-base-prev link_prev))))
(deftest empty-card-should-produce-empty-result
(is (= nil
(sut/mastocard->html nil))))
(def link-card {:description "A comprehensive free SSL test for your public web servers.",
:author_url "", :width 0, :type "link", :embed_url "",
:title "SSL Server Test (Powered by Qualys SSL Labs)",
:provider_name "", :url "https://www.ssllabs.com/ssltest/",
:author_name "", :image nil, :provider_url "", :height 0, :html ""})
(deftest link-card-should-show-desc-and-link
(is (= [:div {:class "card", :url "https://www.ssllabs.com/ssltest/"} nil
[:h3 {:class "card-title"} "SSL Server Test (Powered by Qualys SSL Labs)"]
[:p {:class "card-body"} "A comprehensive free SSL test for your public web servers."]]
(sut/mastocard->html link-card))))
(def link-card-with-image
{:description "Cryogen's core. Contribute to DomainDrivenArchitecture/cryogen-core development by creating an account on GitHub.", :author_url "", :width 400, :type "link", :embed_url "",
:title "DomainDrivenArchitecture/cryogen-core", :provider_name "",
:url "https://github.com/DomainDrivenArchitecture/cryogen-core", :author_name "",
:image "https://cf.mastohost.com/v1/AUTH_91eb37814936490c95da7b85993cc2ff/socialmeissagmbhde/cache/preview_cards/images/000/017/635/original/5634071238f1f91f.png",
:provider_url "", :height 400, :html ""})
(deftest link-card-should-show-image-and-desc-and-link
(is (= [:div {:class "card", :url "https://github.com/DomainDrivenArchitecture/cryogen-core"}
[:img {:class "card-img-top", :src "https://cf.mastohost.com/v1/AUTH_91eb37814936490c95da7b85993cc2ff/socialmeissagmbhde/cache/preview_cards/images/000/017/635/original/5634071238f1f91f.png"}]
[:h3 {:class "card-title"} "DomainDrivenArchitecture/cryogen-core"]
[:p {:class "card-body"} "Cryogen's core. Contribute to DomainDrivenArchitecture/cryogen-core development by creating an account on GitHub."]]
(sut/mastocard->html link-card-with-image))))