Feature updates v1.7.4: media, blog, featured content, editor nav, content blocks #11

Merged
ngu-git-admin merged 22 commits from feature/new-features into main 2026-09-27 23:37:03 +01:00
2 changed files with 17 additions and 5 deletions
Showing only changes of commit 9b6d9b9aff - Show all commits

View file

@ -22,7 +22,7 @@ Backend (`server/`, Node >= 22). The server reads `HOST` (default `127.0.0.1`),
- `DB_PATH=./dev.db pnpm dev`: run with `node --watch` - `DB_PATH=./dev.db pnpm dev`: run with `node --watch`
- `DB_PATH=./dev.db pnpm migrate`: apply migrations without starting the server - `DB_PATH=./dev.db pnpm migrate`: apply migrations without starting the server
- `DB_PATH=./dev.db node src/admin-cli.js add|list|passwd|role|disable|enable ...`: the only way accounts are created - `DB_PATH=./dev.db node src/admin-cli.js add|list|passwd|role|disable|enable ...`: the only way accounts are created
- `DB_PATH=./dev.db node src/seed-showcase.js [--listed]`: writes fully filled test records (a region, chapter, team, award, person, three events and a blog post with every content block type), ids starting `showcase-`, for checking pages. Unlisted unless `--listed`. Local only; refuses /var/lib/ngu. - `DB_PATH=./dev.db node src/seed-showcase.js [--listed]`: writes fully filled test records (a region, chapter, team, award, person, three events and a blog post with every content block type), ids starting `showcase-`, for checking pages. Unlisted unless `--listed`. Refuses a database under /var/lib/ngu unless `--production` is also given.
In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API must listen on that port. In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API must listen on that port.

View file

@ -1,8 +1,9 @@
/* ═══════════════════════════════════════════════════════════════ /* ═══════════════════════════════════════════════════════════════
SHOWCASE: local test records with every field filled in SHOWCASE: test records with every field filled in
DB_PATH=./dev.db node src/seed-showcase.js DB_PATH=./dev.db node src/seed-showcase.js
DB_PATH=./dev.db node src/seed-showcase.js --listed DB_PATH=./dev.db node src/seed-showcase.js --listed
DB_PATH=/var/lib/ngu/ngu.db node src/seed-showcase.js --production
Writes one of each record kind with every field and option used, Writes one of each record kind with every field and option used,
so a change to any page can be checked against a record that so a change to any page can be checked against a record that
@ -39,20 +40,31 @@
Admin → Media and copy it to that name in the uploads directory, Admin → Media and copy it to that name in the uploads directory,
or leave it missing to check how each page copes without one. or leave it missing to check how each page copes without one.
It refuses the production database (anything under /var/lib/ngu). A database under /var/lib/ngu (where the deployed service keeps
its data) is refused unless --production is given too. That's for
a server that exists to be tested; on the live site, back up the
database first and leave --listed off, so the showcase is only
reachable by its links.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { openDatabase, migrate, tx } from "./db.js"; import { openDatabase, migrate, tx } from "./db.js";
const DB_PATH = process.env.DB_PATH ?? "./ngu.db"; const DB_PATH = process.env.DB_PATH ?? "./ngu.db";
const LISTED = process.argv.includes("--listed") ? 1 : 0; const LISTED = process.argv.includes("--listed") ? 1 : 0;
const PRODUCTION = process.argv.includes("--production");
// Matched anywhere in the path, not only at its start, so a shell // Matched anywhere in the path, not only at its start, so a shell
// that rewrites /var/lib/... into its own form (Git Bash) is caught too. // that rewrites /var/lib/... into its own form (Git Bash) is caught too.
if (/(^|\/)var\/lib\/ngu(\/|$)/.test(DB_PATH.replace(/\\/g, "/"))) { const deployed = /(^|\/)var\/lib\/ngu(\/|$)/.test(DB_PATH.replace(/\\/g, "/"));
console.error("✗ This is test content. It won't write to the production database.");
if (deployed && !PRODUCTION) {
console.error(
`✗ ${DB_PATH} is a deployed database. This writes test content;\n` +
" add --production if that's what you mean.",
);
process.exit(1); process.exit(1);
} }
if (deployed) console.warn(`! Writing showcase records to the deployed database ${DB_PATH}.`);
const IMAGE = "/uploads/showcase.jpg"; const IMAGE = "/uploads/showcase.jpg";
const POST_ID = "content-block-showcase"; const POST_ID = "content-block-showcase";