reports: user articles that embed claims under a database seal and link each other

- /berichte lists published reports; /berichte/<slug> renders a report: Markdown subset built as React
  elements (no raw HTML), [[angabe:ID]] embeds the claim card under a seal (green 'Amtliche Daten' when a
  source is official), [text](angabe:ID|bericht:slug|person:slug|org:slug) links inline, [[bericht:slug]]
  embeds another report; a box says how many claims the text rests on; backlinks between reports.
- /berichte/verfassen (login at the proxy): own reports, editor with a picker that finds claims, reports and
  persons and inserts their codes; draft / published / withdrawn; every save kept in report_revision.
- Claim pages show the embed code, 'use in a new report' and the reports citing the claim.
- API: GET /api/v1/reports, /reports/{slug} (references resolved like permalinks, merged claims follow the
  survivor); POST/PUT for the web app with POLITRACK_AUTHOR_TOKEN on behalf of the proxy user. The web app
  trusts Remote-User only with X-Politrack-Proxy = POLITRACK_PROXY_SECRET.
- Migration 0011 (report, report_revision, report_reference, app_user.display_name); docs: data model,
  deployment (sign-in setup), design system, roadmap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-20 10:19:50 +01:00
1 parent f2d72fe464
commit 9f0e2fc115
32 files changed
+1974 -21

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
-- Reports: articles written by signed-in users that embed and link claims (and other reports) from the database.
-- The text is the author's; the embedded claims keep their own evidence, so readers can tell the two apart.
ALTER TABLE app_user ADD COLUMN display_name TEXT;
ALTER TABLE app_user ADD COLUMN last_seen_at TIMESTAMPTZ;
COMMENT ON COLUMN app_user.external_subject IS 'User name from the reverse-proxy login (Authelia Remote-User).';
COMMENT ON COLUMN app_user.display_name IS 'Name shown as the author of reports (Authelia Remote-Name), updated at every write.';
CREATE TABLE report (
id SERIAL PRIMARY KEY,
slug TEXT NOT NULL UNIQUE,
title TEXT NOT NULL,
lede TEXT,
body TEXT NOT NULL,
lang TEXT NOT NULL DEFAULT 'de' CHECK (lang IN ('de', 'en')),
status TEXT NOT NULL DEFAULT 'draft' CHECK (status IN ('draft', 'published', 'withdrawn')),
author_id INT NOT NULL REFERENCES app_user(id),
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
published_at TIMESTAMPTZ
);
COMMENT ON TABLE report IS 'User-written articles. body is Markdown with references: [[angabe:ID]] embeds a claim, [[bericht:slug]] another report; [text](angabe:ID|bericht:slug|person:slug|org:slug) link inline.';
COMMENT ON COLUMN report.slug IS 'Permanent URL key, fixed at creation so that links from other reports keep working.';
COMMENT ON COLUMN report.status IS 'draft: only the author sees it. published: listed. withdrawn: unlisted, the page stays and says so.';
COMMENT ON COLUMN report.published_at IS 'First publication; later edits only change updated_at (and add a revision).';
CREATE INDEX report_list_idx ON report (status, published_at DESC);
CREATE INDEX report_author_idx ON report (author_id, updated_at DESC);
CREATE TABLE report_revision (
id BIGSERIAL PRIMARY KEY,
report_id INT NOT NULL REFERENCES report(id) ON DELETE CASCADE,
title TEXT NOT NULL,
lede TEXT,
body TEXT NOT NULL,
status TEXT NOT NULL,
edited_by INT NOT NULL REFERENCES app_user(id),
edited_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
COMMENT ON TABLE report_revision IS 'Every saved version of a report (also the first), so that changes after publication stay traceable.';
CREATE INDEX report_revision_idx ON report_revision (report_id, edited_at DESC);
CREATE TABLE report_reference (
report_id INT NOT NULL REFERENCES report(id) ON DELETE CASCADE,
ref_type TEXT NOT NULL CHECK (ref_type IN ('claim', 'report', 'person', 'organization')),
ref_key TEXT NOT NULL,
embedded BOOLEAN NOT NULL DEFAULT FALSE,
PRIMARY KEY (report_id, ref_type, ref_key)
);
COMMENT ON TABLE report_reference IS 'References parsed from the current body at every save: drives "used in reports" on claim, person and report pages.';
COMMENT ON COLUMN report_reference.ref_key IS 'Claim id, report slug, person slug or organisation slug, as written in the body.';
COMMENT ON COLUMN report_reference.embedded IS 'TRUE for a block embed ([[...]]), FALSE for an inline link.';
CREATE INDEX report_reference_target_idx ON report_reference (ref_type, ref_key);