@deskwork/studio 0.10.2 → 0.11.1
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/dist/lib/editorial-skills-catalogue.d.ts +15 -1
- package/dist/lib/editorial-skills-catalogue.d.ts.map +1 -1
- package/dist/lib/editorial-skills-catalogue.js +66 -59
- package/dist/lib/editorial-skills-catalogue.js.map +1 -1
- package/dist/lib/entry-resolver.d.ts +22 -0
- package/dist/lib/entry-resolver.d.ts.map +1 -0
- package/dist/lib/entry-resolver.js +42 -0
- package/dist/lib/entry-resolver.js.map +1 -0
- package/dist/lib/stage-affordances.d.ts +31 -0
- package/dist/lib/stage-affordances.d.ts.map +1 -0
- package/dist/lib/stage-affordances.js +37 -0
- package/dist/lib/stage-affordances.js.map +1 -0
- package/dist/pages/dashboard/affordances.d.ts +41 -0
- package/dist/pages/dashboard/affordances.d.ts.map +1 -0
- package/dist/pages/dashboard/affordances.js +87 -0
- package/dist/pages/dashboard/affordances.js.map +1 -0
- package/dist/pages/dashboard/affordances.ts +95 -0
- package/dist/pages/dashboard/data.d.ts +24 -0
- package/dist/pages/dashboard/data.d.ts.map +1 -0
- package/dist/pages/dashboard/data.js +49 -0
- package/dist/pages/dashboard/data.js.map +1 -0
- package/dist/pages/dashboard/data.ts +56 -0
- package/dist/pages/dashboard/header.d.ts +13 -0
- package/dist/pages/dashboard/header.d.ts.map +1 -0
- package/dist/pages/dashboard/header.js +70 -0
- package/dist/pages/dashboard/header.js.map +1 -0
- package/dist/pages/dashboard/header.ts +80 -0
- package/dist/pages/dashboard/section.d.ts +37 -0
- package/dist/pages/dashboard/section.d.ts.map +1 -0
- package/dist/pages/dashboard/section.js +117 -0
- package/dist/pages/dashboard/section.js.map +1 -0
- package/dist/pages/dashboard/section.ts +132 -0
- package/dist/pages/dashboard.d.ts +30 -21
- package/dist/pages/dashboard.d.ts.map +1 -1
- package/dist/pages/dashboard.js +34 -799
- package/dist/pages/dashboard.js.map +1 -1
- package/dist/pages/dashboard.ts +44 -980
- package/dist/pages/entry-review.d.ts +25 -0
- package/dist/pages/entry-review.d.ts.map +1 -0
- package/dist/pages/entry-review.js +148 -0
- package/dist/pages/entry-review.js.map +1 -0
- package/dist/pages/entry-review.ts +185 -0
- package/dist/pages/help.d.ts +10 -5
- package/dist/pages/help.d.ts.map +1 -1
- package/dist/pages/help.js +113 -99
- package/dist/pages/help.js.map +1 -1
- package/dist/pages/help.ts +113 -99
- package/dist/pages/index.d.ts +13 -1
- package/dist/pages/index.d.ts.map +1 -1
- package/dist/pages/index.js +39 -24
- package/dist/pages/index.js.map +1 -1
- package/dist/pages/index.ts +43 -27
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +23 -3
- package/dist/server.js.map +1 -1
- package/package.json +4 -4
package/dist/pages/dashboard.js
CHANGED
|
@@ -1,816 +1,58 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Studio dashboard page — `/dev/editorial-studio`.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Pipeline-redesign Task 34. The dashboard renders eight stage
|
|
5
|
+
* sections — Ideas → Planned → Outlining → Drafting → Final →
|
|
6
|
+
* Published, plus Blocked and Cancelled — backed by sidecar reads
|
|
7
|
+
* under `<projectRoot>/.deskwork/entries/*.json`. Each row carries
|
|
8
|
+
* the entry's iteration count for its current stage and a
|
|
9
|
+
* reviewState badge so an operator can see at a glance where each
|
|
10
|
+
* entry sits without opening it.
|
|
9
11
|
*
|
|
10
|
-
*
|
|
11
|
-
* (
|
|
12
|
-
*
|
|
12
|
+
* Replaces the legacy calendar.md + workflow store rendering. The
|
|
13
|
+
* scaffold (folio, masthead, filter strip, layout) is preserved so
|
|
14
|
+
* existing CSS keeps working.
|
|
13
15
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* The renderer's data flow:
|
|
17
|
+
* 1. loadDashboardData reads every sidecar and groups by stage.
|
|
18
|
+
* 2. Each of the eight stages renders via `renderStageSection`.
|
|
19
|
+
* 3. The Distribution placeholder pins beneath the stage sections.
|
|
20
|
+
*
|
|
21
|
+
* The legacy export `renderDashboard` stays — server.ts wires it as
|
|
22
|
+
* the page handler. The `getIndex` parameter is preserved for
|
|
23
|
+
* signature compatibility with the override resolver in server.ts;
|
|
24
|
+
* the new dashboard does not currently consume it (sidecars are the
|
|
25
|
+
* data source, not the on-disk content tree).
|
|
20
26
|
*/
|
|
21
|
-
import { readCalendar } from '@deskwork/core/calendar';
|
|
22
|
-
import { buildReport, } from '@deskwork/core/review/report';
|
|
23
|
-
import { readWorkflows } from '@deskwork/core/review/pipeline';
|
|
24
|
-
import { bodyState } from '@deskwork/core/body-state';
|
|
25
|
-
import { countScrapbook, countScrapbookForEntry } from '@deskwork/core/scrapbook';
|
|
26
|
-
import { PLATFORMS, STAGES, effectiveContentType, hasRepoContent, } from '@deskwork/core/types';
|
|
27
|
-
import { resolveCalendarPath, resolveBlogFilePath, findEntryFile, } from '@deskwork/core/paths';
|
|
28
27
|
import { html, unsafe } from "./html.js";
|
|
29
28
|
import { layout } from "./layout.js";
|
|
30
29
|
import { renderEditorialFolio } from "./chrome.js";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
'youtube',
|
|
35
|
-
'instagram',
|
|
36
|
-
];
|
|
37
|
-
const STAGE_ORNAMENTS = {
|
|
38
|
-
Ideas: '◇',
|
|
39
|
-
Planned: '§',
|
|
40
|
-
Outlining: '⊹',
|
|
41
|
-
Drafting: '✎',
|
|
42
|
-
Review: '※',
|
|
43
|
-
Paused: '⏸',
|
|
44
|
-
Published: '✓',
|
|
45
|
-
};
|
|
46
|
-
const MONTH_NAMES = [
|
|
47
|
-
'January', 'February', 'March', 'April', 'May', 'June',
|
|
48
|
-
'July', 'August', 'September', 'October', 'November', 'December',
|
|
49
|
-
];
|
|
50
|
-
function isPlatform(value) {
|
|
51
|
-
return PLATFORMS.includes(value);
|
|
52
|
-
}
|
|
53
|
-
function siteLabel(site) {
|
|
54
|
-
return site.slice(0, 2).toUpperCase();
|
|
55
|
-
}
|
|
56
|
-
function stateLabel(state) {
|
|
57
|
-
return state.replace('-', ' ');
|
|
58
|
-
}
|
|
30
|
+
import { loadDashboardData, DASHBOARD_STAGE_ORDER } from "./dashboard/data.js";
|
|
31
|
+
import { renderStageSection, renderDistributionPlaceholder, } from "./dashboard/section.js";
|
|
32
|
+
import { renderHeader, renderFilterStrip } from "./dashboard/header.js";
|
|
59
33
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* falling back to the slug for legacy data (workflows / entries
|
|
63
|
-
* created before frontmatter ids landed). The function is overloaded
|
|
64
|
-
* via two arities — `covKey(site, slug)` for slug-only callers and
|
|
65
|
-
* `covKey(site, slug, entryId)` for callers that have access to the
|
|
66
|
-
* id. The latter form picks `entryId` when it's a non-empty string,
|
|
67
|
-
* else falls through to `slug`. Display still uses slug as the human
|
|
68
|
-
* label; this key only correlates internally.
|
|
69
|
-
*
|
|
70
|
-
* The "fallback" here is the legacy migration path — not the kind of
|
|
71
|
-
* silent fallback the project rules forbid. Doctor reports the legacy
|
|
72
|
-
* cases so operators can backfill ids.
|
|
34
|
+
* Render the studio dashboard. Async because sidecar reads hit disk;
|
|
35
|
+
* the route handler in server.ts awaits the result before sending it.
|
|
73
36
|
*/
|
|
74
|
-
function
|
|
75
|
-
|
|
76
|
-
? entryId
|
|
77
|
-
: slug;
|
|
78
|
-
return `${site}::${stable}`;
|
|
79
|
-
}
|
|
80
|
-
function fmtRelTime(iso, now) {
|
|
81
|
-
const t = new Date(iso).getTime();
|
|
82
|
-
const s = Math.max(0, Math.floor((now.getTime() - t) / 1000));
|
|
83
|
-
if (s < 60)
|
|
84
|
-
return `${s}s ago`;
|
|
85
|
-
const m = Math.floor(s / 60);
|
|
86
|
-
if (m < 60)
|
|
87
|
-
return `${m}m ago`;
|
|
88
|
-
const h = Math.floor(m / 60);
|
|
89
|
-
if (h < 48)
|
|
90
|
-
return `${h}h ago`;
|
|
91
|
-
return `${Math.floor(h / 24)}d ago`;
|
|
92
|
-
}
|
|
93
|
-
function workflowLink(w) {
|
|
94
|
-
if (w.contentKind === 'shortform') {
|
|
95
|
-
// Phase 21c: shortform now renders inside the unified review
|
|
96
|
-
// surface. Workflow-id deep-links land on the right workflow
|
|
97
|
-
// without first resolving an entry id — the route handler
|
|
98
|
-
// recognises a workflow id and dispatches accordingly.
|
|
99
|
-
return `/dev/editorial-review/${w.id}`;
|
|
100
|
-
}
|
|
101
|
-
// Phase 19d: prefer the canonical id-based URL when the workflow
|
|
102
|
-
// carries entryId. The legacy slug URL still works (server.ts will
|
|
103
|
-
// 302-redirect it), but emitting the canonical form skips the
|
|
104
|
-
// redirect round trip and makes the UI's outbound links honest.
|
|
105
|
-
const key = w.entryId ?? w.slug;
|
|
106
|
-
const kindBit = w.contentKind === 'outline' ? '&kind=outline' : '';
|
|
107
|
-
return `/dev/editorial-review/${key}?site=${w.site}${kindBit}`;
|
|
108
|
-
}
|
|
109
|
-
function blogPreviewLink(site, slug, host, entry) {
|
|
110
|
-
if (entry.stage === 'Published')
|
|
111
|
-
return `https://${host}/blog/${slug}/`;
|
|
112
|
-
// Phase 19d: prefer the canonical id-based URL.
|
|
113
|
-
const key = entry.id ?? slug;
|
|
114
|
-
return `/dev/editorial-review/${key}?site=${site}`;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Issue #110: when a calendar entry has no open workflow, the row
|
|
118
|
-
* still needs a navigation target so it doesn't read as decoration.
|
|
119
|
-
* The content-detail page (`/dev/content/<site>/<root>?node=<slug>`)
|
|
120
|
-
* is the right surface — it shows frontmatter + body + scrapbook for
|
|
121
|
-
* the entry without requiring a review workflow. Workflow-linked
|
|
122
|
-
* entries keep their `/dev/editorial-review/<id>` target via
|
|
123
|
-
* `workflowLink` above.
|
|
124
|
-
*
|
|
125
|
-
* The `<root>` segment is the entry slug's first path segment (the
|
|
126
|
-
* project root). For flat slugs (`the-outbound`), the project root
|
|
127
|
-
* IS the slug itself; for hierarchical slugs (`projects/x/y`), it's
|
|
128
|
-
* the first segment.
|
|
129
|
-
*/
|
|
130
|
-
function contentDetailLink(site, slug) {
|
|
131
|
-
const root = slug.split('/')[0];
|
|
132
|
-
return `/dev/content/${encodeURIComponent(site)}/${encodeURIComponent(root)}?node=${encodeURIComponent(slug)}`;
|
|
133
|
-
}
|
|
134
|
-
function loadDashboardData(ctx, getIndex) {
|
|
135
|
-
// `getIndex` is currently consumed downstream by renderRow →
|
|
136
|
-
// entryBodyStateOf, not here. Threading it through keeps the call
|
|
137
|
-
// signature symmetric with renderDashboard and leaves room for
|
|
138
|
-
// future load-time uses (e.g., joining workflows by entry id).
|
|
37
|
+
export async function renderDashboard(ctx, getIndex) {
|
|
38
|
+
// Touch the parameter so the unused-param check stays satisfied.
|
|
139
39
|
void getIndex;
|
|
140
|
-
const
|
|
141
|
-
const distributions = [];
|
|
142
|
-
const slugsBySite = {};
|
|
143
|
-
const sites = Object.keys(ctx.config.sites);
|
|
144
|
-
for (const site of sites) {
|
|
145
|
-
slugsBySite[site] = [];
|
|
146
|
-
const calendarPath = resolveCalendarPath(ctx.projectRoot, ctx.config, site);
|
|
147
|
-
const cal = readCalendar(calendarPath);
|
|
148
|
-
// Build a slug → id map up front so distributions can resolve
|
|
149
|
-
// their entry's stable id even when the DistributionRecord
|
|
150
|
-
// pre-dates the entryId field.
|
|
151
|
-
const idBySlug = new Map();
|
|
152
|
-
for (const entry of cal.entries) {
|
|
153
|
-
calendarEntries.push({ site, entry });
|
|
154
|
-
slugsBySite[site].push(entry.slug);
|
|
155
|
-
if (entry.id)
|
|
156
|
-
idBySlug.set(entry.slug, entry.id);
|
|
157
|
-
}
|
|
158
|
-
for (const d of cal.distributions) {
|
|
159
|
-
const dr = d;
|
|
160
|
-
const entryId = dr.entryId ?? idBySlug.get(dr.slug) ?? null;
|
|
161
|
-
distributions.push({
|
|
162
|
-
site,
|
|
163
|
-
platform: dr.platform,
|
|
164
|
-
slug: dr.slug,
|
|
165
|
-
entryId,
|
|
166
|
-
shortform: typeof dr.shortform === 'string' && dr.shortform.length > 0,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
const workflows = readWorkflows(ctx.projectRoot, ctx.config);
|
|
171
|
-
const approved = workflows.filter((w) => w.state === 'approved');
|
|
172
|
-
const terminal = workflows
|
|
173
|
-
.filter((w) => w.state === 'applied' || w.state === 'cancelled')
|
|
174
|
-
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
|
|
175
|
-
.slice(0, 10);
|
|
176
|
-
const shortformCoverage = new Map();
|
|
177
|
-
for (const d of distributions) {
|
|
178
|
-
if (!d.shortform)
|
|
179
|
-
continue;
|
|
180
|
-
if (!isPlatform(d.platform))
|
|
181
|
-
continue;
|
|
182
|
-
const key = covKey(d.site, d.slug, d.entryId);
|
|
183
|
-
const set = shortformCoverage.get(key) ?? new Set();
|
|
184
|
-
set.add(d.platform);
|
|
185
|
-
shortformCoverage.set(key, set);
|
|
186
|
-
}
|
|
187
|
-
// Phase 21c — shortform workflows count as coverage too. Distributions
|
|
188
|
-
// come from the calendar (an `editorial-publish` side-effect), so a
|
|
189
|
-
// freshly-started shortform draft (no published-yet distribution
|
|
190
|
-
// record) wouldn't show in the matrix without this branch.
|
|
191
|
-
for (const w of workflows) {
|
|
192
|
-
if (w.contentKind !== 'shortform')
|
|
193
|
-
continue;
|
|
194
|
-
if (w.state === 'applied' || w.state === 'cancelled')
|
|
195
|
-
continue;
|
|
196
|
-
if (!w.platform || !isPlatform(w.platform))
|
|
197
|
-
continue;
|
|
198
|
-
const key = covKey(w.site, w.slug, w.entryId);
|
|
199
|
-
const set = shortformCoverage.get(key) ?? new Set();
|
|
200
|
-
set.add(w.platform);
|
|
201
|
-
shortformCoverage.set(key, set);
|
|
202
|
-
}
|
|
203
|
-
const publishedBlogEntries = calendarEntries
|
|
204
|
-
.filter(({ entry }) => entry.stage === 'Published' && effectiveContentType(entry) === 'blog')
|
|
205
|
-
.sort((a, b) => (b.entry.datePublished ?? '').localeCompare(a.entry.datePublished ?? ''));
|
|
206
|
-
const activeBySitedSlug = new Map();
|
|
207
|
-
for (const w of workflows) {
|
|
208
|
-
if (w.state === 'applied' || w.state === 'cancelled')
|
|
209
|
-
continue;
|
|
210
|
-
const key = covKey(w.site, w.slug, w.entryId);
|
|
211
|
-
const list = activeBySitedSlug.get(key) ?? [];
|
|
212
|
-
list.push(w);
|
|
213
|
-
activeBySitedSlug.set(key, list);
|
|
214
|
-
}
|
|
215
|
-
const report = buildReport(ctx.projectRoot, ctx.config, {});
|
|
216
|
-
return {
|
|
217
|
-
calendarEntries,
|
|
218
|
-
distributions,
|
|
219
|
-
slugsBySite,
|
|
220
|
-
workflows,
|
|
221
|
-
approved,
|
|
222
|
-
terminal,
|
|
223
|
-
publishedBlogEntries,
|
|
224
|
-
shortformCoverage,
|
|
225
|
-
activeBySitedSlug,
|
|
226
|
-
report,
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
function entryBodyStateOf(ctx, site, entry, getIndex) {
|
|
230
|
-
if (!hasRepoContent(effectiveContentType(entry)))
|
|
231
|
-
return 'missing';
|
|
232
|
-
// When the entry has a stable id AND the route layer wired in a
|
|
233
|
-
// per-request index getter, use the id-driven content-index lookup
|
|
234
|
-
// — this matches files whose path doesn't follow the slug template
|
|
235
|
-
// (e.g., writingcontrol-shape projects where slug `the-outbound`
|
|
236
|
-
// resolves to `projects/the-outbound/index.md` while the calendar
|
|
237
|
-
// slug doesn't bake the path). Without an id or getter, fall back
|
|
238
|
-
// to the slug-template behavior so non-route callers still work.
|
|
239
|
-
if (entry.id !== undefined && entry.id !== '' && getIndex) {
|
|
240
|
-
const path = findEntryFile(ctx.projectRoot, ctx.config, site, entry.id, getIndex(site), { slug: entry.slug });
|
|
241
|
-
if (path !== undefined)
|
|
242
|
-
return bodyState(path);
|
|
243
|
-
}
|
|
244
|
-
const fallback = resolveBlogFilePath(ctx.projectRoot, ctx.config, site, entry.slug);
|
|
245
|
-
return bodyState(fallback);
|
|
246
|
-
}
|
|
247
|
-
function findStageWorkflow(data, site, entry, stage) {
|
|
248
|
-
const list = data.activeBySitedSlug.get(covKey(site, entry.slug, entry.id)) ?? [];
|
|
249
|
-
if (stage === 'Outlining')
|
|
250
|
-
return list.find((w) => w.contentKind === 'outline');
|
|
251
|
-
return list.find((w) => w.contentKind === 'longform');
|
|
252
|
-
}
|
|
253
|
-
// ---------------------------------------------------------------------------
|
|
254
|
-
// Section renderers
|
|
255
|
-
// ---------------------------------------------------------------------------
|
|
256
|
-
function renderHeader(data, ctx, now) {
|
|
257
|
-
const volume = '01';
|
|
258
|
-
const issueNum = String(data.workflows.length).padStart(2, '0');
|
|
259
|
-
const issueDate = `${now.getDate()} ${MONTH_NAMES[now.getMonth()]} ${now.getFullYear()}`;
|
|
260
|
-
return unsafe(html `
|
|
261
|
-
<header class="er-pagehead er-pagehead--centered">
|
|
262
|
-
<p class="er-pagehead__kicker">
|
|
263
|
-
Vol. ${volume} · № ${issueNum} · Press-check
|
|
264
|
-
</p>
|
|
265
|
-
<h1 class="er-pagehead__title">
|
|
266
|
-
Editorial <em>Studio</em>
|
|
267
|
-
</h1>
|
|
268
|
-
<p class="er-pagehead__deck">
|
|
269
|
-
Project: <code>${ctx.projectRoot}</code>
|
|
270
|
-
· <a class="er-link-marginalia" href="/dev/editorial-help">the manual</a>
|
|
271
|
-
</p>
|
|
272
|
-
<p class="er-pagehead__meta">
|
|
273
|
-
<span>${issueDate}</span>
|
|
274
|
-
<span class="sep">·</span>
|
|
275
|
-
<span>${data.calendarEntries.length} on the calendar</span>
|
|
276
|
-
<span class="sep">·</span>
|
|
277
|
-
<span>${data.activeBySitedSlug.size} in review</span>
|
|
278
|
-
<span class="sep">·</span>
|
|
279
|
-
<span>${data.approved.length} awaiting press</span>
|
|
280
|
-
</p>
|
|
281
|
-
</header>`);
|
|
282
|
-
}
|
|
283
|
-
function renderFilterStrip(sites) {
|
|
284
|
-
return unsafe(html `
|
|
285
|
-
<section class="er-filter" data-filter-strip>
|
|
286
|
-
<span class="er-filter-label">Find</span>
|
|
287
|
-
<input type="search" data-filter-input placeholder="slug, title…" autocomplete="off" />
|
|
288
|
-
<span class="er-filter-label er-filter-label--gap">Site</span>
|
|
289
|
-
<div class="er-chips" role="tablist">
|
|
290
|
-
<button class="er-chip" aria-pressed="true" data-site-chip="all">all</button>
|
|
291
|
-
${sites.map((s) => unsafe(html `<button class="er-chip" data-site-chip="${s}">${siteLabel(s).toLowerCase()}</button>`))}
|
|
292
|
-
</div>
|
|
293
|
-
<span class="er-filter-label er-filter-label--gap">Stage</span>
|
|
294
|
-
<div class="er-chips" role="tablist">
|
|
295
|
-
<button class="er-chip" aria-pressed="true" data-stage-chip="all">all</button>
|
|
296
|
-
${STAGES.map((s) => unsafe(html `<button class="er-chip" data-stage-chip="${s}">${s.toLowerCase()}</button>`))}
|
|
297
|
-
</div>
|
|
298
|
-
</section>`);
|
|
299
|
-
}
|
|
300
|
-
const STAGE_EMPTY_MESSAGES = {
|
|
301
|
-
Ideas: 'No open ideas. Run /deskwork:add to capture one.',
|
|
302
|
-
Planned: 'Nothing planned. /deskwork:plan <slug> to promote an idea.',
|
|
303
|
-
Outlining: 'Nothing in outlining. /deskwork:outline <slug> to start one.',
|
|
304
|
-
Drafting: 'No posts in drafting.',
|
|
305
|
-
Review: 'Nothing in review stage.',
|
|
306
|
-
Paused: 'Nothing paused. /deskwork:pause <slug> sets an entry aside without losing where it was.',
|
|
307
|
-
Published: 'No published posts yet.',
|
|
308
|
-
};
|
|
309
|
-
function renderRowMeta(ctx, site, entry, stage, hasFile, getIndex) {
|
|
310
|
-
const kind = effectiveContentType(entry);
|
|
311
|
-
const parts = [];
|
|
312
|
-
if (entry.targetKeywords && entry.targetKeywords.length > 0 && stage === 'Planned') {
|
|
313
|
-
parts.push(unsafe(html `<span class="er-calendar-meta"><em>kw:</em> ${entry.targetKeywords.join(', ')}</span>`));
|
|
314
|
-
}
|
|
315
|
-
if (entry.issueNumber && entry.issueNumber > 0) {
|
|
316
|
-
parts.push(unsafe(html `<span class="er-calendar-meta">issue #${entry.issueNumber}</span>`));
|
|
317
|
-
}
|
|
318
|
-
if (entry.datePublished && stage === 'Published') {
|
|
319
|
-
parts.push(unsafe(html `<span class="er-calendar-meta">${entry.datePublished}</span>`));
|
|
320
|
-
}
|
|
321
|
-
if (stage === 'Paused' && entry.pausedFrom) {
|
|
322
|
-
parts.push(unsafe(html `<span class="er-calendar-meta"><em>was:</em> ${entry.pausedFrom}</span>`));
|
|
323
|
-
}
|
|
324
|
-
if (kind !== 'blog') {
|
|
325
|
-
parts.push(unsafe(html `<span class="er-calendar-meta er-calendar-meta-kind">${kind}</span>`));
|
|
326
|
-
}
|
|
327
|
-
if (kind === 'blog' && hasFile) {
|
|
328
|
-
// Phase 19c+: prefer the id-driven content-index lookup so entries
|
|
329
|
-
// whose on-disk path doesn't match the slug template (e.g.
|
|
330
|
-
// writingcontrol-shape projects) report the correct count. When the
|
|
331
|
-
// entry has no id binding OR no per-request index getter is wired,
|
|
332
|
-
// fall through to the slug-template path. The fallback is the
|
|
333
|
-
// legacy migration path, not a silent default — doctor reports the
|
|
334
|
-
// unbound cases so operators can backfill ids.
|
|
335
|
-
const n = entry.id !== undefined && entry.id !== '' && getIndex
|
|
336
|
-
? countScrapbookForEntry(ctx.projectRoot, ctx.config, site, entry, getIndex(site))
|
|
337
|
-
: countScrapbook(ctx.projectRoot, ctx.config, site, entry.slug);
|
|
338
|
-
if (n > 0) {
|
|
339
|
-
const label = n === 1 ? 'scrapbook item' : 'scrapbook items';
|
|
340
|
-
parts.push(unsafe(html `<a class="er-calendar-meta er-calendar-meta-scrapbook er-calendar-meta-link"
|
|
341
|
-
href="/dev/scrapbook/${site}/${entry.slug}"
|
|
342
|
-
title="${n} ${label}">scrapbook · <span class="er-calendar-meta-scrapbook-count">${n}</span> →</a>`));
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return unsafe(parts.map((p) => p.__raw).join(''));
|
|
346
|
-
}
|
|
347
|
-
function renderRowActions(site, entry, stage, hasFile, bodyWritten, wf) {
|
|
348
|
-
const kind = effectiveContentType(entry);
|
|
349
|
-
const buttons = [];
|
|
350
|
-
if (stage === 'Ideas') {
|
|
351
|
-
buttons.push(html `<button class="er-btn er-btn-small er-copy-btn" type="button"
|
|
352
|
-
data-copy="/deskwork:plan --site ${site} ${entry.slug}" title="copy command">plan →</button>`);
|
|
353
|
-
}
|
|
354
|
-
if (stage === 'Planned' && !hasFile) {
|
|
355
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary" type="button"
|
|
356
|
-
data-action="scaffold-draft" data-site="${site}" data-slug="${entry.slug}">scaffold →</button>`);
|
|
357
|
-
}
|
|
358
|
-
if (stage === 'Planned' && hasFile) {
|
|
359
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary er-copy-btn" type="button"
|
|
360
|
-
data-copy="/deskwork:outline --site ${site} ${entry.slug}"
|
|
361
|
-
title="scaffold file exists — copy to sketch the outline in Claude Code">outline →</button>`);
|
|
362
|
-
}
|
|
363
|
-
if (stage === 'Outlining' && wf && wf.state === 'iterating') {
|
|
364
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary er-copy-btn" type="button"
|
|
365
|
-
data-copy="/deskwork:iterate --kind outline --site ${site} ${entry.slug}"
|
|
366
|
-
title="operator clicked Iterate">iterate outline →</button>`);
|
|
367
|
-
}
|
|
368
|
-
if (stage === 'Outlining' && wf && wf.state === 'approved') {
|
|
369
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-approve er-copy-btn" type="button"
|
|
370
|
-
data-copy="/deskwork:approve --site ${site} ${entry.slug}"
|
|
371
|
-
title="outline approved — advance to Drafting">approve outline →</button>`);
|
|
372
|
-
}
|
|
373
|
-
if (stage === 'Outlining' &&
|
|
374
|
-
wf &&
|
|
375
|
-
(wf.state === 'open' || wf.state === 'in-review')) {
|
|
376
|
-
buttons.push(html `<a class="er-btn er-btn-small" href="${workflowLink(wf)}"
|
|
377
|
-
title="open the review surface to annotate / edit the outline">review outline →</a>`);
|
|
378
|
-
}
|
|
379
|
-
if (stage === 'Outlining' && !wf) {
|
|
380
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary er-copy-btn" type="button"
|
|
381
|
-
data-copy="/deskwork:outline --site ${site} ${entry.slug}"
|
|
382
|
-
title="no outline workflow found — copy to (re)start one">outline →</button>`);
|
|
383
|
-
}
|
|
384
|
-
if ((stage === 'Drafting' || stage === 'Review') && !bodyWritten) {
|
|
385
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary er-copy-btn" type="button"
|
|
386
|
-
data-copy="/deskwork:draft --site ${site} ${entry.slug}"
|
|
387
|
-
title="body is still the placeholder">draft body →</button>`);
|
|
388
|
-
}
|
|
389
|
-
if ((stage === 'Drafting' || stage === 'Review') && bodyWritten && !wf) {
|
|
390
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary" type="button"
|
|
391
|
-
data-action="enqueue-review" data-site="${site}" data-slug="${entry.slug}"
|
|
392
|
-
title="body is drafted — create a longform review workflow">review →</button>`);
|
|
393
|
-
}
|
|
394
|
-
if (stage === 'Drafting' || stage === 'Review') {
|
|
395
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-approve" type="button"
|
|
396
|
-
data-action="mark-published" data-site="${site}" data-slug="${entry.slug}"
|
|
397
|
-
title="flip to Published + set date">publish →</button>`);
|
|
398
|
-
}
|
|
399
|
-
if (stage === 'Published' && !wf) {
|
|
400
|
-
buttons.push(html `<button class="er-btn er-btn-small er-copy-btn" type="button"
|
|
401
|
-
data-copy="/deskwork:review-start --site ${site} ${entry.slug}"
|
|
402
|
-
title="re-review a published post">re-review</button>`);
|
|
403
|
-
}
|
|
404
|
-
// #27 — Paused gets a "resume" copy; pausable stages get a "pause" copy.
|
|
405
|
-
if (stage === 'Paused') {
|
|
406
|
-
buttons.push(html `<button class="er-btn er-btn-small er-btn-primary er-copy-btn" type="button"
|
|
407
|
-
data-copy="/deskwork:resume --site ${site} ${entry.slug}"
|
|
408
|
-
title="restore to ${entry.pausedFrom ?? 'prior stage'}">resume →</button>`);
|
|
409
|
-
}
|
|
410
|
-
else if (stage === 'Ideas' ||
|
|
411
|
-
stage === 'Planned' ||
|
|
412
|
-
stage === 'Outlining' ||
|
|
413
|
-
stage === 'Drafting' ||
|
|
414
|
-
stage === 'Review') {
|
|
415
|
-
buttons.push(html `<button class="er-btn er-btn-small er-copy-btn" type="button"
|
|
416
|
-
data-copy="/deskwork:pause --site ${site} ${entry.slug}"
|
|
417
|
-
title="set aside without losing the prior stage">pause</button>`);
|
|
418
|
-
}
|
|
419
|
-
if (kind === 'blog') {
|
|
420
|
-
buttons.push(html `<button class="er-btn er-btn-small" type="button" data-action="rename-open"
|
|
421
|
-
title="rename the slug">rename →</button>`);
|
|
422
|
-
}
|
|
423
|
-
return unsafe(`<span class="er-calendar-action">${buttons.join('')}</span>`);
|
|
424
|
-
}
|
|
425
|
-
function renderRow(ctx, data, sited, stage, index, getIndex) {
|
|
426
|
-
const { site, entry } = sited;
|
|
427
|
-
const kind = effectiveContentType(entry);
|
|
428
|
-
const body = entryBodyStateOf(ctx, site, entry, getIndex);
|
|
429
|
-
const hasFile = body !== 'missing';
|
|
430
|
-
const bodyWritten = body === 'written';
|
|
431
|
-
const wf = findStageWorkflow(data, site, entry, stage);
|
|
432
|
-
const search = [
|
|
433
|
-
entry.slug,
|
|
434
|
-
entry.title,
|
|
435
|
-
(entry.targetKeywords ?? []).join(' '),
|
|
436
|
-
kind,
|
|
437
|
-
site,
|
|
438
|
-
].join(' ').toLowerCase();
|
|
439
|
-
const host = ctx.config.sites[site]?.host ?? site;
|
|
440
|
-
// Issue #110: every row gets a link target. Workflow-linked rows
|
|
441
|
-
// open the review surface; Published rows link to the public host
|
|
442
|
-
// URL; everything else links to the content-detail page so the
|
|
443
|
-
// operator can read the entry's frontmatter, body, and scrapbook
|
|
444
|
-
// without inventing a workflow.
|
|
445
|
-
const slugLink = wf
|
|
446
|
-
? workflowLink(wf)
|
|
447
|
-
: entry.stage === 'Published'
|
|
448
|
-
? blogPreviewLink(site, entry.slug, host, entry)
|
|
449
|
-
: contentDetailLink(site, entry.slug);
|
|
450
|
-
const slugTitle = wf
|
|
451
|
-
? 'open the review surface'
|
|
452
|
-
: entry.stage === 'Published'
|
|
453
|
-
? 'read the published article'
|
|
454
|
-
: 'view content details';
|
|
455
|
-
const slugCell = unsafe(html `<a href="${slugLink}" title="${slugTitle}">${entry.slug}</a>`);
|
|
456
|
-
const fileDot = hasRepoContent(kind)
|
|
457
|
-
? unsafe(html `<span class="er-file-dot er-file-${body}"
|
|
458
|
-
title="${body === 'missing'
|
|
459
|
-
? 'no blog file'
|
|
460
|
-
: body === 'placeholder'
|
|
461
|
-
? 'scaffold present, body is the placeholder'
|
|
462
|
-
: 'body written'}">●</span>`)
|
|
463
|
-
: '';
|
|
464
|
-
const stamp = wf
|
|
465
|
-
? unsafe(html `<span class="er-stamp er-stamp-${wf.state}">${stateLabel(wf.state)} v${wf.currentVersion}</span>`)
|
|
466
|
-
: '';
|
|
467
|
-
const renameForm = kind === 'blog'
|
|
468
|
-
? unsafe(html `<form class="er-rename-inline" data-rename-form
|
|
469
|
-
data-site="${site}" data-slug="${entry.slug}" hidden>
|
|
470
|
-
<span class="er-rename-kicker" aria-hidden="true">rename →</span>
|
|
471
|
-
<code class="er-rename-old" title="current slug; will 301 after rename">${entry.slug}</code>
|
|
472
|
-
<span class="er-rename-arrow" aria-hidden="true">→</span>
|
|
473
|
-
<input type="text" name="new-slug" data-rename-input autocomplete="off" spellcheck="false"
|
|
474
|
-
placeholder="new-slug-here" aria-label="new slug" required />
|
|
475
|
-
<small class="er-rename-hint" data-rename-hint>lowercase, digits, hyphens</small>
|
|
476
|
-
<button type="button" class="er-btn er-btn-small" data-action="rename-cancel">cancel</button>
|
|
477
|
-
<button type="submit" class="er-btn er-btn-small er-btn-primary"
|
|
478
|
-
data-action="rename-copy">copy /rename →</button>
|
|
479
|
-
</form>`)
|
|
480
|
-
: '';
|
|
481
|
-
// Hierarchical entries (slugs containing `/`) get a depth indicator the
|
|
482
|
-
// CSS layer indents off of. Storage stays flat; this is a display-only
|
|
483
|
-
// marker. Depth = number of `/` in the slug (so "the-outbound" → 0,
|
|
484
|
-
// "the-outbound/characters" → 1, etc.).
|
|
485
|
-
const depth = entry.slug.split('/').length - 1;
|
|
486
|
-
const depthAttrs = depth > 0
|
|
487
|
-
? unsafe(html ` data-depth="${depth}" style="--er-row-depth: ${depth}"`)
|
|
488
|
-
: '';
|
|
489
|
-
// For nested entries, show only the leaf segment as the prominent
|
|
490
|
-
// identifier — the ancestor segments are implied by the visual indent
|
|
491
|
-
// and the position in the sorted list. Issue #110: the hierarchical
|
|
492
|
-
// shape still wraps in an <a> so the row has a link target.
|
|
493
|
-
const slugDisplay = depth > 0
|
|
494
|
-
? unsafe(html `<a href="${slugLink}" title="${slugTitle}"><span class="er-row-slug-ancestors" aria-hidden="true">${entry.slug.slice(0, entry.slug.lastIndexOf('/') + 1)}</span><span class="er-row-slug-leaf">${entry.slug.slice(entry.slug.lastIndexOf('/') + 1)}</span></a>`)
|
|
495
|
-
: '';
|
|
496
|
-
const slugCellWithHierarchy = depth > 0 ? slugDisplay : slugCell;
|
|
497
|
-
return unsafe(html `
|
|
498
|
-
<div class="er-calendar-row-wrap" data-row-wrap data-search="${search}"${depthAttrs}>
|
|
499
|
-
<div class="er-calendar-row" data-stage="${stage}" data-site="${site}"
|
|
500
|
-
data-slug="${entry.slug}" data-search="${search}">
|
|
501
|
-
<span class="er-row-num">№ ${String(index + 1).padStart(2, '0')}</span>
|
|
502
|
-
<div class="er-calendar-body">
|
|
503
|
-
<span class="er-row-site er-row-site--${site}" title="${host}">${siteLabel(site)}</span>
|
|
504
|
-
<span class="er-row-slug">${depth > 0 ? slugCellWithHierarchy : slugCell}</span>
|
|
505
|
-
<span class="er-calendar-title">${entry.title}</span>
|
|
506
|
-
${renderRowMeta(ctx, site, entry, stage, hasFile, getIndex)}
|
|
507
|
-
</div>
|
|
508
|
-
<span class="er-calendar-status">${fileDot}${stamp}</span>
|
|
509
|
-
${renderRowActions(site, entry, stage, hasFile, bodyWritten, wf)}
|
|
510
|
-
</div>
|
|
511
|
-
${renameForm}
|
|
512
|
-
</div>`);
|
|
513
|
-
}
|
|
514
|
-
function renderStageSection(ctx, data, stage, entries, sites, getIndex) {
|
|
515
|
-
const intakeBlock = stage === 'Ideas'
|
|
516
|
-
? unsafe(html `
|
|
517
|
-
<div class="er-intake-form" data-intake-form hidden>
|
|
518
|
-
<p class="er-intake-hint">
|
|
519
|
-
Fill in what you know; the agent will use the values verbatim.
|
|
520
|
-
</p>
|
|
521
|
-
<div class="er-intake-grid">
|
|
522
|
-
<label>
|
|
523
|
-
<span>Site</span>
|
|
524
|
-
<select data-intake-field="site">
|
|
525
|
-
${sites.map((s) => unsafe(html `<option value="${s}">${s}</option>`))}
|
|
526
|
-
</select>
|
|
527
|
-
</label>
|
|
528
|
-
<label>
|
|
529
|
-
<span>Content type</span>
|
|
530
|
-
<select data-intake-field="contentType">
|
|
531
|
-
<option value="blog">blog (default)</option>
|
|
532
|
-
<option value="youtube">youtube</option>
|
|
533
|
-
<option value="tool">tool</option>
|
|
534
|
-
</select>
|
|
535
|
-
</label>
|
|
536
|
-
<label class="er-intake-wide">
|
|
537
|
-
<span>Title</span>
|
|
538
|
-
<input type="text" data-intake-field="title" placeholder="Working title" />
|
|
539
|
-
</label>
|
|
540
|
-
<label class="er-intake-wide">
|
|
541
|
-
<span>Description</span>
|
|
542
|
-
<textarea data-intake-field="description" rows="4"></textarea>
|
|
543
|
-
</label>
|
|
544
|
-
<label class="er-intake-wide" data-intake-content-url hidden>
|
|
545
|
-
<span>Content URL</span>
|
|
546
|
-
<input type="url" data-intake-field="contentUrl" placeholder="https://..." />
|
|
547
|
-
</label>
|
|
548
|
-
</div>
|
|
549
|
-
<div class="er-intake-actions">
|
|
550
|
-
<button class="er-btn er-btn-small" type="button" data-action="intake-cancel">cancel</button>
|
|
551
|
-
<button class="er-btn er-btn-small er-btn-primary" type="button"
|
|
552
|
-
data-action="intake-copy">copy intake →</button>
|
|
553
|
-
</div>
|
|
554
|
-
</div>`)
|
|
555
|
-
: '';
|
|
556
|
-
const intakeButton = stage === 'Ideas'
|
|
557
|
-
? unsafe(html `<button class="er-btn er-btn-small er-section-action" type="button"
|
|
558
|
-
data-action="intake-toggle"
|
|
559
|
-
title="fill out an intake sheet">intake new idea →</button>`)
|
|
560
|
-
: '';
|
|
561
|
-
const body = entries.length === 0
|
|
562
|
-
? unsafe(html `<div class="er-empty" style="padding: 1rem 0.25rem; font-size: 0.95rem;">
|
|
563
|
-
${STAGE_EMPTY_MESSAGES[stage]}
|
|
564
|
-
</div>`)
|
|
565
|
-
: unsafe(entries
|
|
566
|
-
.map((e, i) => renderRow(ctx, data, e, stage, i, getIndex).__raw)
|
|
567
|
-
.join(''));
|
|
568
|
-
return unsafe(html `
|
|
569
|
-
<section class="er-section" id="stage-${stage.toLowerCase()}" data-stage-section="${stage}">
|
|
570
|
-
<h2 class="er-section-head">
|
|
571
|
-
<span>${stage}</span>
|
|
572
|
-
<span class="ornament">${STAGE_ORNAMENTS[stage]}</span>
|
|
573
|
-
<span class="count">№ ${entries.length}</span>
|
|
574
|
-
${intakeButton}
|
|
575
|
-
</h2>
|
|
576
|
-
${intakeBlock}
|
|
577
|
-
${body}
|
|
578
|
-
</section>`);
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Shortform workflow lookup keyed by (site, entryId|slug, platform).
|
|
582
|
-
* Built once per dashboard render so the coverage matrix can render
|
|
583
|
-
* each covered cell as a direct link to the workflow's review surface
|
|
584
|
-
* — phase 21c replaces the prior "✓" sigil + copy-CLI-command flow.
|
|
585
|
-
*/
|
|
586
|
-
function indexShortformWorkflows(data) {
|
|
587
|
-
const out = new Map();
|
|
588
|
-
for (const w of data.workflows) {
|
|
589
|
-
if (w.contentKind !== 'shortform')
|
|
590
|
-
continue;
|
|
591
|
-
if (w.state === 'applied' || w.state === 'cancelled')
|
|
592
|
-
continue;
|
|
593
|
-
if (!w.platform)
|
|
594
|
-
continue;
|
|
595
|
-
const key = `${covKey(w.site, w.slug, w.entryId)}::${w.platform}`;
|
|
596
|
-
out.set(key, w);
|
|
597
|
-
}
|
|
598
|
-
return out;
|
|
599
|
-
}
|
|
600
|
-
function renderShortformMatrix(data, ctx) {
|
|
601
|
-
if (data.publishedBlogEntries.length === 0)
|
|
602
|
-
return unsafe('');
|
|
603
|
-
const wfIndex = indexShortformWorkflows(data);
|
|
604
|
-
const rows = data.publishedBlogEntries.map(({ site, entry }) => {
|
|
605
|
-
const covered = data.shortformCoverage.get(covKey(site, entry.slug, entry.id)) ??
|
|
606
|
-
new Set();
|
|
607
|
-
const cells = PLATFORMS_ORDER.map((p) => {
|
|
608
|
-
const has = covered.has(p);
|
|
609
|
-
const wfKey = `${covKey(site, entry.slug, entry.id)}::${p}`;
|
|
610
|
-
const wf = wfIndex.get(wfKey);
|
|
611
|
-
// A covered cell with a live workflow → link straight into the
|
|
612
|
-
// unified review surface. A covered cell without a workflow
|
|
613
|
-
// (distribution recorded outside the studio's pipeline — legacy
|
|
614
|
-
// data) keeps the static "✓" so the matrix doesn't lie about
|
|
615
|
-
// what's clickable. Empty cells render a real start button that
|
|
616
|
-
// POSTs to /api/dev/editorial-review/start-shortform and
|
|
617
|
-
// navigates to the new workflow's review URL.
|
|
618
|
-
let inner;
|
|
619
|
-
if (has && wf) {
|
|
620
|
-
inner = html `<a class="er-sf-link" href="/dev/editorial-review/${wf.id}"
|
|
621
|
-
title="${p} workflow · open in review">✓</a>`;
|
|
622
|
-
}
|
|
623
|
-
else if (has) {
|
|
624
|
-
inner = html `<span class="er-sf-check" title="${p} copy drafted">✓</span>`;
|
|
625
|
-
}
|
|
626
|
-
else {
|
|
627
|
-
inner = html `<button class="er-sf-start-btn" type="button"
|
|
628
|
-
data-action="start-shortform"
|
|
629
|
-
data-site="${site}"
|
|
630
|
-
data-slug="${entry.slug}"
|
|
631
|
-
data-platform="${p}"
|
|
632
|
-
title="Start a ${p} shortform draft for ${entry.slug}">start</button>`;
|
|
633
|
-
}
|
|
634
|
-
const cls = has ? 'er-sf-cell er-sf-cell-covered' : 'er-sf-cell er-sf-cell-empty';
|
|
635
|
-
return html `<td class="${cls}">${unsafe(inner)}</td>`;
|
|
636
|
-
}).join('');
|
|
637
|
-
const host = ctx.config.sites[site]?.host ?? site;
|
|
638
|
-
return html `
|
|
639
|
-
<tr data-site="${site}">
|
|
640
|
-
<th scope="row" class="er-sf-slug">
|
|
641
|
-
<span class="er-row-site er-row-site--${site}" title="${host}">${siteLabel(site)}</span>
|
|
642
|
-
${entry.slug}
|
|
643
|
-
</th>
|
|
644
|
-
${unsafe(cells)}
|
|
645
|
-
</tr>`;
|
|
646
|
-
}).join('');
|
|
647
|
-
return unsafe(html `
|
|
648
|
-
<section class="er-section">
|
|
649
|
-
<h2 class="er-section-head">
|
|
650
|
-
<span>Short form · coverage</span>
|
|
651
|
-
<span class="count">${data.publishedBlogEntries.length} × ${PLATFORMS_ORDER.length}</span>
|
|
652
|
-
</h2>
|
|
653
|
-
<table class="er-sf-matrix">
|
|
654
|
-
<thead>
|
|
655
|
-
<tr>
|
|
656
|
-
<th scope="col" class="er-sf-slug-col">slug</th>
|
|
657
|
-
${PLATFORMS_ORDER.map((p) => unsafe(html `<th scope="col" class="er-sf-platform er-sf-platform-${p}">${p}</th>`))}
|
|
658
|
-
</tr>
|
|
659
|
-
</thead>
|
|
660
|
-
<tbody>${unsafe(rows)}</tbody>
|
|
661
|
-
</table>
|
|
662
|
-
</section>`);
|
|
663
|
-
}
|
|
664
|
-
function renderApprovedSection(data, ctx) {
|
|
665
|
-
if (data.approved.length === 0)
|
|
666
|
-
return unsafe('');
|
|
667
|
-
const rows = data.approved
|
|
668
|
-
.map((w) => {
|
|
669
|
-
const host = ctx.config.sites[w.site]?.host ?? w.site;
|
|
670
|
-
const platformBit = w.contentKind === 'shortform' && w.platform
|
|
671
|
-
? html `<span class="er-row-channel"> · ${w.platform}${w.channel ? ` · ${w.channel}` : ''}</span>`
|
|
672
|
-
: '';
|
|
673
|
-
const flagBit = w.contentKind === 'shortform' && w.platform
|
|
674
|
-
? ` --platform ${w.platform}${w.channel ? ` --channel ${w.channel}` : ''}`
|
|
675
|
-
: '';
|
|
676
|
-
return html `
|
|
677
|
-
<a class="er-row" href="${workflowLink(w)}" data-slug="${w.slug}"
|
|
678
|
-
data-site="${w.site}" data-state="${w.state}">
|
|
679
|
-
<span class="er-row-num">→</span>
|
|
680
|
-
<span class="er-row-site er-row-site--${w.site}" title="${host}">${siteLabel(w.site)}</span>
|
|
681
|
-
<span class="er-row-slug">${w.slug}</span>
|
|
682
|
-
<span class="er-row-kind">${w.contentKind}${unsafe(platformBit)}</span>
|
|
683
|
-
<span class="er-stamp er-stamp-approved">approved</span>
|
|
684
|
-
<span class="er-row-ts">v${w.currentVersion}</span>
|
|
685
|
-
<span class="er-row-hint">
|
|
686
|
-
Run · <code>/deskwork:approve --site ${w.site} ${w.slug}${flagBit}</code>
|
|
687
|
-
</span>
|
|
688
|
-
</a>`;
|
|
689
|
-
})
|
|
690
|
-
.join('');
|
|
691
|
-
return unsafe(html `
|
|
692
|
-
<section class="er-section">
|
|
693
|
-
<h2 class="er-section-head">
|
|
694
|
-
<span>Awaiting press</span>
|
|
695
|
-
<span class="count">№ ${data.approved.length}</span>
|
|
696
|
-
</h2>
|
|
697
|
-
${unsafe(rows)}
|
|
698
|
-
</section>`);
|
|
699
|
-
}
|
|
700
|
-
function renderTerminalSection(data, ctx, now) {
|
|
701
|
-
if (data.terminal.length === 0)
|
|
702
|
-
return unsafe('');
|
|
703
|
-
// Issue #110: Recent proofs rows are now `<a>` so adopters can
|
|
704
|
-
// click into the historical review record (the review surface
|
|
705
|
-
// renders terminal workflows for inspection just as well as
|
|
706
|
-
// active ones).
|
|
707
|
-
const rows = data.terminal
|
|
708
|
-
.map((w) => {
|
|
709
|
-
const host = ctx.config.sites[w.site]?.host ?? w.site;
|
|
710
|
-
const platformBit = w.contentKind === 'shortform' && w.platform
|
|
711
|
-
? html `<span class="er-row-channel"> · ${w.platform}</span>`
|
|
712
|
-
: '';
|
|
713
|
-
return html `
|
|
714
|
-
<a class="er-row" href="${workflowLink(w)}" data-state="${w.state}" data-site="${w.site}"
|
|
715
|
-
title="open the ${w.state} review record">
|
|
716
|
-
<span class="er-row-num">—</span>
|
|
717
|
-
<span class="er-row-site er-row-site--${w.site}" title="${host}">${siteLabel(w.site)}</span>
|
|
718
|
-
<span class="er-row-slug" style="color: var(--er-ink-soft);">${w.slug}</span>
|
|
719
|
-
<span class="er-row-kind">${w.contentKind}${unsafe(platformBit)}</span>
|
|
720
|
-
<span class="er-stamp er-stamp-${w.state}">${w.state}</span>
|
|
721
|
-
<span class="er-row-ts">${fmtRelTime(w.updatedAt, now)}</span>
|
|
722
|
-
</a>`;
|
|
723
|
-
})
|
|
724
|
-
.join('');
|
|
725
|
-
return unsafe(html `
|
|
726
|
-
<section class="er-section">
|
|
727
|
-
<h2 class="er-section-head">
|
|
728
|
-
<span>Recent proofs</span>
|
|
729
|
-
<span class="count">last ${data.terminal.length}</span>
|
|
730
|
-
</h2>
|
|
731
|
-
${unsafe(rows)}
|
|
732
|
-
</section>`);
|
|
733
|
-
}
|
|
734
|
-
function renderSidebar(data) {
|
|
735
|
-
const totalTerminal = data.report.all.approvedCount + data.report.all.cancelledCount;
|
|
736
|
-
const hasEnoughSignal = totalTerminal >= 5;
|
|
737
|
-
const topTwo = data.report.topCategories.filter((c) => c.count > 0).slice(0, 2);
|
|
738
|
-
const driftBody = hasEnoughSignal && topTwo.length > 0
|
|
739
|
-
? unsafe(html `
|
|
740
|
-
<p class="er-drift-primary">
|
|
741
|
-
<em>${topTwo[0].category}</em>
|
|
742
|
-
<span class="count"> ${topTwo[0].count}</span>
|
|
743
|
-
</p>
|
|
744
|
-
${topTwo[1]
|
|
745
|
-
? unsafe(html `<p class="er-drift-secondary" style="margin: 0;">
|
|
746
|
-
then <em style="color: var(--er-red-pencil);">${topTwo[1].category}</em> · ${topTwo[1].count}
|
|
747
|
-
</p>`)
|
|
748
|
-
: ''}
|
|
749
|
-
<div style="margin-top: var(--er-space-2); font-family: var(--er-font-mono); font-size: 0.68rem; color: var(--er-faded);">
|
|
750
|
-
from ${data.report.all.approvedCount} approved · ${data.report.all.cancelledCount} cancelled<br />
|
|
751
|
-
<code style="margin-top: 0.25rem; display: inline-block;">/deskwork:review-report --site <site></code>
|
|
752
|
-
</div>`)
|
|
753
|
-
: unsafe(html `
|
|
754
|
-
<p style="font-family: var(--er-font-display); font-style: italic; color: var(--er-ink-soft); margin: 0;">
|
|
755
|
-
${totalTerminal === 0
|
|
756
|
-
? 'No proofs yet. The signal builds with use.'
|
|
757
|
-
: `Only ${totalTerminal} terminal ${totalTerminal === 1 ? 'proof' : 'proofs'} so far — need ${5 - totalTerminal} more.`}
|
|
758
|
-
</p>`);
|
|
759
|
-
return unsafe(html `
|
|
760
|
-
<aside>
|
|
761
|
-
<section class="er-drift">
|
|
762
|
-
<div class="er-drift-label">Voice-drift · signal</div>
|
|
763
|
-
${driftBody}
|
|
764
|
-
</section>
|
|
765
|
-
<section class="er-slip" style="margin-top: var(--er-space-4);">
|
|
766
|
-
<div class="er-slip-header">Short form</div>
|
|
767
|
-
<h3 class="er-slip-title">Social copy</h3>
|
|
768
|
-
<p style="font-size: 0.85rem; margin: 0 0 var(--er-space-1); color: var(--er-ink-soft);">
|
|
769
|
-
Click <em>start</em> in the coverage matrix above to begin a
|
|
770
|
-
shortform draft. Edit, iterate, and approve in the unified
|
|
771
|
-
review surface.
|
|
772
|
-
</p>
|
|
773
|
-
<p style="margin-top: var(--er-space-2);">
|
|
774
|
-
<a href="/dev/editorial-review-shortform">Go to the shortform desk →</a>
|
|
775
|
-
</p>
|
|
776
|
-
</section>
|
|
777
|
-
</aside>`);
|
|
778
|
-
}
|
|
779
|
-
// ---------------------------------------------------------------------------
|
|
780
|
-
// Entry point
|
|
781
|
-
// ---------------------------------------------------------------------------
|
|
782
|
-
export function renderDashboard(ctx, getIndex) {
|
|
783
|
-
const sites = Object.keys(ctx.config.sites);
|
|
784
|
-
const data = loadDashboardData(ctx, getIndex);
|
|
40
|
+
const data = await loadDashboardData(ctx.projectRoot);
|
|
785
41
|
const now = ctx.now ? ctx.now() : new Date();
|
|
786
|
-
const stageSections =
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
// and `the-outbound/characters/strivers`. This is purely a display
|
|
790
|
-
// ordering; the underlying calendar storage stays a flat table.
|
|
791
|
-
const stageEntries = data.calendarEntries
|
|
792
|
-
.filter((e) => e.entry.stage === stage)
|
|
793
|
-
.sort((a, b) => {
|
|
794
|
-
const siteCmp = a.site.localeCompare(b.site);
|
|
795
|
-
if (siteCmp !== 0)
|
|
796
|
-
return siteCmp;
|
|
797
|
-
return a.entry.slug.localeCompare(b.entry.slug);
|
|
798
|
-
});
|
|
799
|
-
return renderStageSection(ctx, data, stage, stageEntries, sites, getIndex).__raw;
|
|
42
|
+
const stageSections = DASHBOARD_STAGE_ORDER.map((stage) => {
|
|
43
|
+
const bucket = data.byStage.get(stage) ?? [];
|
|
44
|
+
return renderStageSection(stage, bucket).__raw;
|
|
800
45
|
}).join('\n');
|
|
801
46
|
const body = html `
|
|
802
47
|
${renderEditorialFolio('dashboard', 'press-check')}
|
|
803
|
-
${renderHeader(data, ctx, now)}
|
|
48
|
+
${renderHeader(data, ctx.projectRoot, now)}
|
|
804
49
|
<main class="er-container">
|
|
805
|
-
${renderFilterStrip(
|
|
50
|
+
${renderFilterStrip()}
|
|
806
51
|
<div class="er-layout">
|
|
807
52
|
<div>
|
|
808
53
|
${unsafe(stageSections)}
|
|
809
|
-
${
|
|
810
|
-
${renderApprovedSection(data, ctx)}
|
|
811
|
-
${renderTerminalSection(data, ctx, now)}
|
|
54
|
+
${renderDistributionPlaceholder()}
|
|
812
55
|
</div>
|
|
813
|
-
${renderSidebar(data)}
|
|
814
56
|
</div>
|
|
815
57
|
</main>
|
|
816
58
|
<div class="er-toast" data-toast hidden></div>
|
|
@@ -824,13 +66,6 @@ export function renderDashboard(ctx, getIndex) {
|
|
|
824
66
|
],
|
|
825
67
|
bodyAttrs: 'data-review-ui="studio"',
|
|
826
68
|
bodyHtml: body,
|
|
827
|
-
embeddedJson: [
|
|
828
|
-
{
|
|
829
|
-
id: '',
|
|
830
|
-
attr: 'data-rename-slugs',
|
|
831
|
-
data: data.slugsBySite,
|
|
832
|
-
},
|
|
833
|
-
],
|
|
834
69
|
scriptModules: ['/static/dist/editorial-studio-client.js'],
|
|
835
70
|
});
|
|
836
71
|
}
|