This commit is contained in:
bom 2022-03-11 14:26:47 +01:00
parent 4c494e7d33
commit 2b1b032039
2 changed files with 27 additions and 16 deletions

View file

@ -38,20 +38,31 @@
[:h3 {:class "card-title"} title] [:h3 {:class "card-title"} title]
[:p {:class "card-body"} description]]))) [:p {:class "card-body"} description]])))
(defn mastomedia->html [media]
(when (some? media)
(let [{:keys [id type preview_url url]} (first media)]
[:div {:class "media"}
(when (and (some? type) (= type "image"))
[:img {:class "card-img-top float-right" :width "100" :height "100"
:src preview_url}])])))
(defn masto->html [statuses] (defn masto->html [statuses]
[:ul {:class "list-group"} [:ul {:class "list-group"}
(map (fn [status] (map (fn [status]
(let [{:keys [created_at card media_attachments]} status (let [{:keys [created_at card media_attachments]} status
date (t/parse created_at)] date (t/parse created_at)]
[:li {:class "list-group-item, card"} [:li {:class "list-group-item, card"}
[:div {:class "card-body"} [:div {:class "card-body row"}
[:div {:class "col-sm"}
[:h2 {:class "card-title"} [:h2 {:class "card-title"}
[:a {:href (get-in status [:url])} [:a {:href (get-in status [:url])}
(t/unparse (t/formatters :date) date) " " (t/unparse (t/formatters :date) date) " "
(t/unparse (t/formatters :hour-minute-second) date)]] (t/unparse (t/formatters :hour-minute-second) date)]]
[:div {:class "card-text"} [:div {:class "card-text"}
(:content status) (:content status)]]
(mastocard->html card media_attachments)]]])) [:div {:class "col-sm"} (mastomedia->html media_attachments)]]]))
statuses)]) statuses)])
(defn favorited-replies? [host-url account-name reply-id] (defn favorited-replies? [host-url account-name reply-id]

View file

@ -116,6 +116,6 @@
[:h2 {:class "card-title"} [:h2 {:class "card-title"}
[:a {:href "https://social.meissa-gmbh.de/@jerger/107937257700481042"} "2022-03-11" " " "09:44:07"]] [:a {:href "https://social.meissa-gmbh.de/@jerger/107937257700481042"} "2022-03-11" " " "09:44:07"]]
[:div {:class "card-text"} [:div {:class "card-text"}
"<p><span class=\"h-card\"><a href=\"https://social.meissa-gmbh.de/@team\" class=\"u-url mention\">@<span>team</span></a></span> Hier mein erstes Bild :-)</p>"] "<p><span class=\"h-card\"><a href=\"https://social.meissa-gmbh.de/@team\" class=\"u-url mention\">@<span>team</span></a></span> Hier mein erstes Bild :-)</p>"
]])] [:div {:class "media"} [:img {:class "card-img-top", :src "https://cdn.masto.host/socialmeissagmbhde/media_attachments/files/107/937/248/257/634/217/small/923e75c7684a2c31.jpg"}]]]]])]
(sut/masto->html statuses)))) (sut/masto->html statuses))))