v1.13.1-data: links/redirects, captions, partner picks, Plausible reports, migration baseline #28

Merged
ngu-git-admin merged 16 commits from data into main 2026-10-06 10:10:57 +01:00
11 changed files with 146 additions and 23 deletions
Showing only changes of commit fd7e1b6fc1 - Show all commits

View file

@ -167,7 +167,7 @@ also in `server/src/admin-schema/` and a CHECK):
| Entity → field | Stored values | Labeled? | Also used on the public site by |
| --- | --- | --- | --- |
| Organizations → Kind (+ list filter) | national, region, group, partner, ministry | no, shows values | `ORG_BASE` in `src/lib/hrefs.ts` (the route each kind uses). A ministry has no page or list on the public site (the public routes, `pageMeta.js` and the sitemap leave it out, `ORG_KINDS` in `server/src/routes/content.js` doesn't take it); only its groups name it. `KINDS` in `src/components/admin/NewsletterRecipients.tsx` (the export's filter) lists every kind too. |
| Organizations → Kind (+ list filter) | national, region, group, partner, ministry | no, shows values | `ORG_BASE` in `src/lib/hrefs.ts` (the route each kind uses). A ministry has no page on the public site (the public routes, `pageMeta.js` and the sitemap leave it out); its groups name it, and an organization cards section lists it when asked to (below). `/organizations` returns ministries only when asked by kind or id. `KINDS` in `src/components/admin/NewsletterRecipients.tsx` (the export's filter) lists every kind too. |
| Organizations → Region → Scope | domestic, international, virtual | no | the Community page groups regions by it |
| Organizations → Region areas → Edge | top, bottom | no | the group map (`OrgList-Map.tsx`) |
| Events → Type (+ list filter) | retreat, class, workshop, meeting, other | no | `EVENT_TYPES` in `src/lib/eventTypes.ts` (public labels and plurals) |
@ -190,6 +190,7 @@ also in `server/src/admin-schema/` and a CHECK):
| Front page → Featured cards → Card type (Community → Community blog: pinned community posts offers link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` |
| Front page → Featured cards → Record type | event, organization, person, team, award | no | `FEATURED_REFS` in `server/src/shape.js` (what each fills the card with); the triggers in `030_featured_cards.sql` |
| Pages → Sections → Preset | community_blog, group_map, region_list, partner_list, events, timeline, people_directory | **yes**, `PRESETS` in `src/lib/adminSchema/sitePages.ts` (which pages offer which, the list passed to each `sitePage`) | `PRESETS` in `src/pages/SitePage.tsx`. A People directory shows its tag's first `DIRECTORY_PREVIEW` people (`src/pages/sections/PeopleDirectory.tsx`), linking to `/directory/<tag>`. |
| Pages → Sections → Cards: list (organization cards preset, 067) | partner, ministry, partner,ministry | **yes**, inline in `src/lib/adminSchema/sitePages.ts` | `partner_list` in `PRESETS` in `src/pages/SitePage.tsx` passes it as the kind to `OrgListCards`; a section's hand-picked Cards: organizations (`page_section_orgs`) replace it |
| Every list → Published / Listed / Featured filter | 1, 0 | **yes** | n/a |
"No, shows values" means the dropdown currently shows the raw value,

View file

@ -96,6 +96,9 @@ export const OPTION_QUERIES = {
"SELECT id, name AS label FROM organizations WHERE kind = 'region' ORDER BY name",
ministries:
"SELECT id, name AS label FROM organizations WHERE kind = 'ministry' ORDER BY name",
// What an organization cards section can hand-pick (067).
card_orgs:
"SELECT id, name || ' (' || kind || ')' AS label FROM organizations WHERE kind IN ('partner', 'ministry') ORDER BY kind, name",
event_scopes: "SELECT id, name AS label FROM event_scopes ORDER BY sort_order",
events: "SELECT id, title AS label FROM events ORDER BY starts_on DESC, title",
people: "SELECT id, display_name AS label FROM people ORDER BY sort_name, display_name",

View file

@ -36,8 +36,20 @@ const sectionsChild = {
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
enumeration("view", ["carousel", "grid", "map"]),
text("tag_id"),
// Organization cards (067): the kinds listed by themselves.
enumeration("org_kinds", ["partner", "ministry", "partner,ministry"]),
],
children: [
blocksChild("page_section"),
{
// Organization cards (067): a hand-picked list, shown instead.
key: "orgs",
table: "page_section_orgs",
owner: { column: "section_id" },
order: "sort_order",
columns: [text("org_id", { required: true })],
},
],
children: [blocksChild("page_section")],
};
const sitePage = (id, more = {}) => ({

View file

@ -0,0 +1,42 @@
-- ═══════════════════════════════════════════════════════════════
-- 067 ORGANIZATION CARDS: WHICH ORGANIZATIONS
--
-- The organization cards preset (page_sections.preset 'partner_list',
-- the Community page's Partners) can list ministries as well as
-- partners, chosen two ways:
--
-- page_sections.org_kinds which kinds it lists by itself, every
-- published, listed one by name:
-- 'partner', 'ministry' or both
-- ('partner,ministry'). Blank: partners
-- page_section_orgs a hand-picked list, in order; when a
-- section has any, it shows those instead
-- (published ones, listed or not). Only
-- partners and ministries (triggers below)
-- ═══════════════════════════════════════════════════════════════
ALTER TABLE page_sections ADD COLUMN org_kinds TEXT
CHECK (org_kinds IN ('partner', 'ministry', 'partner,ministry'));
CREATE TABLE page_section_orgs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
org_id TEXT NOT NULL REFERENCES organizations (id) ON DELETE CASCADE
) STRICT;
CREATE INDEX page_section_orgs_section_idx ON page_section_orgs (section_id, sort_order);
CREATE TRIGGER page_section_orgs_kind
BEFORE INSERT ON page_section_orgs
FOR EACH ROW WHEN (SELECT kind FROM organizations WHERE id = new.org_id) NOT IN ('partner', 'ministry')
BEGIN
SELECT RAISE(ABORT, 'Organization cards can list partners and ministries only.');
END;
CREATE TRIGGER page_section_orgs_kind_update
BEFORE UPDATE OF org_id ON page_section_orgs
FOR EACH ROW WHEN (SELECT kind FROM organizations WHERE id = new.org_id) NOT IN ('partner', 'ministry')
BEGIN
SELECT RAISE(ABORT, 'Organization cards can list partners and ministries only.');
END;

View file

@ -72,7 +72,7 @@ const content = new Hono();
// Kinds with a public page. A ministry (063_ministries.sql) has none:
// it's only named on its groups' pages, so no route here serves one.
const ORG_KINDS = ["national", "region", "group", "partner"];
const ORG_KINDS = ["national", "region", "group", "partner", "ministry"];
/* ── Loaders ───────────────────────────────────────────────── */
@ -597,6 +597,11 @@ content.get("/events/:id", (c) => {
GET /organizations every published, listed org
GET /organizations?kind=region one kind
GET /organizations?kind=region,group
GET /organizations?ids=a,b these, published, listed or
not (a hand-picked list, 067)
Ministries come only when asked for, by kind or id: they have no
page, so the plain list leaves them out.
Whatever the kind, the common card fields are in the same
places, so a list component reads `name`, `color`, `logo` and
@ -616,19 +621,21 @@ content.get("/organizations", (c) => {
return c.json({ error: `kind must be one of ${ORG_KINDS.join(", ")}` }, 400);
}
const filter = kinds.length > 0 ? `AND kind IN (${marks(kinds.length)})` : "";
const ids = (c.req.query("ids") ?? "").split(",").map((id) => id.trim()).filter(Boolean).slice(0, 100);
const [where, params] =
ids.length > 0
? [`id IN (${marks(ids.length)})`, ids]
: kinds.length > 0
? [`is_listed = 1 AND kind IN (${marks(kinds.length)})`, kinds]
: [`is_listed = 1 AND kind <> 'ministry'`, []];
const rows = db
.prepare(
`SELECT * FROM organizations
WHERE is_published = 1 AND is_listed = 1 AND kind <> 'ministry' ${filter}
ORDER BY kind, sort_order, name`,
)
.all(...kinds);
.prepare(`SELECT * FROM organizations WHERE is_published = 1 AND ${where} ORDER BY kind, sort_order, name`)
.all(...params);
const ids = rows.map((row) => row.id);
const links = loadLinks(db, "organization", ids);
const cards = loadBlocks(db, "organization", ids, "card");
const found = rows.map((row) => row.id);
const links = loadLinks(db, "organization", found);
const cards = loadBlocks(db, "organization", found, "card");
// No body blocks or leadership: they grow with every organization
// and only a group's own detail panel or page shows them, which

View file

@ -37,11 +37,21 @@ sitePages.get("/site-pages/:id", (c) => {
const rows = db
.prepare(
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id, org_kinds
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
)
.all(id);
const blocks = loadBlocks(db, "page_section", rows.map((row) => String(row.id)));
const picked = new Map();
for (const { section_id, org_id } of db
.prepare(
`SELECT o.section_id, o.org_id FROM page_section_orgs o
JOIN page_sections s ON s.id = o.section_id
WHERE s.page_id = ? ORDER BY o.section_id, o.sort_order, o.id`,
)
.all(id)) {
picked.set(section_id, [...(picked.get(section_id) ?? []), org_id]);
}
return json(c, {
page: {
@ -49,6 +59,7 @@ sitePages.get("/site-pages/:id", (c) => {
sections: rows.map(({ id: sectionId, ...section }) => ({
...section,
blocks: blocks.get(String(sectionId)) ?? [],
org_ids: picked.get(sectionId) ?? [],
})),
},
});

View file

@ -15,7 +15,7 @@ const PRESETS = {
community_blog: "Community blog (its settings are below)",
group_map: "Local groups map",
region_list: "Unity Regions list",
partner_list: "Partner organization cards",
partner_list: "Organization cards (partners, ministries)",
events: "Event carousel or grid",
timeline: "Timeline",
people_directory: "People directory (a tag's people)",
@ -37,6 +37,7 @@ const EVENT_TYPES = [
];
const EVENTS = { path: "preset", value: "events" };
const CARDS = { path: "preset", value: "partner_list" };
const sectionsChild = (presets: string[]) => ({
key: "sections",
@ -113,6 +114,23 @@ const sectionsChild = (presets: string[]) => ({
},
]
: []),
...(presets.includes("partner_list")
? [
{
path: "org_kinds",
label: "Cards: list",
widget: "select",
options: [
["partner", "Partners"],
["ministry", "Ministries"],
["partner,ministry", "Partners and ministries"],
],
blankLabel: "Default: Partners",
help: "Every published, listed one, by name. Organizations picked below replace this list.",
when: CARDS,
},
]
: []),
...(presets.includes("group_map")
? [
{
@ -127,6 +145,16 @@ const sectionsChild = (presets: string[]) => ({
: []),
],
children: [
{
key: "orgs",
label: "Cards: organizations",
note: "Picked here, these show instead of the list above, in this order: partners or ministries, published ones, listed or not.",
addLabel: "Add organization",
when: CARDS,
title: (row, options) => options?.card_orgs?.find((o) => o.id === row.org_id)?.label ?? "New organization",
blank: { org_id: "" },
fields: [{ path: "org_id", label: "Organization", widget: "select", optionsFrom: "card_orgs", required: true }],
},
{
...blocksChild,
label: "Blocks",

View file

@ -27,8 +27,11 @@ import { isBadId, orgHref } from "./hrefs.ts";
import { useResource } from "./useResource.ts";
export function useOrganizations(kind) {
const path = kind
/* `ids` (a hand-picked list) wins over `kind`. */
export function useOrganizations(kind, ids?: string[]) {
const path = ids?.length
? `/organizations?ids=${ids.map(encodeURIComponent).join(",")}`
: kind
? `/organizations?kind=${encodeURIComponent(kind)}`
: "/organizations";

View file

@ -17,6 +17,10 @@ export type SitePageSection = {
view?: string | null
/** A people_directory preset's tag (Data → People tags). */
tag_id?: string | null
/** Organization cards: the kinds listed ('partner', 'ministry' or both, comma separated). */
org_kinds?: string | null
/** Organization cards: a hand-picked list, in order, shown instead. */
org_ids: string[]
blocks: ContentBlock[]
}

View file

@ -66,10 +66,15 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
],
},
}),
partner_list: () => ({
partner_list: (section) => ({
Component: OrgListCards,
request: { type: 'partner', label: 'Request a partner listing' },
props: { kind: 'partner', pageLabel: 'Partner page', empty: '· Partner organizations coming soon ·' },
props: {
kind: section.org_kinds || 'partner',
ids: section.org_ids,
pageLabel: 'Partner page',
empty: '· Organizations coming soon ·',
},
}),
events: (section) => ({
Component: EventListCards,

View file

@ -18,6 +18,7 @@ import { useReadingMode } from '../../lib/readingMode.ts'
page manifest and gets no control in its heading.
<OrgListCards kind="partner" pageLabel="Partner page" />
<OrgListCards ids={["unity-worldwide", "unity-of-x"]} /> in that order
Where the vertical list expands in place, a card links out. The
card carries as much as fits at a glance and the organization's
@ -152,6 +153,7 @@ function Block({ title, orgs, accent, pageLabel, siteLabel }) {
export default function OrgListCards({
kind,
ids,
title,
groups,
groupBy,
@ -161,7 +163,7 @@ export default function OrgListCards({
sort = byName,
empty = "Nothing to show here yet.",
}) {
const { organizations, loading, error } = useOrganizations(kind);
const { organizations, loading, error } = useOrganizations(kind, ids);
const shell = children => (
<div className="mx-auto px-8 md:px-12" style={{ maxWidth: GRID_MAX }}>
@ -191,7 +193,12 @@ export default function OrgListCards({
);
}
const sorted = sort ? [...organizations].sort(sort) : organizations;
// A hand-picked list keeps its order; anything else is sorted.
const sorted = ids?.length
? ids.flatMap((id) => organizations.filter((org) => org.id === id))
: sort
? [...organizations].sort(sort)
: organizations;
// No groups given means one undivided grid.
if (!groups || !groupBy) {