Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 77f2a12f95df366ff89ce06abbbe1049d9c09e2c
parent 18c4a22f96a70e0577bf5f8e48e1afc48a3c8c9d
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Fri,  6 Nov 2026 01:32:51 -0500

umtool: a post item's excerpt -- a long post read in part, the whole post shown

A post item's read was never an excerpt (post-narration.mjs), so each of
MadamSavvy's long posts read ~40 s and her 11-04 post was left out of rev 9.

`excerpt` on a post item: one or more VERBATIM spans of its words (1–8),
each found in the text after the one before it (post-item.mjs excerptErrors;
refused in the build's words otherwise). What is read is the spans joined
with " … " (postReadText): `posts narrate --all --draft-scripts` drafts from
it, `posts set-item` redrafts a narrated item's script when the excerpt is
set or cleared (so the next `posts narrate <p> <item> --take` reads it), and
an un-narrated card's reading time counts its words.

The card shows the WHOLE post with the words the excerpt does not read
dimmed (38 %, `data-post-cut`) -- chosen over the spans with "…" between
them because it never hides that text was cut, and the viewer sees what
was skipped.

Writer: `umtool posts set-item <p> <item> excerpt='["…","…"]'` (`excerpt=off`),
through updatePostItem; knobs.md's post item table. Still:
shots/excerpt-card-savvy.png (her 23 Oct post, two spans read).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/docs/knobs.md | 1+
Mumtool/lib/report/manifest.mjs | 17+++++++++++++----
Aumtool/lib/report/postExcerpt.test.mjs | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mumtool/lib/report/postNarrationCli.mjs | 7++++---
Mumtool/lib/report/postsCli.mjs | 15+++++++++++++++
Mumtool/report-to-video/post-item.mjs | 93++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Mumtool/report-to-video/post-narration.mjs | 9+++++----
7 files changed, 213 insertions(+), 16 deletions(-)

diff --git a/umtool/docs/knobs.md b/umtool/docs/knobs.md @@ -708,6 +708,7 @@ background jumped at the cut. A segment built full range before the pin is rebui |---|---|---|---| | `hold` — the item's whole length in seconds (1–120; absent: the pacing rule, the item is its read) | post bench, **hold** | `umtool posts set-item <p> <item> hold=12` (`hold=off`) | `POST /api/report/post-item {project, op: "set", id, patch: {hold}, token}` | | `mediaLayout` — `grid`: its 2-4 images at once (one picture of the read); absent: one after another, cycling | post bench, **images** | `layout=grid` (`layout=sequence`) | same, `patch: {mediaLayout}` | +| `excerpt` — a long post READ IN PART: one or more verbatim spans of its words (1–8, each found in the text after the one before it; refused otherwise). The read is the spans joined with " … " (a narrated item's script is redrafted from it when it is set or cleared, so the next `posts narrate <p> <item> --take` reads it; `posts narrate --all --draft-scripts` drafts from it; an un-narrated item's reading time counts its words); the card still shows the WHOLE post, the words it does not read dimmed (`.xcut`, 38 %) -- it never hides that text was cut. Absent: the whole post | -- | `umtool posts set-item <p> <item> excerpt='["I bought your shitty coffee.","I look forward to you felting me"]'` (`excerpt=off`) | same, `patch: {excerpt}` | | `redact` — other authors (the posts it answers, the one it quotes, a repost's original): absent, the privacy rule (blurred unless a subject or gold/grey verified); `false` shows them (judged public); `true` blurs even the verified | post bench, **other authors** | `redact=off` · `redact=on` · `redact=auto` | same, `patch: {redact}` | | `quoted.paraphrase`, `parents[i].paraphrase` — your short retelling (≤ 600 characters) of a long context post (the post it quotes, the posts it answers, nearest first): the card (render, Play, the bench, the recording page) draws it in place of that post's words, in the same style, with a small **paraphrased** label beside its date; its read counts the paraphrase's words; the author stays under the blur rule; its `text` is never touched. Absent or empty: its own words | post bench, the context block's **Paraphrase** (its words shown above it; **clear**), then **Save** | `quoted.paraphrase="He reviewed three of the videos."` · `parent.0.paraphrase="…"` (`=off`) | same, `patch: {quoted: {paraphrase}, parents: {"0": {paraphrase}}}` | | `media[i].start`, `media[i].end` — a video's or a GIF's in and out, its own seconds (at least 0.5 s apart) | post bench, **in / out**, **In at playhead**, **Out at playhead**, **Whole**; or the attachment's LANE (one per video or GIF, under the player): its whole length as a waveform (a flat line for a GIF or a silent video), the in and out its two handles (drag one, or click near it; never closer than 0.5 s, never past the file), the part the item plays dashed, the playhead; the bench's clock follows a moving edge, so the player shows its frame. Focused: `[` `]` the in, `,` `.` the out (0.05 s; Shift 0.5 s), `←` `→` the edge last moved (0.1 s; Shift 1 s). The number fields follow at once; **Save** writes them (the take's patch on `?inTake=<t>`) | `media.0.start=1.5 media.0.end=6` · `media.0.trim=off` | same, `patch: {media: {"0": {start, end}}}` | diff --git a/umtool/lib/report/manifest.mjs b/umtool/lib/report/manifest.mjs @@ -59,12 +59,12 @@ import { variantsProblems, verdictOfInput, } from "./knobs.mjs"; import { validateNarration } from "umtool-report-to-video/narration"; -import { validatePostItem, validatePostItems } from "umtool-report-to-video/post-item"; +import { postReadText, validatePostItem, validatePostItems } from "umtool-report-to-video/post-item"; import { threadReadErrors } from "umtool-report-to-video/post-thread"; import { planContext } from "umtool-report-to-video/post-conversation"; import { followKnobs } from "umtool-report-to-video/read-follow"; import { AVATARS_DIR, avatarEntryOf, handleKey, validatePostAvatars } from "umtool-report-to-video/post-avatars"; -import { POST_NARRATION_DEFAULTS, validatePostNarrationRender } from "umtool-report-to-video/post-narration"; +import { POST_NARRATION_DEFAULTS, draftScript, validatePostNarrationRender } from "umtool-report-to-video/post-narration"; import { termWords, validatePostsRender } from "umtool-report-to-video/post-redact"; import { parseMuteFrom } from "./playback.mjs"; import { isMeasureLedger, ledgerRowOf, ledgerRowReferences } from "./ledgerRows.mjs"; @@ -2480,7 +2480,7 @@ export async function insertEntries(dir, afterId, specs, { token = null, op = "i } /** The knobs of a post item a write may set (post-item.mjs; knobs.md, "A post item"). */ -export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "panel", "redact", "follow", "thread", "scene", "progress", "pictureOnly"]); +export const POST_ITEM_KNOBS = Object.freeze(["hold", "mediaLayout", "panel", "redact", "follow", "thread", "scene", "progress", "pictureOnly", "excerpt"]); /** A post item attachment's knobs: its trim, its sound, its crop, the push-in, its transcript, its censoring blur. */ export const POST_MEDIA_KNOBS = Object.freeze(["start", "end", "mute", "crop", "push", "words", "blur", "enter"]); /** A context post's knobs (`quoted`, `parents[i]`): the operator's paraphrase of its words. */ @@ -2493,7 +2493,7 @@ const POST_REF_FIELDS = Object.freeze(["id", "author", "handle", "badge", "date" * is `{ hold?, mediaLayout?, redact?, scene?: false | "join", follow?: false | { on?, dim?, ease? }, thread?: { parent?, quoted?, carry?, * reveal?, shrink?, dim?, seconds?, pan? }, media?: { <i>: { start?, end?, mute?, * crop?, push?, words?, blur? } }, quoted?: { paraphrase? }, parents?: { <i>: - * { paraphrase? } } }`; a null clears a knob (the default again), and so + * { paraphrase? } }, excerpt?: [span…] | null }`; a null clears a knob (the default again), and so * does an empty paraphrase (the context's own words again; its `text` is * never touched). One structural write, refused in the build's words * (validatePostItem). @@ -2648,6 +2648,15 @@ export async function updatePostItem(dir, id, patch, { token = null } = {}) { if (patch.links !== undefined) patchRefs("links", patch.links); const errors = validatePostItem(e); if (errors.length) throw new StructureRefused(errors); + // THE EXCERPT (post-item.mjs): a narrated item's script is redrafted from what is now read -- the spans joined, + // or the whole post again -- so the next take (`posts narrate --take`) reads it; its takes of the old script + // are kept (a take whose script is not the item's is not the one that plays until it is re-taken). + if ("excerpt" in patch && isObj(e.narration)) { + const d = draftScript(postReadText(e)); + if (d.script) e.narration.script = d.script; + if (e.excerpt) e.narration.excerpt = true; + else delete e.narration.excerpt; + } // NEVER NARRATE HIDDEN TEXT (post-thread.mjs): a change to what the card shows that leaves a part of its read // off the screen is refused, with the fix (one it had before is the guard's, not this write's). if ("thread" in patch || "follow" in patch || "parents" in patch || "links" in patch || "linksAdd" in patch) { diff --git a/umtool/lib/report/postExcerpt.test.mjs b/umtool/lib/report/postExcerpt.test.mjs @@ -0,0 +1,87 @@ +// A post item's EXCERPT (post-item.mjs; rev 9, 6 Nov): a long post read in part -- verbatim spans of its words, in +// order -- the read the spans joined with " … ", the card the whole post with the unread words dimmed. Its writer +// (`umtool posts set-item <p> <item> excerpt='[…]'`) and its script (`posts narrate --all --draft-scripts`). +// Made-up posts only. +import assert from "node:assert/strict"; +import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import path from "node:path"; +import { after, test } from "node:test"; +import { postsCommand } from "./postsCli.mjs"; +import { + excerptCutWords, excerptErrors, excerptRanges, postCardHtml, postReadText, readSeconds, validatePostItem, +} from "umtool-report-to-video/post-item"; + +const ROOT = await mkdtemp(path.join(tmpdir(), "umtool-post-excerpt-")); +after(() => rm(ROOT, { recursive: true, force: true })); +const REPORTS = path.join(ROOT, "reports"); +const TEXT = "I bought your coffee. You have my name and my address. Also a long aside about scrubs nobody needs. I look forward to the video."; +const item = (o = {}) => ({ type: "post", id: "p-1", post: "savvy-x/1", platform: "x", author: "A Person", handle: "aperson", date: "2026-10-23T10:00:00.000Z", text: TEXT, ...o }); +const cli = async (args) => { + const lines = []; + const errs = []; + const code = await postsCommand(args, { root: REPORTS, out: (s) => lines.push(s), err: (s) => errs.push(s) }); + return { code, out: lines.join("\n"), err: errs.join("\n") }; +}; +async function project(name, timeline) { + const dir = path.join(REPORTS, name); + await mkdir(dir, { recursive: true }); + await writeFile(path.join(dir, "video.manifest.json"), JSON.stringify({ + schemaVersion: 1, slug: name, title: name, provenance: { siteOrigin: "", channelSlug: "savvy-x" }, + render: { width: 1920, height: 1080, fps: 30 }, timeline, + }, null, 2)); + return { id: name, dir }; +} +const manifest = async (p) => JSON.parse(await readFile(path.join(p.dir, "video.manifest.json"), "utf8")); + +test("the excerpt: spans found in order, the read joined with \" … \", the unread words dimmed on the whole card", () => { + const e = item({ excerpt: ["I bought your coffee.", "I look forward to the video."] }); + assert.deepEqual(validatePostItem(e), []); + assert.deepEqual(excerptRanges(TEXT, e.excerpt), [{ start: 0, end: 21 }, { start: TEXT.indexOf("I look"), end: TEXT.length }]); + assert.equal(postReadText(e), "I bought your coffee. … I look forward to the video."); + assert.ok(readSeconds(e) < readSeconds(item()), "it reads in less time than the whole post"); + const cut = excerptCutWords(e); + assert.ok(cut.has(4) && !cut.has(0) && !cut.has(3), "words 0-3 read; 4 on dimmed"); + const html = postCardHtml(e, { width: 1248, height: 702 }); + assert.match(html, /data-post-cut=""/); + for (const w of ["scrubs", "address", "coffee", "video"]) assert.ok(html.includes(w), `the card shows "${w}" (the whole post)`); + assert.equal(postCardHtml(item(), { width: 1248, height: 702 }).includes("data-post-cut"), false, "no excerpt: nothing dimmed"); + // Refused: a span not in the text, spans out of order, an empty list. + assert.match(excerptErrors(item({ excerpt: ["I bought your tea."] }))[0], /is not in the post's words \(an excerpt is verbatim\)/); + assert.match(excerptErrors(item({ excerpt: ["I look forward", "I bought"] }))[0], /before the span ahead of it/); + assert.match(excerptErrors(item({ excerpt: [] }))[0], /must be a list of the post's own words/); +}); + +test("posts set-item excerpt='[…]': written through the item writer, the narrated script redrafted from it; excerpt=off reads the whole post again", async () => { + const p = await project("x", [item({ narration: { script: "I bought your coffee. You have my name and my address. Also a long aside about scrubs nobody needs. I look forward to the video." } })]); + let r = await cli(["set-item", "x", "p-1", `excerpt=["I bought your coffee.","I look forward to the video."]`]); + assert.equal(r.code, 0, r.err); + let e = (await manifest(p)).timeline[0]; + assert.deepEqual(e.excerpt, ["I bought your coffee.", "I look forward to the video."]); + assert.equal(e.narration.script, "I bought your coffee. … I look forward to the video."); + assert.equal(e.narration.excerpt, true); + assert.equal(e.text, TEXT, "the post's words are never rewritten"); + // A span that is not verbatim is refused in the build's words; the manifest untouched. + r = await cli(["set-item", "x", "p-1", `excerpt=["I bought your tea."]`]); + assert.notEqual(r.code, 0); + assert.match(r.err + r.out, /not in the post's words/); + assert.deepEqual((await manifest(p)).timeline[0].excerpt, ["I bought your coffee.", "I look forward to the video."]); + r = await cli(["set-item", "x", "p-1", "excerpt=nope"]); + assert.notEqual(r.code, 0); + assert.match(r.err + r.out, /JSON list/); + r = await cli(["set-item", "x", "p-1", "excerpt=off"]); + assert.equal(r.code, 0, r.err); + e = (await manifest(p)).timeline[0]; + assert.equal(e.excerpt, undefined); + assert.equal(e.narration.excerpt, undefined); + assert.match(e.narration.script, /scrubs nobody needs/); +}); + +test("posts narrate --all --draft-scripts drafts an excerpted item from its spans", async () => { + const p = await project("d", [item({ excerpt: ["I bought your coffee.", "I look forward to the video."] })]); + const r = await cli(["narrate", "d", "--all", "--draft-scripts"]); + assert.equal(r.code, 0, r.err); + const e = (await manifest(p)).timeline[0]; + assert.equal(e.narration.script, "I bought your coffee. … I look forward to the video."); + assert.equal(e.narration.excerpt, true); +}); diff --git a/umtool/lib/report/postNarrationCli.mjs b/umtool/lib/report/postNarrationCli.mjs @@ -26,7 +26,7 @@ import { promisify } from "node:util"; import { NARRATION_INDEX, POST_DERIVE_OPS, POST_DERIVE_ROUTES, derivedFileOf, draftScript, takeIdOf, isNarrated, nextTakeNumber, pickedTake, postIdOf, postNarrationKnobs, takeFileOf, takesDirOf, } from "umtool-report-to-video/post-narration"; -import { postItemPlan } from "umtool-report-to-video/post-item"; +import { excerptSpansOf, postItemPlan, postReadText } from "umtool-report-to-video/post-item"; import { partRoles } from "umtool-report-to-video/post-thread"; import { spokenRead } from "umtool-report-to-video/post-redact"; import { projectRedaction } from "./postRedaction.mjs"; @@ -427,9 +427,10 @@ export async function narrateCommand(project, words, flags, { json = false, dryR const patches = []; for (const e of tl) { if (!force && typeof e.narration?.script === "string" && e.narration.script) continue; - const d = draftScript(e.text); + // What is read: its excerpt's spans (post-item.mjs postReadText), else the whole post. + const d = draftScript(postReadText(e)); if (!d.script) continue; - patches.push({ id: e.id, patch: { script: d.script, excerpt: null } }); + patches.push({ id: e.id, patch: { script: d.script, excerpt: excerptSpansOf(e) ? true : null } }); } if (dryRun || !patches.length) { out(json ? JSON.stringify({ ok: true, dryRun, patches }, null, 2) : `${dryRun ? "would draft" : "nothing to draft:"} ${patches.length} script(s)${patches.length ? "" : " (every post item has one; --force redrafts them)"}`); diff --git a/umtool/lib/report/postsCli.mjs b/umtool/lib/report/postsCli.mjs @@ -103,6 +103,7 @@ export const POSTS_USAGE = [ " the channels merged in time order, de-duplicated by post id; a post already in the cut is skipped, so a re-run", " adds only what is new -- in ONE write (one undo point), at the end unless --after.", " umtool posts set-item <project> <item> [hold=<s>|off] [layout=sequence|grid] [redact=on|off|auto] [scene=off|join|auto] [follow=on|off|auto] [follow.dim=<0.2-1>] [follow.ease=<s>]", + " [excerpt='[\"<span>\", …]'|off] read only these verbatim spans (in the post's order, joined \" … \"); the card shows the whole post, the rest dimmed", " [thread.parent[.<i>]=auto|full|excerpt|context|carry|hidden] [thread.quoted=auto|full|excerpt|context|hidden]", " [thread.carry=auto|on|off] [thread.reveal=on|off] [thread.shrink=<0.3-1>] [thread.dim=<0.15-1>]", " [thread.seconds=<0-3>] [thread.pan=<0.1-3>] [thread=auto]", @@ -939,6 +940,20 @@ export function postItemPatchOf(pairs) { const raw = pair.slice(eq + 1); const v = raw.toLowerCase(); if (k === "hold") out.hold = OFF.has(v) || v === "" ? null : Number(raw); + // Its EXCERPT (post-item.mjs): excerpt='["span", "span"]' -- verbatim spans of the post, in order -- or off. + else if (k === "excerpt") { + if (OFF.has(v) || v === "") out.excerpt = null; + else { + let spans; + try { + spans = JSON.parse(raw); + } catch { + throw new CliError(`excerpt= takes a JSON list of the post's own words, e.g. excerpt='["I bought your shitty coffee.","I look forward to you felting me"]' (or off)`); + } + if (!Array.isArray(spans) || !spans.every((x) => typeof x === "string")) throw new CliError("excerpt= takes a JSON list of strings (verbatim spans of the post, in order)"); + out.excerpt = spans; + } + } else if (k === "layout") out.mediaLayout = v === "sequence" ? null : v; else if (k === "redact") out.redact = v === "auto" || v === "" ? null : onOff(v, k); // Its progress bar (post-progress.mjs): on, off or auto (60 s of read or more); default: the cut's. diff --git a/umtool/report-to-video/post-item.mjs b/umtool/report-to-video/post-item.mjs @@ -129,9 +129,87 @@ export const ownPictureOnly = (entry) => isPictureOnly(entry, { text: cardText(e /** Whether a context post (a parent, the quoted post) is picture-only (post-picture.mjs). */ export const refPictureOnly = (ref) => isPictureOnly(ref); -/** Seconds to read the post itself (the rule above, its first line). */ +// --------------------------------------------------------------------------- +// THE EXCERPT (rev 9, 6 Nov): a long post read in part. `entry.excerpt` is one +// or more VERBATIM spans of the post's words, in order; the read (the +// narration script drafted for it, an un-narrated card's reading time) is +// those spans joined with " … ", and the card still shows the WHOLE post -- +// the spans read lit, the rest dimmed -- so it never hides that text was cut. +// --------------------------------------------------------------------------- + +/** The excerpt's join: what stands between two spans in the read. */ +export const POST_EXCERPT_JOIN = " … "; +/** At most this many spans. */ +export const POST_EXCERPT_MAX = 8; + +/** The excerpt's spans (`entry.excerpt`, the strings), or null when it has none. */ +export const excerptSpansOf = (entry) => (Array.isArray(entry?.excerpt) && entry.excerpt.length && entry.excerpt.every((x) => typeof x === "string" && x.trim()) ? entry.excerpt : null); + +/** + * Where each span stands in `text`, in order -- `[{ start, end }]` (character + * offsets; each found at or after the end of the one before) -- or null when a + * span is not in the text there. + */ +export function excerptRanges(text, spans) { + const t = str(text); + const out = []; + let from = 0; + for (const sp of spans) { + const at = t.indexOf(sp, from); + if (at < 0) return null; + out.push({ start: at, end: at + sp.length }); + from = at + sp.length; + } + return out; +} + +/** What is READ of a post: its excerpt's spans joined with " … ", else the card's words whole. */ +export function postReadText(entry) { + const spans = excerptSpansOf(entry); + return spans && excerptRanges(cardText(entry), spans) ? spans.map((x) => x.trim()).join(POST_EXCERPT_JOIN) : cardText(entry); +} + +/** The card's word indices (cardTokens') that the excerpt does NOT read (drawn dimmed), or null with no excerpt. */ +export function excerptCutWords(entry) { + const spans = excerptSpansOf(entry); + const text = cardText(entry); + const ranges = spans ? excerptRanges(text, spans) : null; + if (!ranges) return null; + const cut = new Set(); + let at = 0; + for (const t of cardTokens(text)) { + const len = (t.space ?? t.tok).length; + if (t.tok !== undefined && !ranges.some((r) => at < r.end && at + len > r.start)) cut.add(t.i); + at += len; + } + return cut; +} + +/** Every reason `entry.excerpt` cannot be read (empty: it can). */ +export function excerptErrors(entry, where = `timeline ${entry?.id ?? "?"}.excerpt`) { + const x = entry?.excerpt; + if (x === undefined) return []; + if (!Array.isArray(x) || !x.length) return [`${where} must be a list of the post's own words to read (one or more spans)`]; + if (x.length > POST_EXCERPT_MAX) return [`${where}: at most ${POST_EXCERPT_MAX} spans`]; + const errors = []; + x.forEach((sp, i) => { if (typeof sp !== "string" || !sp.trim()) errors.push(`${where}[${i}] must be words of the post`); }); + if (errors.length) return errors; + const text = cardText(entry); + let from = 0; + x.forEach((sp, i) => { + const at = str(text).indexOf(sp, from); + if (at < 0) { + errors.push(str(text).includes(sp) + ? `${where}[${i}] "${sp.slice(0, 40)}" is in the post, but before the span ahead of it (the spans go in the post's order)` + : `${where}[${i}] "${sp.slice(0, 40)}" is not in the post's words (an excerpt is verbatim)`); + } else from = at + sp.length; + }); + return errors; +} + +/** Seconds to read the post itself (the rule above, its first line): its excerpt when it has one. */ export function readSeconds(entry) { - return clamp(POST_READ.lead + wordCount(cardText(entry)) / POST_READ.wps, POST_READ.min, POST_READ.max); + return clamp(POST_READ.lead + wordCount(postReadText(entry)) / POST_READ.wps, POST_READ.min, POST_READ.max); } /** Whether a context post (a parent, the quoted post) is drawn as the operator's paraphrase. */ @@ -573,6 +651,7 @@ export function validatePostItem(e) { if (!POST_ITEM_PLATFORMS.includes(e.platform)) errors.push(`${w}.platform must be one of ${POST_ITEM_PLATFORMS.join(", ")}`); if (typeof e.text !== "string") errors.push(`${w}.text must be the post's words (a string; "" for none)`); else if (e.text.length > TEXT_MAX) errors.push(`${w}.text is longer than ${TEXT_MAX} characters`); + if (typeof e.text === "string") errors.push(...excerptErrors(e, `${w}.excerpt`)); if (e.author !== undefined && typeof e.author !== "string") errors.push(`${w}.author must be a string`); if (e.handle !== undefined && (typeof e.handle !== "string" || !HANDLE_RE.test(e.handle))) errors.push(`${w}.handle must be a handle`); if (typeof e.date !== "string" || Number.isNaN(Date.parse(e.date))) errors.push(`${w}.date must be the post's date (ISO)`); @@ -997,7 +1076,7 @@ export const hueOf = (s) => { * and Play zooms toward it; `hl` (`{ from, to }`) marks those words' * spans `data-w-hl` (the zoom's highlight is drawn under them). */ -export function wordsHtml(text, blurred, scope = null, hl = null, blocks = null) { +export function wordsHtml(text, blurred, scope = null, hl = null, blocks = null, cut = null) { const set = new Set(blurred.map((h) => h.replace(/^@/, "").toLowerCase())); const word = (t) => esc(t) @@ -1016,7 +1095,8 @@ export function wordsHtml(text, blurred, scope = null, hl = null, blocks = null) if (t.space !== undefined) return t.space.replace(/[^\n]+/g, " ").replace(/\n/g, "<br>"); const lit = hl && t.i >= hl.from && t.i <= hl.to; const open = opens.has(t.i) ? `<span class="fblock" data-post-block="${opens.get(t.i)}">` : ""; - return `${open}<span data-w="${esc(scope)}:${t.i}"${lit ? " data-w-hl=\"\"" : ""}>${word(t.tok)}</span>${closes.has(t.i) ? "</span>" : ""}`; + // `cut` (excerptCutWords): a word the excerpt does not read, drawn dimmed. + return `${open}<span data-w="${esc(scope)}:${t.i}"${lit ? " data-w-hl=\"\"" : ""}${cut?.has(t.i) ? ' class="xcut" data-post-cut=""' : ""}>${word(t.tok)}</span>${closes.has(t.i) ? "</span>" : ""}`; }) .join(""); } @@ -1202,7 +1282,9 @@ export function postCardHtml(entry, { width, height, palette = {}, fonts = {}, p : ""; const head = `<div class="head"${ownRed ? ' data-redacted=""' : ""}>${avatarHtml(own, { redact: ownRed, size: Math.round(64 * k), accent: ownRed ? undefined : pal.accent, img: pic(own) })}<div class="hwho">${nameHtml(own, { redact: ownRed, cls: "big" })}<div class="date">${esc(cardDate(entry.date))}</div></div><div class="mark">${esc(PLATFORM_NAME[entry.platform] ?? "")}</div></div>`; // A card alone (text, or a stack's reading) is as tall as its words, centred in its box; beside the attachments, the box's height. - const card = (box) => `<div class="card" data-post-card="${esc(entry.id)}" style="left:${box.x}px;${L.mode === "side" ? `top:${box.y}px;height:${box.height}px` : `top:${box.y + box.height / 2}px;transform:translateY(-50%);max-height:${box.height}px`};width:${box.width}px">${repost}${ctx.length ? `<div class="context">${ctx.join("")}</div>` : ""}${head}<div class="words${picOwn ? " pmen" : ""}" data-post-words="" style="font-size:${picOwn ? menSize : size}px">${follow ? `<div class="wflow" data-post-flow="">${wordsHtml(cardText(entry), blurred, "post", hlOf("post"), blk("post"))}</div><div class="wfade" data-post-fade="top"></div><div class="wfade" data-post-fade="bottom"></div>` : wordsHtml(cardText(entry), blurred, "post", hlOf("post"))}</div>${picOwn ? picIn("post", entry, L.card.width - 2 * L.pad, ownPicMax) : ""}${quoted}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div>`; + // The excerpt (excerptCutWords): the whole post drawn, the words it does not read dimmed. + const excerptCut = excerptCutWords(entry); + const card = (box) => `<div class="card" data-post-card="${esc(entry.id)}" style="left:${box.x}px;${L.mode === "side" ? `top:${box.y}px;height:${box.height}px` : `top:${box.y + box.height / 2}px;transform:translateY(-50%);max-height:${box.height}px`};width:${box.width}px">${repost}${ctx.length ? `<div class="context">${ctx.join("")}</div>` : ""}${head}<div class="words${picOwn ? " pmen" : ""}" data-post-words="" style="font-size:${picOwn ? menSize : size}px">${follow ? `<div class="wflow" data-post-flow="">${wordsHtml(cardText(entry), blurred, "post", hlOf("post"), blk("post"), excerptCut)}</div><div class="wfade" data-post-fade="top"></div><div class="wfade" data-post-fade="bottom"></div>` : wordsHtml(cardText(entry), blurred, "post", hlOf("post"), null, excerptCut)}</div>${picOwn ? picIn("post", entry, L.card.width - 2 * L.pad, ownPicMax) : ""}${quoted}${counts ? `<div class="counts" data-post-counts="">${counts}</div>` : ""}</div>`; const stripHtml = L.strip ? `<div class="strip" data-post-strip="" style="left:${L.strip.x}px;top:${L.strip.y}px;width:${L.strip.width}px;height:${L.strip.height}px">${avatarHtml(own, { redact: ownRed, size: Math.round(56 * k), accent: ownRed ? undefined : pal.accent, img: pic(own) })}<div class="hwho">${nameHtml(own, { redact: ownRed, cls: "big" })}<div class="date">${esc(cardDate(entry.date))}</div></div><div class="sline">${wordsHtml(cardText(entry).split("\n")[0].slice(0, 140) + (cardText(entry).length > 140 ? "…" : ""), blurred)}</div></div>` : ""; @@ -1355,6 +1437,7 @@ b, .name, .mark { font-family: 'PostSansBold', sans-serif; font-weight: 400; } .words { line-height: ${LINE}; overflow-wrap: anywhere; flex: 0 1 auto; min-height: 0; overflow: hidden; } .sline { margin-left: ${Math.round(12 * k)}px; color: ${pal.fg}; font-size: ${Math.round(24 * k)}px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; } .mention, .link { color: ${pal.accent}; } +.xcut { opacity: 0.38; } .context { display: flex; flex-direction: column; gap: ${Math.round(10 * k)}px; } .parent { display: flex; gap: ${Math.round(14 * k)}px; position: relative; padding-bottom: ${Math.round(6 * k)}px; } .parent::after { content: ""; position: absolute; left: ${Math.round(21 * k)}px; top: ${Math.round(50 * k)}px; bottom: -${Math.round(6 * k)}px; width: 2px; background: ${line}; } diff --git a/umtool/report-to-video/post-narration.mjs b/umtool/report-to-video/post-narration.mjs @@ -7,7 +7,7 @@ // // entry.narration = { // script: "what is read (Orpheus tags <sigh> <laugh> … allowed)", -// excerpt?: true, // drafted as an excerpt of a longer post +// excerpt?: true, // drafted from the item's `excerpt` (post-item.mjs: verbatim spans, " … "-joined) // engine?, voice?, speed?, // the next take's (default: render.postNarration's) // takes: [{ file: "narration/posts/<postId>/take-<n>.<engine>-<voice>.wav", // engine, voice, seconds, script, at, note?, speed?, lufs?, jobId?, @@ -157,7 +157,7 @@ export const POST_NARRATION_LIMITS = Object.freeze({ rate: [0.8, 1.5], /** A part's own tempo (a `tempo` step: the part time-stretched in the take's file, its pitch kept). */ tempo: [1, 1.6], - /** A script is the whole post read aloud (operator, 2 Nov: never excerpted); the editor's tts op takes 20,000. */ + /** A script is the whole post read aloud (operator, 2 Nov) -- or its `excerpt`'s spans (post-item.mjs, 6 Nov), the card showing the whole post; the editor's tts op takes 20,000. */ scriptChars: 20000, takes: 50, }); @@ -536,8 +536,9 @@ export function speakableText(text) { } /** - * A DRAFT SCRIPT from the post's words: the whole post (speakableText), never - * an excerpt. Emotion is the operator's to add (Orpheus's tags, <sigh> …). + * A DRAFT SCRIPT from the words it is given: the whole post (speakableText) -- + * or, from the CLI, its `excerpt`'s spans (post-item.mjs postReadText). Emotion + * is the operator's to add (Orpheus's tags, <sigh> …). * * @returns {{ script: string, words: number }} */