// XenForo captures (release 37 S3): a captured thread page → one // `forum-post` draft per post, read by THE forum parser // (social/xenforoParse.ts `parseXenforoThreadPage`, not a fork of it). The // item id is the bare post id — the id a live forum channel stores for the // same post (xenforoFetcher.ts hands the parser's posts straight to the // store) — and `forum` is the parser's own, so a capture's posts and a live // channel's posts of the same thread line up. A captured page that stands in // the thread's way (a login wall, a browser check, "not found") → one // whole-page draft with `noContent: true` saying which. import { classifyForumPage, parseXenforoThreadPage } from "../../../social/xenforoParse"; import type { PageExtractInput, PageExtractor, PageRecordDraft } from "../types"; import { unwrapWaybackHtml, unwrapWaybackUrl } from "./util"; const XF_MARKERS = [/data-template=["']?thread_view/i, /]*\bid=["']?XF\b/i, /class=["'][^"']*\bmessage--post\b/i]; export function extractXenforo(input: PageExtractInput): PageRecordDraft[] { const html = unwrapWaybackHtml(input.html); const page = parseXenforoThreadPage(html, { channelSlug: "page", pageUrl: input.capture.originalUrl }); const drafts: PageRecordDraft[] = []; for (const p of page.posts) { const draft: PageRecordDraft = { kind: "forum-post", itemId: p.id, url: p.url, author: p.author, publishedAt: p.createdAt, text: p.text, links: p.links.map(unwrapWaybackUrl), isReply: p.isReply, isRepost: p.isRepost, }; if (page.threadTitle) draft.title = page.threadTitle; if (p.authorName) draft.authorName = p.authorName; if (p.media) draft.media = p.media.map((m) => ({ ...m, url: unwrapWaybackUrl(m.url) })); if (p.replyTo) draft.replyTo = p.replyTo; if (p.quoted) draft.quoted = p.quoted; if (p.forum) draft.forum = p.forum; drafts.push(draft); } if (drafts.length > 0) return drafts; const block = classifyForumPage(html, input.capture.status); const WHY: Record = { login: " The forum asked for a login.", challenge: " It is a browser check, not the thread.", captcha: " It is a captcha page, not the thread.", blocked: " The forum refused the request.", "not-found": " The forum said the thread could not be found.", }; const what = (block && WHY[block.kind]) ?? ""; const draft: PageRecordDraft = { kind: "generic", text: `This capture holds no forum posts.${what}`, links: [], noContent: true, }; // A wall's own title ("Log in | Example Forum"); a thread page's when no wall. const title = block?.title ?? page.threadTitle; if (title) draft.title = title; return [draft]; } export const xenforoExtractor: PageExtractor = { name: "xenforo", version: 1, matches(_originalUrl, html) { return XF_MARKERS.some((re) => re.test(html)); }, extract: extractXenforo, };