Tidy the admin editor's text: previews, blank options, no em-dashes
Your wording pass on adminSchema.ts and fields.tsx: "Default: ..."
blank options, "eg." examples, "URL ID" for slugs, and relabelled
front page sections, stat sources and hero fields.
On top of it:
- Content block row titles end with an ellipsis when the paragraph
is cut. preview() in src/lib/text.ts does it for anything that
shortens text: it collapses whitespace, cuts on a word and adds
"..." only when it actually shortened.
- No em-dashes in the editor, front end or server: placeholders
("Internal note: ..."), the Organizations blurb, the URL ID help,
empty table cells (now "-"), the Award dropdown ("Torch Award
(NGU)" in OPTION_QUERIES), a boot error message, and every comment
in the admin files. Also cleared from the files added this branch
(QR page, directory route, embeds, hero, migration 024), and the
QR page's team labels read "Board (NGU)".
- A few comments where removing the dash had run two sentences
together get a comma, colon or parentheses back.
- docs/updating-data-in-code.md matches the new labels and gains a
"Writing text in the editor" section with these conventions;
CLAUDE.md lists them under Rules and gotchas.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e35d09b172
commit
54bf649b8d
31 changed files with 239 additions and 187 deletions
|
|
@ -10,7 +10,7 @@
|
|||
it wants to exist, the engine deletes and reinserts in array
|
||||
order, and sort_order becomes the index. That makes drag-to-
|
||||
reorder free and removes a whole class of "which row is this"
|
||||
bugs, at the cost of churning autoincrement ids — which is fine
|
||||
bugs, at the cost of churning autoincrement ids, which is fine
|
||||
precisely because nothing references them.
|
||||
|
||||
A column that isn't present in the payload at all is left out of
|
||||
|
|
@ -51,7 +51,7 @@ function coerceValue(column, raw, errors, prefix = "") {
|
|||
|
||||
// Absent from the payload. Fall back to the descriptor default
|
||||
// if it declares one, otherwise let the column's own DEFAULT do
|
||||
// the work — which needs the column omitted, not nulled.
|
||||
// the work, which needs the column omitted, not nulled.
|
||||
if (raw === undefined) {
|
||||
if (column.default !== undefined) return column.default;
|
||||
if (column.required) errors[key] = "Required.";
|
||||
|
|
@ -183,8 +183,8 @@ export function readRow(db, entity, rawId) {
|
|||
/* A 1:1 side table is found one of two ways. `idColumn` is the
|
||||
original: the side table's key IS the parent's id, which is how
|
||||
regions and person_private work. `owner` is the same block children
|
||||
already use — a foreign key column plus an optional kind discriminator
|
||||
— and it exists because a timeline entry is keyed by (ref_kind,
|
||||
already use (a foreign key column plus an optional kind discriminator),
|
||||
and it exists because a timeline entry is keyed by (ref_kind,
|
||||
ref_id) rather than by the event's own slug. Same upsert either way;
|
||||
only the WHERE differs. */
|
||||
function extensionWhere(ext, id) {
|
||||
|
|
@ -257,7 +257,7 @@ export function createRow(db, entity, payload) {
|
|||
|
||||
// idKind "auto": the table assigns the id, so there is nothing to
|
||||
// validate, nothing to check for collisions, and nothing for the
|
||||
// client to have sent. Timeline entries use this — they have no
|
||||
// client to have sent. Timeline entries use this: they have no
|
||||
// natural name to slug, and one gets created every time somebody
|
||||
// ticks a checkbox on an event.
|
||||
const auto = entity.idKind === "auto";
|
||||
|
|
@ -390,8 +390,8 @@ export function deleteRow(db, entity, rawId) {
|
|||
function writeExtensions(db, entity, id, payload, parentValues) {
|
||||
for (const ext of entity.extensions ?? []) {
|
||||
if (!applies(ext.when, parentValues)) {
|
||||
// The gate closed — the kind changed away from this side
|
||||
// table, or a checkbox was unticked — so its row (and anything
|
||||
// The gate closed (the kind changed away from this side
|
||||
// table, or a checkbox was unticked), so its row (and anything
|
||||
// cascading off it) goes.
|
||||
const gone = extensionWhere(ext, id);
|
||||
db.prepare(`DELETE FROM ${ext.table} WHERE ${gone.sql}`).run(...gone.params);
|
||||
|
|
@ -587,7 +587,7 @@ function deleteChildren(db, child, ownerId) {
|
|||
|
||||
/* SQLite's constraint messages are accurate and unreadable. Turn
|
||||
the ones that users actually cause into something actionable,
|
||||
and name the column wherever the message carries it — a missing
|
||||
and name the column wherever the message carries it: a missing
|
||||
field is the client's problem to fix, not a 500.
|
||||
|
||||
The descriptor and the schema agreeing (see admin-schema-sync.js)
|
||||
|
|
@ -635,7 +635,7 @@ function wrapDbErrors(fn) {
|
|||
|
||||
// The polymorphic tables stand in for a foreign key with a
|
||||
// BEFORE INSERT trigger, and a trigger's RAISE(ABORT) matches none
|
||||
// of the patterns above — so without this, pointing a content
|
||||
// of the patterns above, so without this, pointing a content
|
||||
// block, link or timeline entry at a row that isn't there is a 500
|
||||
// rather than something the form can show.
|
||||
const ghost = /^(\w+): no such (\w+)$/.exec(message);
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
field instead of SQLite catching it as a 500;
|
||||
- reports a descriptor column the table doesn't have;
|
||||
- reports a NOT NULL, no-DEFAULT column that no descriptor
|
||||
column and no engine-supplied column covers — nothing can
|
||||
column and no engine-supplied column covers: nothing can
|
||||
ever set it, so every insert through the admin will fail.
|
||||
|
||||
The first is a silent repair. The other two are deployment bugs,
|
||||
|
|
@ -122,7 +122,7 @@ export function syncDescriptorsWithSchema(db, entities, { strict = true } = {})
|
|||
if (group.engineSupplied.includes(columnName)) continue;
|
||||
problems.push(
|
||||
`${name}: ${group.table}.${columnName} is NOT NULL with no default, ` +
|
||||
`but no descriptor column covers it — every insert will fail.`,
|
||||
`but no descriptor column covers it, so every insert will fail.`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
ADMIN ENTITY DESCRIPTORS
|
||||
|
||||
One object per editable entity. Everything the CRUD handlers do
|
||||
— validation, SQL, nesting — is read from here, so adding a
|
||||
(validation, SQL, nesting) is read from here, so adding a
|
||||
table later is a descriptor rather than another set of
|
||||
hand-written statements to keep in step with the schema.
|
||||
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
owner by free-text owner_id, so renaming a slug in place would
|
||||
silently orphan every link and content block attached to it.
|
||||
|
||||
affiliations is edited from both ends — a person's roles, and a
|
||||
affiliations is edited from both ends: a person's roles, and a
|
||||
team's members. Each side deletes and reinserts only its own
|
||||
slice (WHERE person_id = ?, WHERE team_id = ?) and declares
|
||||
every column of the row, so a save from one side round-trips
|
||||
|
|
@ -81,7 +81,7 @@ const affiliationRole = [
|
|||
editor and by the in_timeline extension on events and organizations.
|
||||
|
||||
occurred_on is text, not date. "2012" and "2025-07" are legitimate
|
||||
values — a backfilled entry often knows the year and nothing more —
|
||||
values (a backfilled entry often knows the year and nothing more),
|
||||
and the date coercion would reject both. `precision` is what says how
|
||||
much of it to believe. */
|
||||
const timelineFields = [
|
||||
|
|
@ -180,7 +180,7 @@ const blocksChild = (ownerKind) => ({
|
|||
});
|
||||
|
||||
/* Hosts. One row is one host, ordered, each either an organization
|
||||
or a person — the CHECK on event_hosts rejects both and the blank
|
||||
or a person. The CHECK on event_hosts rejects both and the blank
|
||||
filter drops neither, so the only bad row that reaches SQLite is
|
||||
one with both selects filled, and that comes back keyed to the
|
||||
row like any other field error.
|
||||
|
|
@ -496,7 +496,7 @@ const people = {
|
|||
// · org_id cannot be changed once anyone is filed under the
|
||||
// team. The composite foreign key has no ON UPDATE CASCADE, so
|
||||
// SQLite aborts the UPDATE. That surfaces as a constraint
|
||||
// error, which is the correct answer — reassign the members
|
||||
// error, which is the correct answer: reassign the members
|
||||
// first.
|
||||
//
|
||||
// · deleting a team with members fails the same way, rather than
|
||||
|
|
@ -655,8 +655,8 @@ const timeline = {
|
|||
row impossible even without it.
|
||||
|
||||
Every collection here is owned by page_id and replaced wholesale.
|
||||
That is safe for the same reason it is for links and blocks —
|
||||
nothing has a foreign key into these tables — and paths carry
|
||||
That is safe for the same reason it is for links and blocks
|
||||
(nothing has a foreign key into these tables), and paths carry
|
||||
their actions as a nested collection, the shape content blocks
|
||||
and their items already use. */
|
||||
|
||||
|
|
@ -811,13 +811,13 @@ export const OPTION_QUERIES = {
|
|||
ORDER BY kind, label`,
|
||||
|
||||
// The awarding organization is folded into the label instead,
|
||||
// because a person can receive an award from any organization —
|
||||
// because a person can receive an award from any organization:
|
||||
// there is nothing to filter on, only something to disambiguate
|
||||
// when two orgs name an award the same thing.
|
||||
awards: `
|
||||
SELECT a.id,
|
||||
CASE WHEN o.name IS NULL THEN a.name
|
||||
ELSE a.name || ' — ' || o.name END AS label,
|
||||
ELSE a.name || ' (' || o.name || ')' END AS label,
|
||||
a.org_id
|
||||
FROM awards a
|
||||
LEFT JOIN organizations o ON o.id = a.org_id
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
Everything that decides who someone is. Routes decide what they
|
||||
may do.
|
||||
|
||||
Password storage is scrypt from node:crypto — no native module,
|
||||
Password storage is scrypt from node:crypto: no native module,
|
||||
nothing to compile, nothing for pnpm to get wrong. The stored
|
||||
string carries its own parameters, so raising the cost later
|
||||
doesn't invalidate existing hashes.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
--
|
||||
-- A fourth hero mode, 'video': a recorded video beside the words,
|
||||
-- the way 'livestream' puts a stream there, but without the LIVE
|
||||
-- badge and without autoplay — a visitor presses play.
|
||||
-- badge and without autoplay: a visitor presses play.
|
||||
--
|
||||
-- Its own two columns rather than reusing the livestream's, so a
|
||||
-- featured video and a stream can both be set up ahead of time and
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
feedback routes. Both sit under the same requireAuth.
|
||||
|
||||
:entity is matched against the descriptor map, never
|
||||
interpolated into SQL from the URL — an unknown name is a 404
|
||||
interpolated into SQL from the URL; an unknown name is a 404
|
||||
before anything touches the database.
|
||||
═══════════════════════════════════════════════════════════════ */
|
||||
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ admin.get("/feedback", (c) => {
|
|||
});
|
||||
|
||||
/* ── PATCH /api/admin/feedback/:id ───────────────────────────────
|
||||
{ status?, admin_note? } — either, both, partial.
|
||||
{ status?, admin_note? }: either, both, partial.
|
||||
───────────────────────────────────────────────────────────── */
|
||||
|
||||
admin.patch("/feedback/:id", requireRole("editor"), async (c) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
DIRECTORY ROUTE — read-only, mounted under /api
|
||||
DIRECTORY ROUTE: read-only, mounted under /api
|
||||
|
||||
GET /directory every public record that has a page
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
/* ═══════════════════════════════════════════════════════════════
|
||||
PANEL ROUTES — server/src/routes/panel.js
|
||||
PANEL ROUTES: server/src/routes/panel.js
|
||||
|
||||
GET /api/admin/panel/overview
|
||||
PATCH /api/admin/panel/users/:id role, is_active
|
||||
DELETE /api/admin/panel/users/:id/sessions sign out everywhere
|
||||
|
||||
Everything here is superadmin-only, enforced once at the top
|
||||
rather than per route — there's no read here that an ordinary
|
||||
rather than per route; there's no read here that an ordinary
|
||||
admin should have either. Account records and live session
|
||||
counts are a different class of thing from content.
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ panel.get("/overview", (c) => {
|
|||
});
|
||||
|
||||
/* A table that hasn't been created yet shouldn't take the whole
|
||||
page down — the panel is where you go when something is wrong. */
|
||||
page down: the panel is where you go when something is wrong. */
|
||||
function count(db, table, where) {
|
||||
try {
|
||||
const sql = `SELECT COUNT(*) AS n FROM ${table}${where ? ` WHERE ${where}` : ""}`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue