Add url to acc names

This commit is contained in:
erik 2024-05-16 14:47:00 +02:00
parent 52c4574a3b
commit a2265d6b42
2 changed files with 17 additions and 6 deletions

View file

@ -50,13 +50,14 @@
(mastocard->html card)]]])) (mastocard->html card)]]]))
statuses)]) statuses)])
(defn masto-header->html [html account created_at] (defn masto-header->html [html account created_at url]
(let [{:keys [username display_name avatar_static]} account (let [{:keys [username display_name avatar_static]} account
date (t/parse created_at)] date (t/parse created_at)]
(-> html (-> html
(cm/replace-all-matching-values-by-new-value "AVATAR_URL" avatar_static) (cm/replace-all-matching-values-by-new-value "AVATAR_URL" avatar_static)
(cm/replace-all-matching-values-by-new-value "POST_URL" url)
(cm/replace-all-matching-values-by-new-value "DISPLAY_NAME" display_name) (cm/replace-all-matching-values-by-new-value "DISPLAY_NAME" display_name)
(cm/replace-all-matching-values-by-new-value "ACCOUNT_NAME" username) (cm/replace-all-matching-values-by-new-value "ACCOUNT_NAME" (str "@" username))
(cm/replace-all-matching-values-by-new-value "DATETIME" created_at) (cm/replace-all-matching-values-by-new-value "DATETIME" created_at)
(cm/replace-all-matching-values-by-new-value "TIME" (t/unparse (t/formatter "EEEE, dd MMMM yyyy") date)) (cm/replace-all-matching-values-by-new-value "TIME" (t/unparse (t/formatter "EEEE, dd MMMM yyyy") date))
))) )))
@ -70,6 +71,15 @@
(-> html (-> html
(cm/replace-all-matching-values-by-new-value "POST_IMG_URL" media)))) (cm/replace-all-matching-values-by-new-value "POST_IMG_URL" media))))
(defn masto-link-prev->html [html card]
(let [{:keys [url image title description]} card]
(-> html
(cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_URL" url)
(cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_IMG_URL" image)
(cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_TITLE" title)
(cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_DESC" description)
)))
(defn masto-footer->html [html replies_count reblogs_count favourites_count] (defn masto-footer->html [html replies_count reblogs_count favourites_count]
(-> html (-> html
(cm/replace-all-matching-values-by-new-value "REPLIES_COUNT" replies_count) (cm/replace-all-matching-values-by-new-value "REPLIES_COUNT" replies_count)
@ -79,11 +89,12 @@
(defn masto->html2 [statuses] (defn masto->html2 [statuses]
(let [html (b/index-html-hiccup)] (let [html (b/index-html-hiccup)]
(map (fn [status] (map (fn [status]
(let [{:keys [account created_at content media_attachments replies_count reblogs_count favourites_count]} 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) (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-footer->html replies_count reblogs_count favourites_count)))) (masto-footer->html replies_count reblogs_count favourites_count))))
statuses))) statuses)))

View file

@ -3,8 +3,8 @@
<header class="mastodon-post-header"> <header class="mastodon-post-header">
<img class="mastodon-post-avatar" src="AVATAR_URL"></img> <img class="mastodon-post-avatar" src="AVATAR_URL"></img>
<div class="mastodon-post-names"> <div class="mastodon-post-names">
<a class="display-name">DISPLAY_NAME</a> <a class="display-name" href="POST_URL">DISPLAY_NAME</a>
<a class="account-name">ACCOUNT_NAME</a> <a class="account-name" href="POST_URL">ACCOUNT_NAME</a>
</div> </div>
<time class="mastodon-post-date" datetime="DATETIME">TIME</time> <time class="mastodon-post-date" datetime="DATETIME">TIME</time>
</header> </header>