jointakahe / takahe

An ActivityPub/Fediverse server
BSD 3-Clause "New" or "Revised" License
1.12k stars 86 forks source link

Prevent dropping ellipsis URL #585

Closed shuuji3 closed 1 year ago

shuuji3 commented 1 year ago

fixes #584

This issue seems to occur because Elk uses the textContent of the Mastodon HTML as a draft text (ref. 1, 2, 3, 4) and we are dropping the remaining URL string after 30 characters.

Here is an example content comparisons between Mastodon (first) and Takahē API (second):

-    "content": "<p>Takahē - return to the wild - <a href=\"https://www.youtube.com/watch?v=IG423K3pmQI\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><span class=\"invisible\">https://www.</span><span class=\"ellipsis\">youtube.com/watch?v=IG423K3pmQ</span><span class=\"invisible\">I</span></a></p>",
+    "content": "<p>Takahē - return to the wild - <a href=\"https://www.youtube.com/watch?v=IG423K3pmQI\" rel=\"nofollow\" class=\"ellipsis\" title=\"www.youtube.com/watch?v=IG423K\">www.youtube.com/watch?v=IG423K</a></p>",

To emulate Mastodon's link in content, this wraps the URL text with <span class="ellipsis"> and <span class="invisible">.

I kept the class="ellipsis" of the <a> tag untouched as I don't fully understand how it affects other parts of logic yet.

Screenshot 2023-05-24 at 21 55 54

https://takahe.shuuji3.xyz/@shuuji3@takahe.shuuji3.xyz/posts/184178424987558872/

Screenshot 2023-05-24 at 21 56 59 Screenshot 2023-05-24 at 21 58 06

https://elk.zone/takahe.shuuji3.xyz/@shuuji3/184178424987558872

andrewgodwin commented 1 year ago

Thanks for this - it was perhaps inevitable we'd have to match Mastodon here as well!