Changeset 221a209 in Klonkt for src/services/CircleFederation.js


Ignore:
Timestamp:
06/16/2026 08:52:32 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
2248cd2
Parents:
fb02cc0
Message:

Circle: carry over + display tags from the original post

Publisher puts tags as AS Hashtag array in the outbox (href pointing to the
source tag page). Consumer parses + caches them (remote_posts.tags). Feed
cards display them (post-card), and the reader shows tag chips that link to
the /tag page of the source.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/CircleFederation.js

    rfb02cc0 r221a209  
    8585}
    8686
     87// Tags-kolom (JSON-array of comma-separated) -> nette string-array.
     88function parseTags(raw) {
     89  if (!raw) return [];
     90  if (Array.isArray(raw)) return raw.map((t) => String(t).trim()).filter(Boolean);
     91  try { const j = JSON.parse(raw); if (Array.isArray(j)) return j.map((t) => String(t).trim()).filter(Boolean); } catch { /* geen JSON */ }
     92  return String(raw).split(',').map((t) => t.trim()).filter(Boolean);
     93}
     94
    8795function iso(d) {
    8896  const t = d ? new Date(d) : new Date();
     
    136144
    137145  const rows = db.prepare(`
    138     SELECT slug, title, excerpt, content, cover_image_url, published_at, created_at, type
     146    SELECT slug, title, excerpt, content, cover_image_url, published_at, created_at, type, tags
    139147    FROM posts
    140148    WHERE site_id = ? AND status = 'published'
     
    148156    const published = iso(p.published_at || p.created_at);
    149157    const summary = (p.excerpt || stripHtml(p.content)).slice(0, 500);
     158    const tags = parseTags(p.tags).slice(0, 12);
    150159    return {
    151160      type: 'Create',
     
    161170        published,
    162171        ...(p.cover_image_url ? { image: { type: 'Image', url: abs(base, p.cover_image_url) } } : {}),
     172        // ActivityStreams: tags als Hashtag-objecten (href naar de bron-tagpagina).
     173        ...(tags.length ? { tag: tags.map((t) => ({ type: 'Hashtag', name: '#' + String(t).replace(/^#/, ''), href: `${base}/tag/${encodeURIComponent(t)}` })) } : {}),
    163174      },
    164175    };
Note: See TracChangeset for help on using the changeset viewer.