Truncate long titles

master
erik 4 weeks ago
parent 2a8171b9bb
commit f79529e0ea

@ -37,6 +37,8 @@
(defn insert [v i e] (vec (concat (subvec v 0 i) [e] (subvec v i))))
(defn truncate [s n] (subs s 0 (min (count s) n)))
(defn masto-header->html [html account created_at url]
(let [{:keys [username display_name avatar_static]} account
date (t/parse created_at)]
@ -88,7 +90,7 @@
(insert-link-prev)
(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_TITLE" (str (truncate title 47) "..."))
(cm/replace-all-matching-values-by-new-value "LINK_PREVIEW_DESC" description)))))
(defn masto-footer->html [html replies_count reblogs_count favourites_count]

@ -288,7 +288,7 @@
[:img {:class "mastodon-post-link-image", :src "https://cdn.masto.host/socialmeissagmbhde/cache/preview_cards/images/000/545/643/original/199336f5aa5b9683.png"}]
[:div
{:class "mastodon-post-link-info"}
[:h4 {:class "mastodon-post-link-title"} "forgejo/tests/integration/api_activitypub_repository_test.go at fe3473fc8b7b51e024b1a564fc7f01e385ebfb5e"]
[:h4 {:class "mastodon-post-link-title"} "forgejo/tests/integration/api_activitypub_repos..."]
[:div {:class "mastodon-post-link-description"} "forgejo - Beyond coding. We forge."]
[:div {:class "mastodon-post-link-url"} "https://codeberg.org//forgejo/forgejo/src/commit/fe3473fc8b7b51e024b1a564fc7f01e385ebfb5e/tests/integration/api_activitypub_repository_test.go"]]]
[:footer

Loading…
Cancel
Save