@anthusai/papyrus 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/amplify/functions/shared/python-bundle.js +3 -3
- package/amplify/functions/shared/python-bundle.ts +3 -3
- package/app/newsroom/sections/[sectionId]/page.tsx +3 -0
- package/components/news-desk-taxonomy-client.ts +36 -21
- package/components/newsroom-board-view.tsx +81 -32
- package/components/use-paged-content-item-versions.ts +151 -0
- package/lib/blog-feature-solver.ts +1 -109
- package/lib/content-item-lifecycle.ts +32 -5
- package/lib/local-preview-seed.ts +2 -4
- package/lib/newsroom-board.ts +44 -7
- package/lib/site-stack.ts +1 -1
- package/package.json +5 -1
- package/renderers/pretext/rhythm-article-page.tsx +1 -18
- package/routes.manifest.json +1 -1
|
@@ -126,9 +126,9 @@ function bundleFromPip(outputDir, options) {
|
|
|
126
126
|
}
|
|
127
127
|
export function bundleFromCheckout(outputDir, options) {
|
|
128
128
|
fs.copyFileSync(path.join(packageRoot, "amplify/functions", options.functionDir, "handler.py"), path.join(outputDir, "handler.py"));
|
|
129
|
-
for (const
|
|
130
|
-
fs.mkdirSync(path.join(outputDir,
|
|
131
|
-
fs.cpSync(path.join(packageRoot, "src",
|
|
129
|
+
for (const moduleName of options.modules) {
|
|
130
|
+
fs.mkdirSync(path.join(outputDir, moduleName), { recursive: true });
|
|
131
|
+
fs.cpSync(path.join(packageRoot, "src", moduleName), path.join(outputDir, moduleName), { recursive: true });
|
|
132
132
|
}
|
|
133
133
|
options.checkoutExtras?.(outputDir);
|
|
134
134
|
copySiteFiles(outputDir, options.siteFiles);
|
|
@@ -164,9 +164,9 @@ export function bundleFromCheckout(outputDir: string, options: PythonBundleOptio
|
|
|
164
164
|
path.join(packageRoot, "amplify/functions", options.functionDir, "handler.py"),
|
|
165
165
|
path.join(outputDir, "handler.py"),
|
|
166
166
|
);
|
|
167
|
-
for (const
|
|
168
|
-
fs.mkdirSync(path.join(outputDir,
|
|
169
|
-
fs.cpSync(path.join(packageRoot, "src",
|
|
167
|
+
for (const moduleName of options.modules) {
|
|
168
|
+
fs.mkdirSync(path.join(outputDir, moduleName), { recursive: true });
|
|
169
|
+
fs.cpSync(path.join(packageRoot, "src", moduleName), path.join(outputDir, moduleName), { recursive: true });
|
|
170
170
|
}
|
|
171
171
|
options.checkoutExtras?.(outputDir);
|
|
172
172
|
copySiteFiles(outputDir, options.siteFiles);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { notFound } from "next/navigation";
|
|
2
|
+
import { resolveActiveSiteBrand } from "../../../../lib/site-brand-tenant";
|
|
3
|
+
import { NewsroomBoardView } from "../../../../components/newsroom-board-view";
|
|
2
4
|
import { NewsDeskPage } from "../../../../components/news-desk-page";
|
|
3
5
|
|
|
4
6
|
export const dynamic = "force-dynamic";
|
|
@@ -13,5 +15,6 @@ export default async function NewsroomDeepSectionPage({ params, searchParams }:
|
|
|
13
15
|
const normalizedSectionId = decodeURIComponent(sectionId ?? "").trim();
|
|
14
16
|
if (!normalizedSectionId) notFound();
|
|
15
17
|
|
|
18
|
+
if (resolveActiveSiteBrand().newsroomLayout === "organizer") return <NewsroomBoardView subject="desk" deskId={normalizedSectionId} />;
|
|
16
19
|
return <NewsDeskPage sectionPageId={normalizedSectionId} searchParams={searchParams} />;
|
|
17
20
|
}
|
|
@@ -41,7 +41,7 @@ import type {
|
|
|
41
41
|
UserDirectoryEntry,
|
|
42
42
|
} from "../lib/category-repository";
|
|
43
43
|
import { relationTypeKey } from "../lib/semantic-graph";
|
|
44
|
-
import {
|
|
44
|
+
import { legacyStageKeysToLoad, type ContentItemVersionRecord } from "../lib/content-item-lifecycle";
|
|
45
45
|
import { getContentItemStageDefinitions } from "../lib/site-brand";
|
|
46
46
|
import { DOCTRINE_DEFINITIONS, getCategoryDoctrineDefinitions, type DoctrineCategory } from "../lib/doctrine";
|
|
47
47
|
import { configureAmplifyClient } from "./amplify-client-provider";
|
|
@@ -2172,31 +2172,45 @@ const CONTENT_ITEMS_BY_STAGE_QUERY = `
|
|
|
2172
2172
|
}
|
|
2173
2173
|
`;
|
|
2174
2174
|
|
|
2175
|
-
export
|
|
2176
|
-
|
|
2175
|
+
export const CONTENT_ITEM_COLUMN_PAGE_LIMIT = 25;
|
|
2176
|
+
|
|
2177
|
+
export type ContentItemStagePage = {
|
|
2178
|
+
versions: ContentItemVersionRecord[];
|
|
2179
|
+
nextToken: string | null;
|
|
2180
|
+
};
|
|
2181
|
+
|
|
2182
|
+
/** One newest-updated-first page of the content items in one stage, so a board column can load as it is scrolled. */
|
|
2183
|
+
export async function loadNewsroomContentItemStagePage(
|
|
2184
|
+
stage: string,
|
|
2185
|
+
nextToken: string | null = null,
|
|
2186
|
+
limit: number = CONTENT_ITEM_COLUMN_PAGE_LIMIT,
|
|
2187
|
+
): Promise<ContentItemStagePage> {
|
|
2188
|
+
if (isLocalPreviewEnabled()) {
|
|
2189
|
+
const versionsInStage = createLocalPreviewContentItemVersions().filter(version => version.stage === stage);
|
|
2190
|
+
const offset = nextToken ? Number(nextToken) : 0;
|
|
2191
|
+
const followingOffset = offset + limit;
|
|
2192
|
+
return {
|
|
2193
|
+
versions: versionsInStage.slice(offset, followingOffset),
|
|
2194
|
+
nextToken: followingOffset < versionsInStage.length ? String(followingOffset) : null,
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2177
2197
|
configureAmplifyClient();
|
|
2178
2198
|
const client = generateClient<Schema>() as unknown as {
|
|
2179
2199
|
graphql: (options: Record<string, unknown>) => Promise<GraphQLConnectionResponse<ContentItemVersionRecord>>;
|
|
2180
2200
|
};
|
|
2181
2201
|
const field = "listItemsByStageAndUpdatedAt";
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
versions.push(...((connection.items ?? []).filter(Boolean) as ContentItemVersionRecord[]));
|
|
2195
|
-
nextToken = connection.nextToken ?? null;
|
|
2196
|
-
} while (nextToken);
|
|
2197
|
-
return versions;
|
|
2198
|
-
}));
|
|
2199
|
-
return versionsPerStage.flat();
|
|
2202
|
+
const response: GraphQLConnectionResponse<ContentItemVersionRecord> = await client.graphql({
|
|
2203
|
+
query: CONTENT_ITEMS_BY_STAGE_QUERY,
|
|
2204
|
+
variables: { stage, sortDirection: "DESC", limit, nextToken },
|
|
2205
|
+
authMode: USER_POOL_AUTH_MODE,
|
|
2206
|
+
});
|
|
2207
|
+
assertNoGraphQLErrors(response.errors);
|
|
2208
|
+
const connection = response.data?.[field];
|
|
2209
|
+
if (!connection) throw new Error(`Missing GraphQL connection payload for ${field}.`);
|
|
2210
|
+
return {
|
|
2211
|
+
versions: (connection.items ?? []).filter(Boolean) as ContentItemVersionRecord[],
|
|
2212
|
+
nextToken: connection.nextToken ?? null,
|
|
2213
|
+
};
|
|
2200
2214
|
}
|
|
2201
2215
|
|
|
2202
2216
|
const PUBLISHED_ITEMS_QUERY = `
|
|
@@ -2222,6 +2236,7 @@ type PublishedItemBoardRow = {
|
|
|
2222
2236
|
};
|
|
2223
2237
|
|
|
2224
2238
|
export async function loadNewsroomPublishedContentItemVersions(): Promise<ContentItemVersionRecord[]> {
|
|
2239
|
+
if (isLocalPreviewEnabled()) return [];
|
|
2225
2240
|
configureAmplifyClient();
|
|
2226
2241
|
const client = generateClient<Schema>() as unknown as {
|
|
2227
2242
|
graphql: (options: Record<string, unknown>) => Promise<GraphQLConnectionResponse<PublishedItemBoardRow>>;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import Link from "next/link";
|
|
5
|
-
import { IssueCollection, IssueDetailPanel } from "@kanbus/ui";
|
|
5
|
+
import { IssueCollection, IssueDetailPanel, IssueTypeFilter, issueTypeFromFilter, useBoardColumnState } from "@kanbus/ui";
|
|
6
6
|
import "@kanbus/ui/styles/kanban.css";
|
|
7
7
|
import "./newsroom-newsprint-board.css";
|
|
8
8
|
import { PlusIcon } from "lucide-react";
|
|
@@ -15,14 +15,20 @@ import {
|
|
|
15
15
|
canReadNewsroomBoard,
|
|
16
16
|
contentItemBoardConfig,
|
|
17
17
|
contentItemBoardType,
|
|
18
|
+
deskBoardConfig,
|
|
19
|
+
deskContainsAssignment,
|
|
20
|
+
deskContainsContentItem,
|
|
18
21
|
projectAssignmentBoard,
|
|
19
22
|
projectContentItemBoard,
|
|
20
23
|
type NativeBoardIssue,
|
|
21
24
|
} from "../lib/newsroom-board";
|
|
22
|
-
import type { AssignmentRecord } from "../lib/category-repository";
|
|
23
|
-
import {
|
|
25
|
+
import type { AssignmentRecord, NewsroomSectionRecord } from "../lib/category-repository";
|
|
26
|
+
import { displayNewsroomSectionShortTitle } from "../lib/newsroom-sections";
|
|
27
|
+
import { getContentItemName, getContentItemStageDefinitions, SITE_BRAND } from "../lib/site-brand";
|
|
24
28
|
import { getNewsroomNavHref } from "../lib/newsroom-nav";
|
|
25
|
-
import { loadNewsroomAssignmentPage,
|
|
29
|
+
import { loadNewsroomAssignmentPage, loadNewsroomPublishedContentItemVersions } from "./news-desk-taxonomy-client";
|
|
30
|
+
import { usePagedContentItemVersions } from "./use-paged-content-item-versions";
|
|
31
|
+
import type { ContentItemVersionRecord } from "../lib/content-item-lifecycle";
|
|
26
32
|
import { useOptionalNewsDeskClient } from "./news-desk-client-provider";
|
|
27
33
|
import { NewsDeskAccessGate } from "./newsroom-access-gate";
|
|
28
34
|
import { NewsroomOpsShell, NewsroomOpsStatusBanner } from "./newsroom-ops-shell";
|
|
@@ -31,6 +37,7 @@ import { readLocalReaderSettings, subscribeReaderSettingsChanges } from "./reade
|
|
|
31
37
|
|
|
32
38
|
const STATIC_MOTION = { mode: "static" } as const;
|
|
33
39
|
const BOARD_REFRESH_INTERVAL_MILLISECONDS = 30_000;
|
|
40
|
+
const COLUMN_LOAD_MORE_DISTANCE_PIXELS = 240;
|
|
34
41
|
|
|
35
42
|
async function loadEveryNewsroomAssignment() {
|
|
36
43
|
const assignments: AssignmentRecord[] = [];
|
|
@@ -43,43 +50,59 @@ async function loadEveryNewsroomAssignment() {
|
|
|
43
50
|
return assignments;
|
|
44
51
|
}
|
|
45
52
|
|
|
46
|
-
export type NewsroomBoardSubject = "contentItem" | "assignment";
|
|
53
|
+
export type NewsroomBoardSubject = "contentItem" | "assignment" | "desk";
|
|
47
54
|
|
|
48
55
|
/** Read-only board of one record kind over authenticated CMS records; existing workspaces own every mutation. */
|
|
49
|
-
export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }) {
|
|
56
|
+
export function NewsroomBoardView({ subject, deskId }: { subject: NewsroomBoardSubject; deskId?: string }) {
|
|
50
57
|
const session = useOptionalNewsDeskClient();
|
|
51
58
|
const allowed = canReadNewsroomBoard(session?.shell.phase);
|
|
52
59
|
const theme = useResolvedPapyrusTheme();
|
|
53
60
|
const [lowMotion, setLowMotion] = useState(false);
|
|
54
|
-
const [
|
|
61
|
+
const [assignmentBoardIssues, setAssignmentBoardIssues] = useState<NativeBoardIssue[]>([]);
|
|
62
|
+
const [publishedVersions, setPublishedVersions] = useState<ContentItemVersionRecord[]>([]);
|
|
63
|
+
const [assignments, setAssignments] = useState<AssignmentRecord[]>([]);
|
|
55
64
|
const [view, setView] = useState<"board" | "list">("board");
|
|
56
65
|
const [selected, setSelected] = useState<string | null>(null);
|
|
57
|
-
const [
|
|
58
|
-
const [
|
|
66
|
+
const [supportingRecordsLoading, setSupportingRecordsLoading] = useState(false);
|
|
67
|
+
const [supportingRecordsError, setSupportingRecordsError] = useState<string | null>(null);
|
|
59
68
|
const generation = useRef(0);
|
|
69
|
+
const boardBodyRef = useRef<HTMLDivElement | null>(null);
|
|
70
|
+
const [typeFilter, setTypeFilter] = useState<string | null>("all");
|
|
71
|
+
const showsContentItems = subject !== "assignment";
|
|
72
|
+
const contentItemColumnKeyPrefix = `${contentItemBoardType()}/`;
|
|
73
|
+
const boardType = subject === "assignment" ? ASSIGNMENT_BOARD_TYPE : contentItemBoardType();
|
|
74
|
+
const deskAssignmentIssues = useMemo(() => subject === "desk" && deskId
|
|
75
|
+
? projectAssignmentBoard(assignments.filter(assignment => deskContainsAssignment(assignment, deskId))) : [], [assignments, deskId, subject]);
|
|
76
|
+
const columnStateConfig = useMemo(() => subject === "contentItem" ? contentItemBoardConfig([])
|
|
77
|
+
: subject === "desk" ? deskBoardConfig(deskAssignmentIssues)
|
|
78
|
+
: assignmentBoardConfig(assignmentBoardIssues), [assignmentBoardIssues, deskAssignmentIssues, subject]);
|
|
79
|
+
const columnState = useBoardColumnState({ config: columnStateConfig, storageKey: `papyrus.cms.columns.v1.${SITE_BRAND.id}.${subject}` });
|
|
80
|
+
const openedCollapsedUntilOpenedStages = useMemo(() => !showsContentItems ? [] : getContentItemStageDefinitions()
|
|
81
|
+
.filter(definition => definition.collapsedUntilOpened && !columnState.collapsedColumns.has(`${contentItemColumnKeyPrefix}${definition.key}`))
|
|
82
|
+
.map(definition => definition.key), [contentItemColumnKeyPrefix, columnState.collapsedColumns, showsContentItems]);
|
|
83
|
+
const pagedContentItems = usePagedContentItemVersions({ enabled: allowed && showsContentItems, openedCollapsedUntilOpenedStages });
|
|
60
84
|
useEffect(() => {
|
|
61
85
|
setLowMotion(readLocalReaderSettings().motion === "low");
|
|
62
86
|
return subscribeReaderSettingsChanges(settings => setLowMotion(settings.motion === "low"));
|
|
63
87
|
}, []);
|
|
64
88
|
useEffect(() => {
|
|
65
89
|
const request = ++generation.current;
|
|
66
|
-
|
|
67
|
-
if (!allowed) {
|
|
68
|
-
const
|
|
69
|
-
? Promise.all([
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
90
|
+
setAssignmentBoardIssues([]); setPublishedVersions([]); setAssignments([]); setSelected(null); setSupportingRecordsError(null);
|
|
91
|
+
if (!allowed) { setSupportingRecordsLoading(false); return; }
|
|
92
|
+
const loadSupportingRecords = () => subject !== "assignment"
|
|
93
|
+
? Promise.all([loadNewsroomPublishedContentItemVersions(), loadEveryNewsroomAssignment()]).then(([published, everyAssignment]) => {
|
|
94
|
+
if (generation.current === request) { setPublishedVersions(published); setAssignments(everyAssignment); }
|
|
95
|
+
})
|
|
96
|
+
: loadEveryNewsroomAssignment().then(everyAssignment => {
|
|
97
|
+
if (generation.current === request) setAssignmentBoardIssues(projectAssignmentBoard(everyAssignment));
|
|
98
|
+
});
|
|
74
99
|
const refresh = (initial: boolean) => {
|
|
75
|
-
if (initial)
|
|
76
|
-
|
|
77
|
-
if (generation.current
|
|
78
|
-
setIssues(loadedIssues);
|
|
79
|
-
setError(null);
|
|
100
|
+
if (initial) setSupportingRecordsLoading(true);
|
|
101
|
+
loadSupportingRecords().then(() => {
|
|
102
|
+
if (generation.current === request) setSupportingRecordsError(null);
|
|
80
103
|
}).catch((reason: unknown) => {
|
|
81
|
-
if (generation.current === request && initial)
|
|
82
|
-
}).finally(() => { if (generation.current === request && initial)
|
|
104
|
+
if (generation.current === request && initial) setSupportingRecordsError(reason instanceof Error ? reason.message : "Could not load newsroom records.");
|
|
105
|
+
}).finally(() => { if (generation.current === request && initial) setSupportingRecordsLoading(false); });
|
|
83
106
|
};
|
|
84
107
|
refresh(true);
|
|
85
108
|
const refreshWhenVisible = () => { if (document.visibilityState === "visible") refresh(false); };
|
|
@@ -87,15 +110,40 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
|
|
|
87
110
|
document.addEventListener("visibilitychange", refreshWhenVisible);
|
|
88
111
|
return () => { generation.current = request + 1; window.clearInterval(interval); document.removeEventListener("visibilitychange", refreshWhenVisible); };
|
|
89
112
|
}, [allowed, subject]);
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
const issues = useMemo(() => {
|
|
114
|
+
if (subject === "assignment") return assignmentBoardIssues;
|
|
115
|
+
if (subject === "contentItem") return projectContentItemBoard({ contentItemVersions: [...pagedContentItems.versions, ...publishedVersions], assignments });
|
|
116
|
+
const versionsOnDesk = [...pagedContentItems.versions, ...publishedVersions].filter(version => deskId && deskContainsContentItem(version, deskId));
|
|
117
|
+
return [...projectContentItemBoard({ contentItemVersions: versionsOnDesk, assignments: assignments.filter(assignment => deskId && deskContainsAssignment(assignment, deskId)) }), ...deskAssignmentIssues];
|
|
118
|
+
}, [assignmentBoardIssues, assignments, deskAssignmentIssues, deskId, pagedContentItems.versions, publishedVersions, subject]);
|
|
119
|
+
const loading = supportingRecordsLoading || (showsContentItems && pagedContentItems.loading);
|
|
120
|
+
const error = supportingRecordsError ?? (showsContentItems ? pagedContentItems.error : null);
|
|
121
|
+
const config = useMemo(() => subject === "contentItem" ? contentItemBoardConfig(issues) : subject === "desk" ? deskBoardConfig(issues) : assignmentBoardConfig(issues), [issues, subject]);
|
|
122
|
+
const columnStageFromElement = (element: Element | null) => {
|
|
123
|
+
const columnKey = element?.closest("[data-column-key]")?.getAttribute("data-column-key");
|
|
124
|
+
return columnKey?.startsWith(contentItemColumnKeyPrefix) ? columnKey.slice(contentItemColumnKeyPrefix.length) : null;
|
|
125
|
+
};
|
|
126
|
+
const loadMoreWhenColumnIsNearItsEnd = (columnScroll: HTMLElement) => {
|
|
127
|
+
const distanceToEnd = columnScroll.scrollHeight - columnScroll.scrollTop - columnScroll.clientHeight;
|
|
128
|
+
const stage = columnStageFromElement(columnScroll);
|
|
129
|
+
if (stage && distanceToEnd < COLUMN_LOAD_MORE_DISTANCE_PIXELS) pagedContentItems.loadMoreForStage(stage);
|
|
130
|
+
};
|
|
131
|
+
const handleBoardScroll = (event: React.UIEvent<HTMLDivElement>) => {
|
|
132
|
+
const target = event.target as HTMLElement;
|
|
133
|
+
if (showsContentItems && target.classList?.contains("kb-column-scroll")) loadMoreWhenColumnIsNearItsEnd(target);
|
|
134
|
+
};
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!showsContentItems) return;
|
|
137
|
+
boardBodyRef.current?.querySelectorAll<HTMLElement>(".kb-column-scroll").forEach(loadMoreWhenColumnIsNearItsEnd);
|
|
138
|
+
});
|
|
139
|
+
const deskTitle = session?.shell.dashboard?.newsroomSections?.find(section => section.id === deskId)?.title ?? (deskId ? displayNewsroomSectionShortTitle({ id: deskId } as NewsroomSectionRecord) : "Desk");
|
|
140
|
+
const pageTitle = subject === "contentItem" ? getContentItemName().plural : subject === "desk" ? deskTitle : "Assignments";
|
|
93
141
|
const issue = issues.find(item => item.id === selected);
|
|
94
142
|
if (!allowed) return <NewsDeskAccessGate shell={session?.shell ?? null} />;
|
|
95
|
-
return <NewsroomOpsShell activeTab={subject === "contentItem" ? "articles" : "assignments"} appTitle={SITE_BRAND.appTitle} backLabel={SITE_BRAND.backToHomeLabel} pageTitle={pageTitle}
|
|
143
|
+
return <NewsroomOpsShell activeTab={subject === "contentItem" ? "articles" : subject === "desk" ? "desks" : "assignments"} appTitle={SITE_BRAND.appTitle} backLabel={SITE_BRAND.backToHomeLabel} pageTitle={pageTitle}
|
|
96
144
|
headerActions={<>
|
|
97
145
|
<div role="group" aria-label="Record presentation" className="organizer-board-view-toggle"><button type="button" aria-pressed={view === "board"} onClick={() => setView("board")}>Board</button><button type="button" aria-pressed={view === "list"} onClick={() => setView("list")}>List</button></div>
|
|
98
|
-
{
|
|
146
|
+
{showsContentItems && (
|
|
99
147
|
<Link className={cn(buttonVariants({ size: "sm" }))} data-newsroom-article-new href={getNewsroomNavHref(newsroomHref("articles", "new"))}>
|
|
100
148
|
<PlusIcon aria-hidden="true" />
|
|
101
149
|
{`New ${getContentItemName().singular.toLowerCase()}`}
|
|
@@ -105,10 +153,11 @@ export function NewsroomBoardView({ subject }: { subject: NewsroomBoardSubject }
|
|
|
105
153
|
<div className="organizer-native-board papyrus-newsprint-board" data-color-mode={theme}>
|
|
106
154
|
{error && <NewsroomOpsStatusBanner tone="error">{error}</NewsroomOpsStatusBanner>}
|
|
107
155
|
<p role="status" className="organizer-board-note">{loading ? "Loading records…" : `${issues.length} records loaded.`}</p>
|
|
108
|
-
<
|
|
109
|
-
|
|
156
|
+
{subject === "desk" && <IssueTypeFilter config={config} value={typeFilter} onChange={setTypeFilter} name="Record type" className="organizer-board-type-filter" />}
|
|
157
|
+
<div className="organizer-board-body" data-detail-open={Boolean(issue)} ref={boardBodyRef} onScrollCapture={handleBoardScroll}>
|
|
158
|
+
<IssueCollection issues={issues} config={config} query={{ type: subject === "desk" ? issueTypeFromFilter(typeFilter) : boardType }} view={view}
|
|
110
159
|
motion={lowMotion ? STATIC_MOTION : undefined}
|
|
111
|
-
|
|
160
|
+
collapsedColumns={columnState.collapsedColumns} onToggleCollapse={columnState.toggleColumn} initialScroll="start"
|
|
112
161
|
selectedIssueId={selected} detailOpen={Boolean(issue)} onSelectIssue={item => setSelected(item.id)} ariaLabel={pageTitle}
|
|
113
162
|
emptyMessage={loading ? "Loading records…" : error ? "Records could not be loaded." : "No records in this selection."} />
|
|
114
163
|
{issue && <IssueDetailPanel issue={issue} onClose={() => setSelected(null)} fields={[{ label: "CMS record ID", value: issue.nativeId }, { label: "Status", value: issue.nativeStatus }]}>
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
canonicalContentItemStage,
|
|
6
|
+
legacyStageKeysToLoad,
|
|
7
|
+
type ContentItemVersionRecord,
|
|
8
|
+
} from "../lib/content-item-lifecycle";
|
|
9
|
+
import { getContentItemStageDefinitions } from "../lib/site-brand";
|
|
10
|
+
import { loadNewsroomContentItemStagePage } from "./news-desk-taxonomy-client";
|
|
11
|
+
|
|
12
|
+
const REFRESH_INTERVAL_MILLISECONDS = 30_000;
|
|
13
|
+
|
|
14
|
+
type StageBucket = {
|
|
15
|
+
versions: ContentItemVersionRecord[];
|
|
16
|
+
nextToken: string | null;
|
|
17
|
+
pagesLoaded: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type PagedContentItemVersions = {
|
|
21
|
+
versions: ContentItemVersionRecord[];
|
|
22
|
+
loading: boolean;
|
|
23
|
+
error: string | null;
|
|
24
|
+
stageHasMore: (canonicalStage: string) => boolean;
|
|
25
|
+
loadMoreForStage: (canonicalStage: string) => void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function mergeFreshFirstPage(existing: StageBucket | undefined, fresh: StageBucket): StageBucket {
|
|
29
|
+
if (!existing || existing.pagesLoaded <= 1) return fresh;
|
|
30
|
+
const freshIds = new Set(fresh.versions.map(version => version.id));
|
|
31
|
+
return {
|
|
32
|
+
versions: [...fresh.versions, ...existing.versions.filter(version => !freshIds.has(version.id))],
|
|
33
|
+
nextToken: existing.nextToken,
|
|
34
|
+
pagesLoaded: existing.pagesLoaded,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Newest-updated content items per stage, one page per stage to start, more pages on demand.
|
|
40
|
+
* The periodic refresh re-fetches only first pages and keeps whatever later pages were already loaded.
|
|
41
|
+
*/
|
|
42
|
+
export function usePagedContentItemVersions(options: {
|
|
43
|
+
enabled: boolean;
|
|
44
|
+
openedCollapsedUntilOpenedStages: readonly string[];
|
|
45
|
+
}): PagedContentItemVersions {
|
|
46
|
+
const { enabled, openedCollapsedUntilOpenedStages } = options;
|
|
47
|
+
const [buckets, setBuckets] = useState<Record<string, StageBucket>>({});
|
|
48
|
+
const [loading, setLoading] = useState(false);
|
|
49
|
+
const [error, setError] = useState<string | null>(null);
|
|
50
|
+
const bucketsRef = useRef(buckets);
|
|
51
|
+
const stageKeysBeingExtendedRef = useRef(new Set<string>());
|
|
52
|
+
const generationRef = useRef(0);
|
|
53
|
+
|
|
54
|
+
const openedStagesSignature = openedCollapsedUntilOpenedStages.join(",");
|
|
55
|
+
const stageKeysToLoad = useMemo(() => {
|
|
56
|
+
const stageDefinitions = getContentItemStageDefinitions();
|
|
57
|
+
return [
|
|
58
|
+
...stageDefinitions
|
|
59
|
+
.filter(definition => !definition.collapsedUntilOpened || openedStagesSignature.split(",").includes(definition.key))
|
|
60
|
+
.map(definition => definition.key),
|
|
61
|
+
...legacyStageKeysToLoad(stageDefinitions),
|
|
62
|
+
];
|
|
63
|
+
}, [openedStagesSignature]);
|
|
64
|
+
const stageKeysToLoadRef = useRef(stageKeysToLoad);
|
|
65
|
+
stageKeysToLoadRef.current = stageKeysToLoad;
|
|
66
|
+
|
|
67
|
+
const storeBuckets = useCallback((update: (previous: Record<string, StageBucket>) => Record<string, StageBucket>) => {
|
|
68
|
+
const next = update(bucketsRef.current);
|
|
69
|
+
bucketsRef.current = next;
|
|
70
|
+
setBuckets(next);
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const refreshFirstPages = useCallback(async (request: number, isInitial: boolean, stageKeys: readonly string[]) => {
|
|
74
|
+
if (isInitial) setLoading(true);
|
|
75
|
+
try {
|
|
76
|
+
const freshBuckets = await Promise.all(stageKeys.map(async stageKey => {
|
|
77
|
+
const page = await loadNewsroomContentItemStagePage(stageKey);
|
|
78
|
+
return [stageKey, { versions: page.versions, nextToken: page.nextToken, pagesLoaded: 1 }] as const;
|
|
79
|
+
}));
|
|
80
|
+
if (generationRef.current !== request) return;
|
|
81
|
+
storeBuckets(previous => {
|
|
82
|
+
const next = { ...previous };
|
|
83
|
+
for (const [stageKey, fresh] of freshBuckets) next[stageKey] = mergeFreshFirstPage(previous[stageKey], fresh);
|
|
84
|
+
return next;
|
|
85
|
+
});
|
|
86
|
+
setError(null);
|
|
87
|
+
} catch (reason: unknown) {
|
|
88
|
+
if (generationRef.current === request && isInitial) setError(reason instanceof Error ? reason.message : "Could not load newsroom records.");
|
|
89
|
+
} finally {
|
|
90
|
+
if (generationRef.current === request && isInitial) setLoading(false);
|
|
91
|
+
}
|
|
92
|
+
}, [storeBuckets]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
const request = ++generationRef.current;
|
|
96
|
+
bucketsRef.current = {};
|
|
97
|
+
setBuckets({});
|
|
98
|
+
setError(null);
|
|
99
|
+
if (!enabled) { setLoading(false); return; }
|
|
100
|
+
void refreshFirstPages(request, true, stageKeysToLoadRef.current);
|
|
101
|
+
const refreshWhenVisible = () => {
|
|
102
|
+
if (document.visibilityState === "visible") void refreshFirstPages(request, false, stageKeysToLoadRef.current);
|
|
103
|
+
};
|
|
104
|
+
const interval = window.setInterval(refreshWhenVisible, REFRESH_INTERVAL_MILLISECONDS);
|
|
105
|
+
document.addEventListener("visibilitychange", refreshWhenVisible);
|
|
106
|
+
return () => {
|
|
107
|
+
generationRef.current = request + 1;
|
|
108
|
+
window.clearInterval(interval);
|
|
109
|
+
document.removeEventListener("visibilitychange", refreshWhenVisible);
|
|
110
|
+
};
|
|
111
|
+
}, [enabled, refreshFirstPages]);
|
|
112
|
+
|
|
113
|
+
useEffect(() => {
|
|
114
|
+
if (!enabled) return;
|
|
115
|
+
const stageKeysNotLoadedYet = stageKeysToLoad.filter(stageKey => !(stageKey in bucketsRef.current));
|
|
116
|
+
if (stageKeysNotLoadedYet.length) void refreshFirstPages(generationRef.current, false, stageKeysNotLoadedYet);
|
|
117
|
+
}, [enabled, refreshFirstPages, stageKeysToLoad]);
|
|
118
|
+
|
|
119
|
+
const stageKeysInCanonicalStage = useCallback((canonicalStage: string) => Object.keys(bucketsRef.current)
|
|
120
|
+
.filter(stageKey => canonicalContentItemStage(stageKey, getContentItemStageDefinitions()) === canonicalStage), []);
|
|
121
|
+
|
|
122
|
+
const loadMoreForStage = useCallback((canonicalStage: string) => {
|
|
123
|
+
const request = generationRef.current;
|
|
124
|
+
for (const stageKey of stageKeysInCanonicalStage(canonicalStage)) {
|
|
125
|
+
const bucket = bucketsRef.current[stageKey];
|
|
126
|
+
if (!bucket?.nextToken || stageKeysBeingExtendedRef.current.has(stageKey)) continue;
|
|
127
|
+
stageKeysBeingExtendedRef.current.add(stageKey);
|
|
128
|
+
loadNewsroomContentItemStagePage(stageKey, bucket.nextToken).then(page => {
|
|
129
|
+
if (generationRef.current !== request) return;
|
|
130
|
+
storeBuckets(previous => {
|
|
131
|
+
const current = previous[stageKey] ?? bucket;
|
|
132
|
+
const knownIds = new Set(current.versions.map(version => version.id));
|
|
133
|
+
return {
|
|
134
|
+
...previous,
|
|
135
|
+
[stageKey]: {
|
|
136
|
+
versions: [...current.versions, ...page.versions.filter(version => !knownIds.has(version.id))],
|
|
137
|
+
nextToken: page.nextToken,
|
|
138
|
+
pagesLoaded: current.pagesLoaded + 1,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}).catch(() => undefined).finally(() => { stageKeysBeingExtendedRef.current.delete(stageKey); });
|
|
143
|
+
}
|
|
144
|
+
}, [stageKeysInCanonicalStage, storeBuckets]);
|
|
145
|
+
|
|
146
|
+
const stageHasMore = useCallback((canonicalStage: string) => stageKeysInCanonicalStage(canonicalStage)
|
|
147
|
+
.some(stageKey => Boolean(bucketsRef.current[stageKey]?.nextToken)), [stageKeysInCanonicalStage]);
|
|
148
|
+
|
|
149
|
+
const versions = useMemo(() => Object.values(buckets).flatMap(bucket => bucket.versions), [buckets]);
|
|
150
|
+
return { versions, loading, error, stageHasMore, loadMoreForStage };
|
|
151
|
+
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from "./blog-rhythm";
|
|
13
13
|
import { layoutAllTextLines, layoutTextLines, prepareWithSegments, type TextLine, type TextObstacle } from "./pretext-layout";
|
|
14
14
|
|
|
15
|
-
export type FeaturedLayoutMode = "
|
|
15
|
+
export type FeaturedLayoutMode = "float" | "stacked";
|
|
16
16
|
|
|
17
17
|
export type SolvedFeaturedItem = {
|
|
18
18
|
mode: FeaturedLayoutMode;
|
|
@@ -92,19 +92,6 @@ export function solveFeaturedItem(input: SolveFeaturedItemInput): SolvedFeatured
|
|
|
92
92
|
});
|
|
93
93
|
const aspectRatio = getImageAspectRatio(input.imageAsset);
|
|
94
94
|
|
|
95
|
-
if (mode === "obstacle") {
|
|
96
|
-
return solveObstacleFeaturedItem({
|
|
97
|
-
prepared,
|
|
98
|
-
containerWidth: input.containerWidth,
|
|
99
|
-
viewportWidth: input.viewportWidth,
|
|
100
|
-
rhythm,
|
|
101
|
-
textStyle: input.textStyle,
|
|
102
|
-
aspectRatio,
|
|
103
|
-
gap,
|
|
104
|
-
imageAsset: input.imageAsset,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
95
|
if (mode === "float") {
|
|
109
96
|
return solveFloatFeaturedItem({
|
|
110
97
|
prepared,
|
|
@@ -151,96 +138,6 @@ type PreparedSolveInput = {
|
|
|
151
138
|
imageAsset: ArticleImageAsset;
|
|
152
139
|
};
|
|
153
140
|
|
|
154
|
-
function solveObstacleFeaturedItem(input: PreparedSolveInput): SolvedFeaturedItem {
|
|
155
|
-
const maxImageWidth = getFloatImageWidth(input);
|
|
156
|
-
let best: {
|
|
157
|
-
score: number;
|
|
158
|
-
textLines: TextLine[];
|
|
159
|
-
imageHeight: number;
|
|
160
|
-
imageWidth: number;
|
|
161
|
-
captionHeight: number;
|
|
162
|
-
mediaHeight: number;
|
|
163
|
-
copyWidth: number;
|
|
164
|
-
textFrameHeight: number;
|
|
165
|
-
hasMore: boolean;
|
|
166
|
-
} | null = null;
|
|
167
|
-
|
|
168
|
-
for (const imageWidth of getObstacleImageWidths(maxImageWidth, input.rhythm)) {
|
|
169
|
-
const copyWidth = Math.max(
|
|
170
|
-
getFloatCopyMinimum(input.viewportWidth, input.rhythm),
|
|
171
|
-
input.containerWidth - imageWidth - input.gap,
|
|
172
|
-
);
|
|
173
|
-
const imageHeight = snapImageHeight(imageWidth / input.aspectRatio, input.rhythm, input.imageAsset.layout);
|
|
174
|
-
const captionHeight = getFeatureCaptionHeight(input.imageAsset, imageWidth, input.rhythm);
|
|
175
|
-
const mediaHeight = imageHeight + captionHeight;
|
|
176
|
-
const obstacle: TextObstacle = {
|
|
177
|
-
x: Math.max(0, copyWidth - imageWidth),
|
|
178
|
-
y: 0,
|
|
179
|
-
width: imageWidth,
|
|
180
|
-
height: mediaHeight,
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
let candidateHeight = mediaHeight;
|
|
184
|
-
let result = layoutTextLines({
|
|
185
|
-
prepared: input.prepared,
|
|
186
|
-
cursor: { segmentIndex: 0, graphemeIndex: 0 },
|
|
187
|
-
maxHeight: candidateHeight,
|
|
188
|
-
maxWidth: copyWidth,
|
|
189
|
-
lineHeight: input.textStyle.lineHeight,
|
|
190
|
-
linePaintHeight: input.textStyle.linePaintHeight,
|
|
191
|
-
fontSize: input.textStyle.fontSize,
|
|
192
|
-
fontFamily: input.textStyle.fontFamily,
|
|
193
|
-
obstacles: [obstacle],
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
const textBottom = getMeasuredTextHeight(result.lines);
|
|
197
|
-
if (textBottom > 0 && textBottom < candidateHeight) {
|
|
198
|
-
candidateHeight = reserveRhythmRows(textBottom, input.rhythm);
|
|
199
|
-
obstacle.height = candidateHeight;
|
|
200
|
-
result = layoutTextLines({
|
|
201
|
-
prepared: input.prepared,
|
|
202
|
-
cursor: { segmentIndex: 0, graphemeIndex: 0 },
|
|
203
|
-
maxHeight: candidateHeight,
|
|
204
|
-
maxWidth: copyWidth,
|
|
205
|
-
lineHeight: input.textStyle.lineHeight,
|
|
206
|
-
linePaintHeight: input.textStyle.linePaintHeight,
|
|
207
|
-
fontSize: input.textStyle.fontSize,
|
|
208
|
-
fontFamily: input.textStyle.fontFamily,
|
|
209
|
-
obstacles: [obstacle],
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const whitespace = Math.max(0, candidateHeight - getMeasuredTextHeight(result.lines));
|
|
214
|
-
const score = 50_000 - whitespace * 1.4 - Math.abs(candidateHeight - mediaHeight) * 0.35 - Math.abs(maxImageWidth - imageWidth) * 0.2;
|
|
215
|
-
const candidate = {
|
|
216
|
-
score,
|
|
217
|
-
textLines: result.lines,
|
|
218
|
-
imageHeight: Math.min(imageHeight, candidateHeight),
|
|
219
|
-
imageWidth,
|
|
220
|
-
captionHeight,
|
|
221
|
-
mediaHeight: candidateHeight,
|
|
222
|
-
copyWidth,
|
|
223
|
-
textFrameHeight: reserveRhythmRows(getMeasuredTextHeight(result.lines), input.rhythm),
|
|
224
|
-
hasMore: result.hasMore,
|
|
225
|
-
};
|
|
226
|
-
if (!best || candidate.score > best.score) best = candidate;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const fallbackImageHeight = input.rhythm.rowHeight * 6;
|
|
230
|
-
return {
|
|
231
|
-
mode: "obstacle",
|
|
232
|
-
textLines: best?.textLines ?? [],
|
|
233
|
-
imageHeight: best?.imageHeight ?? fallbackImageHeight,
|
|
234
|
-
imageWidth: best?.imageWidth ?? maxImageWidth,
|
|
235
|
-
captionHeight: best?.captionHeight ?? 0,
|
|
236
|
-
mediaHeight: best?.mediaHeight ?? fallbackImageHeight,
|
|
237
|
-
copyWidth: best?.copyWidth ?? input.containerWidth,
|
|
238
|
-
textFrameHeight: best?.textFrameHeight ?? 0,
|
|
239
|
-
hasMore: best?.hasMore ?? false,
|
|
240
|
-
gap: input.gap,
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
141
|
function solveFloatFeaturedItem(input: PreparedSolveInput): SolvedFeaturedItem {
|
|
245
142
|
const geometry = computeFloatGeometry({
|
|
246
143
|
containerWidth: input.containerWidth,
|
|
@@ -417,11 +314,6 @@ function getFloatCopyMinimum(viewportWidth: number, rhythm: VerticalRhythm): num
|
|
|
417
314
|
return rhythmLengthRows(viewportWidth <= 600 ? FLOAT_COPY_MIN_PHONE_ROWS : FLOAT_COPY_MIN_DESKTOP_ROWS, rhythm);
|
|
418
315
|
}
|
|
419
316
|
|
|
420
|
-
function getObstacleImageWidths(maximum: number, rhythm: VerticalRhythm): number[] {
|
|
421
|
-
const candidateRows = [0, 1, 2].map((offset) => Math.max(rhythm.rowHeight * 5, maximum - (offset * rhythm.rowHeight)));
|
|
422
|
-
return Array.from(new Set(candidateRows));
|
|
423
|
-
}
|
|
424
|
-
|
|
425
317
|
function snapImageHeight(
|
|
426
318
|
naturalHeight: number,
|
|
427
319
|
rhythm: VerticalRhythm,
|
|
@@ -7,24 +7,51 @@
|
|
|
7
7
|
export type ContentItemStageDefinition = {
|
|
8
8
|
key: string;
|
|
9
9
|
label: string;
|
|
10
|
+
/** Closed or rarely visited stage: its board column starts collapsed and its cards load only when it is opened. */
|
|
11
|
+
collapsedUntilOpened?: boolean;
|
|
10
12
|
};
|
|
11
13
|
|
|
14
|
+
export const PUBLISHED_STAGE_KEY = "published";
|
|
15
|
+
|
|
16
|
+
/** Stage keys written before the story stages were simplified, read as the stage that replaced them. */
|
|
17
|
+
export const LEGACY_CONTENT_ITEM_STAGE_ALIASES: Readonly<Record<string, string>> = {
|
|
18
|
+
research: "reporting",
|
|
19
|
+
report: "reporting",
|
|
20
|
+
editor_select: "reporting",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/** Stages for work that has not become a story yet; they appear on the assignments board only. */
|
|
24
|
+
export const ASSIGNMENT_PHASE_STAGE_KEYS: readonly string[] = ["idea", "assignment"];
|
|
25
|
+
|
|
12
26
|
export const DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS: readonly ContentItemStageDefinition[] = [
|
|
13
|
-
{ key: "
|
|
14
|
-
{ key: "assignment", label: "Assignment" },
|
|
15
|
-
{ key: "research", label: "Research" },
|
|
16
|
-
{ key: "report", label: "Report" },
|
|
17
|
-
{ key: "editor_select", label: "Editor select" },
|
|
27
|
+
{ key: "reporting", label: "Reporting" },
|
|
18
28
|
{ key: "copywriting", label: "Copywriting" },
|
|
19
29
|
{ key: "illustration", label: "Illustration" },
|
|
20
30
|
{ key: "typesetting", label: "Typesetting" },
|
|
21
31
|
{ key: "published", label: "Published" },
|
|
32
|
+
{ key: "held", label: "Held" },
|
|
33
|
+
{ key: "spiked", label: "Spiked", collapsedUntilOpened: true },
|
|
22
34
|
];
|
|
23
35
|
|
|
24
36
|
export function contentItemStageKeys(stageDefinitions: readonly ContentItemStageDefinition[]): string[] {
|
|
25
37
|
return stageDefinitions.map(definition => definition.key);
|
|
26
38
|
}
|
|
27
39
|
|
|
40
|
+
export function canonicalContentItemStage(
|
|
41
|
+
stage: string,
|
|
42
|
+
stageDefinitions: readonly ContentItemStageDefinition[] = DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS,
|
|
43
|
+
): string {
|
|
44
|
+
const isDefined = stageDefinitions.some(definition => definition.key === stage);
|
|
45
|
+
return isDefined ? stage : LEGACY_CONTENT_ITEM_STAGE_ALIASES[stage] ?? stage;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function legacyStageKeysToLoad(stageDefinitions: readonly ContentItemStageDefinition[]): string[] {
|
|
49
|
+
const definedKeys = contentItemStageKeys(stageDefinitions);
|
|
50
|
+
return Object.entries(LEGACY_CONTENT_ITEM_STAGE_ALIASES)
|
|
51
|
+
.filter(([legacyKey, replacementKey]) => !definedKeys.includes(legacyKey) && definedKeys.includes(replacementKey))
|
|
52
|
+
.map(([legacyKey]) => legacyKey);
|
|
53
|
+
}
|
|
54
|
+
|
|
28
55
|
export function contentItemStageLabel(
|
|
29
56
|
stage: string,
|
|
30
57
|
stageDefinitions: readonly ContentItemStageDefinition[] = DEFAULT_CONTENT_ITEM_STAGE_DEFINITIONS,
|
|
@@ -6,15 +6,13 @@ const SEED_TIMESTAMP_BASE = Date.parse("2026-10-01T12:00:00.000Z");
|
|
|
6
6
|
const ONE_HOUR_IN_MILLISECONDS = 60 * 60 * 1000;
|
|
7
7
|
|
|
8
8
|
const SEED_CONTENT_ITEM_HEADLINES_BY_POSITION: readonly (readonly string[])[] = [
|
|
9
|
-
["Readers ask what the newsroom should chase next", "A tip from the field: harbor dredging schedule"],
|
|
10
|
-
["City council budget vote draws a crowd", "Interview request: regional transit director"],
|
|
11
|
-
["Mapping every permit filed since January", "What the county audit left out"],
|
|
12
9
|
["Three sources confirm the zoning reversal", "Reporting packet: school board redistricting"],
|
|
13
|
-
["Editor shortlist: the week's lead candidates", "Editor shortlist: the weekend long read"],
|
|
14
10
|
["Draft in progress: the last ferry crossing", "Draft in progress: neighborhood bakery profile"],
|
|
15
11
|
["Illustration brief: flooded streets, aerial view", "Illustration brief: the market at dawn"],
|
|
16
12
|
["Layout pass: front page lead and rail", "Layout pass: the Saturday supplement"],
|
|
17
13
|
["Published: harbor safety review", "Published: the lighthouse keepers' archive"],
|
|
14
|
+
["Held for the winter issue: the lighthouse keepers' archive", "Evergreen: how the harbor dredging works"],
|
|
15
|
+
["Spiked: the unconfirmed council rumor", "Spiked: the recycled press release"],
|
|
18
16
|
];
|
|
19
17
|
|
|
20
18
|
function isoTimestampHoursBeforeBase(hours: number): string {
|
package/lib/newsroom-board.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { KanbanConfig, KanbanIssue } from "@kanbus/ui";
|
|
2
2
|
import type { AssignmentRecord } from "./category-repository";
|
|
3
3
|
import {
|
|
4
|
+
ASSIGNMENT_PHASE_STAGE_KEYS,
|
|
5
|
+
PUBLISHED_STAGE_KEY,
|
|
6
|
+
canonicalContentItemStage,
|
|
4
7
|
contentItemStageKeys,
|
|
5
8
|
contentItemStageLabel,
|
|
6
9
|
latestVersionPerContentItem,
|
|
@@ -42,8 +45,12 @@ export function projectContentItemBoard(records: {
|
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
const contentItemType = contentItemBoardType();
|
|
45
|
-
|
|
46
|
-
|
|
48
|
+
const stageDefinitions = getContentItemStageDefinitions();
|
|
49
|
+
const stageKeys = contentItemStageKeys(stageDefinitions);
|
|
50
|
+
const contentItemVersionsOnBoard = latestVersionPerContentItem(records.contentItemVersions)
|
|
51
|
+
.map(version => ({ version, stage: canonicalContentItemStage(version.stage ?? "idea", stageDefinitions) }))
|
|
52
|
+
.filter(({ stage }) => stageKeys.includes(stage) || !ASSIGNMENT_PHASE_STAGE_KEYS.includes(stage));
|
|
53
|
+
return contentItemVersionsOnBoard.map(({ version, stage }) => {
|
|
47
54
|
const workCount = assignmentCountByContentItem.get(version.lineageId) ?? 0;
|
|
48
55
|
return {
|
|
49
56
|
id: `contentItem:${version.lineageId}`, nativeId: version.lineageId, kind: "contentItem" as const, type: contentItemType,
|
|
@@ -70,9 +77,10 @@ export function contentItemColumnOrder(
|
|
|
70
77
|
stagesPresentOnBoard: readonly string[],
|
|
71
78
|
stageKeys: readonly string[] = contentItemStageKeys(getContentItemStageDefinitions()),
|
|
72
79
|
): string[] {
|
|
73
|
-
const lastStage = stageKeys[stageKeys.length - 1];
|
|
74
80
|
const unrecognizedStages = [...new Set(stagesPresentOnBoard)].filter(stage => !stageKeys.includes(stage));
|
|
75
|
-
|
|
81
|
+
const stageBeforeWhichUnrecognizedStagesSit = stageKeys.includes(PUBLISHED_STAGE_KEY) ? PUBLISHED_STAGE_KEY : stageKeys[stageKeys.length - 1];
|
|
82
|
+
const insertionIndex = stageKeys.indexOf(stageBeforeWhichUnrecognizedStagesSit);
|
|
83
|
+
return [...stageKeys.slice(0, insertionIndex), ...unrecognizedStages, ...stageKeys.slice(insertionIndex)];
|
|
76
84
|
}
|
|
77
85
|
|
|
78
86
|
export function assignmentColumnOrder(statusesPresentOnBoard: readonly string[]): string[] {
|
|
@@ -81,7 +89,7 @@ export function assignmentColumnOrder(statusesPresentOnBoard: readonly string[])
|
|
|
81
89
|
return [...ASSIGNMENT_STATUSES_BEFORE_OTHERS, ...otherStatuses, ...ASSIGNMENT_STATUSES_AFTER_OTHERS];
|
|
82
90
|
}
|
|
83
91
|
|
|
84
|
-
function boardConfigForType(type: string, columns: readonly { key: string; name: string }[]): KanbanConfig {
|
|
92
|
+
function boardConfigForType(type: string, columns: readonly { key: string; name: string; collapsed?: boolean }[]): KanbanConfig {
|
|
85
93
|
const statuses = columns.map(column => ({ ...column, category: "native" }));
|
|
86
94
|
return {
|
|
87
95
|
hierarchy: [], types: [type], statuses,
|
|
@@ -90,11 +98,15 @@ function boardConfigForType(type: string, columns: readonly { key: string; name:
|
|
|
90
98
|
};
|
|
91
99
|
}
|
|
92
100
|
|
|
93
|
-
/** Content items read left to right through the lifecycle
|
|
101
|
+
/** Content items read left to right through the lifecycle; stages marked collapsed-until-opened start collapsed. */
|
|
94
102
|
export function contentItemBoardConfig(issues: readonly NativeBoardIssue[]): KanbanConfig {
|
|
95
103
|
const contentItemType = contentItemBoardType();
|
|
96
104
|
return boardConfigForType(contentItemType, contentItemColumnOrder(issues.map(issue => issue.nativeStatus))
|
|
97
|
-
.map(stage => ({
|
|
105
|
+
.map(stage => ({
|
|
106
|
+
key: `${contentItemType}/${stage}`,
|
|
107
|
+
name: contentItemStageLabel(stage, getContentItemStageDefinitions()),
|
|
108
|
+
collapsed: getContentItemStageDefinitions().some(definition => definition.key === stage && definition.collapsedUntilOpened),
|
|
109
|
+
})));
|
|
98
110
|
}
|
|
99
111
|
|
|
100
112
|
export function assignmentBoardConfig(issues: readonly NativeBoardIssue[]): KanbanConfig {
|
|
@@ -102,6 +114,31 @@ export function assignmentBoardConfig(issues: readonly NativeBoardIssue[]): Kanb
|
|
|
102
114
|
.map(status => ({ key: `${ASSIGNMENT_BOARD_TYPE}/${status}`, name: assignmentStatusLabel(status) })));
|
|
103
115
|
}
|
|
104
116
|
|
|
117
|
+
function matchesDesk(candidate: string | null | undefined, deskId: string): boolean {
|
|
118
|
+
return Boolean(candidate) && candidate!.trim().toLowerCase() === deskId.trim().toLowerCase();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function deskContainsContentItem(version: ContentItemVersionRecord, deskId: string): boolean {
|
|
122
|
+
return matchesDesk(version.section, deskId);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function deskContainsAssignment(assignment: AssignmentRecord, deskId: string): boolean {
|
|
126
|
+
return matchesDesk(assignment.sectionId, deskId) || matchesDesk(assignment.sectionKey, deskId);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** A desk board shows stories and assignments side by side; each keeps its own columns and the type filter narrows to one. */
|
|
130
|
+
export function deskBoardConfig(issues: readonly NativeBoardIssue[]): KanbanConfig {
|
|
131
|
+
const storiesConfig = contentItemBoardConfig(issues.filter(issue => issue.kind === "contentItem"));
|
|
132
|
+
const assignmentsConfig = assignmentBoardConfig(issues.filter(issue => issue.kind === "assignment"));
|
|
133
|
+
return {
|
|
134
|
+
...storiesConfig,
|
|
135
|
+
types: [...(storiesConfig.types ?? []), ...(assignmentsConfig.types ?? [])],
|
|
136
|
+
statuses: [...storiesConfig.statuses, ...assignmentsConfig.statuses],
|
|
137
|
+
categories: storiesConfig.categories,
|
|
138
|
+
workflows: { ...storiesConfig.workflows, ...assignmentsConfig.workflows },
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
105
142
|
export function canReadNewsroomBoard(phase: string | undefined): boolean {
|
|
106
143
|
return phase === "ready";
|
|
107
144
|
}
|
package/lib/site-stack.ts
CHANGED
|
@@ -149,7 +149,7 @@ export const PILOBOL_US_THEME_PACK_TOKENS: ThemePackTokens = {
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
/**
|
|
152
|
-
* Anthus palette, read off the live Gatsby site at `AnthusAI/Anth.us`
|
|
152
|
+
* Anthus palette, read off the live Gatsby site at `AnthusAI/Anth.us-legacy-Gatsby`
|
|
153
153
|
* (`src/styles/variables.scss` `:root`). Colors only — Shadcn owns typography.
|
|
154
154
|
* Mapping from that file's names to the pack's slots:
|
|
155
155
|
*
|
package/package.json
CHANGED
|
@@ -135,6 +135,7 @@
|
|
|
135
135
|
"./components/use-blog-header-obstacles": "./components/use-blog-header-obstacles.ts",
|
|
136
136
|
"./components/use-brand-fonts-ready": "./components/use-brand-fonts-ready.ts",
|
|
137
137
|
"./components/use-near-viewport": "./components/use-near-viewport.ts",
|
|
138
|
+
"./components/use-paged-content-item-versions": "./components/use-paged-content-item-versions.ts",
|
|
138
139
|
"./components/use-resolved-papyrus-theme": "./components/use-resolved-papyrus-theme.ts",
|
|
139
140
|
"./components/use-rhythm-overlay": "./components/use-rhythm-overlay.ts",
|
|
140
141
|
"./lib/amplify-outputs-guard": "./lib/amplify-outputs-guard.ts",
|
|
@@ -350,7 +351,7 @@
|
|
|
350
351
|
"optional": true
|
|
351
352
|
}
|
|
352
353
|
},
|
|
353
|
-
"version": "1.
|
|
354
|
+
"version": "1.7.0",
|
|
354
355
|
"dependencies": {
|
|
355
356
|
"@aws-amplify/adapter-nextjs": "^1.7.3",
|
|
356
357
|
"@aws-crypto/sha256-js": "5.2.0",
|
|
@@ -376,7 +377,9 @@
|
|
|
376
377
|
"clsx": "^2.1.1",
|
|
377
378
|
"cmdk": "^1.1.1",
|
|
378
379
|
"cyclotron": "https://github.com/AnthusAI/Cyclotron/releases/download/ui-v0.2.2/cyclotron-0.2.2.tgz",
|
|
380
|
+
"d3": "^7.9.0",
|
|
379
381
|
"esbuild": "^0.28.2",
|
|
382
|
+
"framer-motion": "^14.3.0",
|
|
380
383
|
"gray-matter": "^4.0.3",
|
|
381
384
|
"gsap": "^3.15.0",
|
|
382
385
|
"lucide-react": "^1.16.0",
|
|
@@ -385,6 +388,7 @@
|
|
|
385
388
|
"shadcn": "^4.8.0",
|
|
386
389
|
"tailwind-merge": "^3.6.0",
|
|
387
390
|
"tailwindcss": "^4.3.0",
|
|
391
|
+
"three": "^0.186.1",
|
|
388
392
|
"tsx": "^4.23.15",
|
|
389
393
|
"tw-animate-css": "^1.4.0",
|
|
390
394
|
"use-stick-to-bottom": "^1.1.4",
|
|
@@ -13,6 +13,7 @@ import { PresentationFooter } from "../../components/presentation-footer";
|
|
|
13
13
|
import { PresentationHeader } from "../../components/presentation-header";
|
|
14
14
|
import { useBlogHeaderObstacles } from "../../components/use-blog-header-obstacles";
|
|
15
15
|
import { useRhythmOverlay } from "../../components/use-rhythm-overlay";
|
|
16
|
+
import { useMeasuredWidth } from "./presentation-shared";
|
|
16
17
|
import { BLOG_RHYTHM, getFeaturedLayoutStyle, getRhythmShellStyle } from "./rhythm-shell-style";
|
|
17
18
|
|
|
18
19
|
const BlogPageBackground = SITE_BRAND.components?.BlogPageBackground ?? GenericBlogPageBackground;
|
|
@@ -135,24 +136,6 @@ export function RhythmArticlePage({
|
|
|
135
136
|
);
|
|
136
137
|
}
|
|
137
138
|
|
|
138
|
-
function useMeasuredWidth(ref: RefObject<HTMLElement | null>): number {
|
|
139
|
-
const [width, setWidth] = useState(0);
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
const node = ref.current;
|
|
142
|
-
if (!node) return;
|
|
143
|
-
const update = () => setWidth(Math.max(1, Math.floor(node.getBoundingClientRect().width)));
|
|
144
|
-
update();
|
|
145
|
-
const observer = new ResizeObserver(update);
|
|
146
|
-
observer.observe(node);
|
|
147
|
-
window.addEventListener("resize", update);
|
|
148
|
-
return () => {
|
|
149
|
-
observer.disconnect();
|
|
150
|
-
window.removeEventListener("resize", update);
|
|
151
|
-
};
|
|
152
|
-
}, [ref]);
|
|
153
|
-
return width;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
139
|
function useViewportWidth(): number {
|
|
157
140
|
const [width, setWidth] = useState(0);
|
|
158
141
|
useEffect(() => {
|
package/routes.manifest.json
CHANGED