From 2b1b0320397bd05aecccd5e5eaeef7a3d5544f7a Mon Sep 17 00:00:00 2001 From: bom Date: Fri, 11 Mar 2022 14:26:47 +0100 Subject: [PATCH] wip mob --- src/main/dda/masto_embed/reply_mode.cljs | 27 +++++++++++++------ src/test/dda/masto_embed/reply_mode_test.cljs | 16 +++++------ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/dda/masto_embed/reply_mode.cljs b/src/main/dda/masto_embed/reply_mode.cljs index 2ed9e8e..d5e9419 100644 --- a/src/main/dda/masto_embed/reply_mode.cljs +++ b/src/main/dda/masto_embed/reply_mode.cljs @@ -38,20 +38,31 @@ [:h3 {:class "card-title"} title] [: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] [:ul {:class "list-group"} (map (fn [status] (let [{:keys [created_at card media_attachments]} 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)]] - [:div {:class "card-text"} - (:content status) - (mastocard->html card media_attachments)]]])) + [:div {:class "card-body row"} + [:div {:class "col-sm"} + [:h2 {:class "card-title"} + [:a {:href (get-in status [:url])} + (t/unparse (t/formatters :date) date) " " + (t/unparse (t/formatters :hour-minute-second) date)]] + [:div {:class "card-text"} + (:content status)]] + [:div {:class "col-sm"} (mastomedia->html media_attachments)]]])) statuses)]) (defn favorited-replies? [host-url account-name reply-id] diff --git a/src/test/dda/masto_embed/reply_mode_test.cljs b/src/test/dda/masto_embed/reply_mode_test.cljs index 07e0271..4b2ca68 100644 --- a/src/test/dda/masto_embed/reply_mode_test.cljs +++ b/src/test/dda/masto_embed/reply_mode_test.cljs @@ -110,12 +110,12 @@ :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/@jerger/107937257700481042"} "2022-03-11" " " "09:44:07"]] - [:div {:class "card-text"} - "

@team Hier mein erstes Bild :-)

"] - ]])] + (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/@jerger/107937257700481042"} "2022-03-11" " " "09:44:07"]] + [:div {:class "card-text"} + "

@team Hier mein erstes Bild :-)

" + [: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))))