Changeset ea3e722 in Klonkt for src/services/ActivityPubService.js
- Timestamp:
- 08/09/2026 08:34:57 AM (4 weeks ago)
- Branches:
- main
- Children:
- 5ae4d61
- Parents:
- d60c498
- File:
-
- 1 edited
-
src/services/ActivityPubService.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/services/ActivityPubService.js
rd60c498 rea3e722 29 29 import Blocklist from './BlocklistService.js'; 30 30 import * as Guardianship from './guardianship/index.js'; 31 import { PUBLIC, AP_CONTEXT, safeUrl, actorId, noteId, guessMediaType, normalizeTags, tagParts } from './ap-core.js';31 import { PUBLIC, AP_CONTEXT, safeUrl, actorId, noteId, guessMediaType, normalizeTags, tagParts, hashtagTags, buildHashtagList } from './ap-core.js'; 32 32 // Doorgeven wat hier altijd vandaan kwam, zodat elke bestaande aanroep blijft werken. 33 33 export { AP_CONTEXT, actorId, noteId, guessMediaType }; … … 2960 2960 2961 2961 // Extract the AP Hashtag tag objects from already-linked reply content. 2962 function hashtagTags(base, content) {2963 const tags = [], seen = new Set();2964 const re = /class="[^"]*\bhashtag\b[^"]*"[^>]*>#([\p{L}\p{M}\p{N}_]+)</giu;2965 let m;2966 while ((m = re.exec(content || ''))) {2967 const k = m[1].toLowerCase();2968 if (seen.has(k)) continue; seen.add(k);2969 tags.push({ type: 'Hashtag', href: `${base}/tag/${encodeURIComponent(k)}`, name: '#' + m[1] });2970 }2971 return tags;2972 }2973 2962 2974 2963 // Normalise a post's tags field (array, JSON-string, or comma-string) to an array. … … 2980 2969 // Merge a post's tags field + the #hashtags linked inline in its body into one deduped 2981 2970 // Hashtag tag list (with hrefs to our /tag page). 2982 function buildHashtagList(base, tagsField, content) { 2983 const out = [], seen = new Set(); 2984 for (const t of normalizeTags(tagsField)) { 2985 const p = tagParts(t); if (!p || seen.has(p.slug)) continue; seen.add(p.slug); 2986 out.push({ type: 'Hashtag', href: `${base}/tag/${encodeURIComponent(p.slug)}`, name: '#' + p.label }); 2987 } 2988 for (const h of hashtagTags(base, content)) { 2989 const k = h.name.slice(1).toLowerCase(); if (seen.has(k)) continue; seen.add(k); 2990 out.push(h); 2991 } 2992 return out; 2993 } 2971 // hashtagTags en buildHashtagList staan sinds shaer-38y in ap-core: music/ 2972 // heeft dezelfde lijst nodig en mag hier niet uit importeren. 2994 2973 2995 2974 // Extract Mention tag objects from already-linked content (class="u-url mention").
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)