mirror of
https://github.com/svemagie/indiekit-endpoint-activitypub.git
synced 2026-04-02 15:44:58 +02:00
feat: content enhancements — URL shortening, hashtag collapse, bot badge, edit indicator (Release 7)
Shorten long URLs in post content (30 char display limit with tooltip). Collapse hashtag-heavy paragraphs into expandable <details> toggle. Show BOT badge for Service/Application actors. Show pencil icon for edited posts with hover tooltip showing edit timestamp. Confab-Link: http://localhost:8080/sessions/e9d666ac-3c90-4298-9e92-9ac9d142bc06
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
import { stripQuoteReferenceHtml } from "./og-unfurl.js";
|
||||
import { replaceCustomEmoji } from "./emoji-utils.js";
|
||||
import { shortenDisplayUrls, collapseHashtagStuffing } from "./content-utils.js";
|
||||
|
||||
/**
|
||||
* Post-process timeline items for rendering.
|
||||
@@ -31,7 +32,10 @@ export async function postProcessItems(items, options = {}) {
|
||||
// 3. Replace custom emoji shortcodes with <img> tags
|
||||
applyCustomEmoji(items);
|
||||
|
||||
// 4. Build interaction map (likes/boosts) — empty when no collection
|
||||
// 4. Shorten long URLs and collapse hashtag stuffing in content
|
||||
applyContentEnhancements(items);
|
||||
|
||||
// 5. Build interaction map (likes/boosts) — empty when no collection
|
||||
const interactionMap = options.interactionsCol
|
||||
? await buildInteractionMap(items, options.interactionsCol)
|
||||
: {};
|
||||
@@ -154,6 +158,24 @@ function applyCustomEmoji(items) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorten long URLs and collapse hashtag-heavy paragraphs in content.
|
||||
* Mutates items in place.
|
||||
*
|
||||
* @param {Array} items
|
||||
*/
|
||||
function applyContentEnhancements(items) {
|
||||
for (const item of items) {
|
||||
if (item.content?.html) {
|
||||
item.content.html = shortenDisplayUrls(item.content.html);
|
||||
item.content.html = collapseHashtagStuffing(item.content.html);
|
||||
}
|
||||
if (item.quote?.content?.html) {
|
||||
item.quote.content.html = shortenDisplayUrls(item.quote.content.html);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build interaction map (likes/boosts) for template rendering.
|
||||
* Returns { [uid]: { like: true, boost: true } }.
|
||||
|
||||
Reference in New Issue
Block a user