diff --git a/CLAUDE.md b/CLAUDE.md index fa0d046..eb258a1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -41,6 +41,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - Security headers: the API sends them (Hono `secureHeaders()`, plus a CSRF check on `/api` writes); nginx sends HSTS on everything and must pass `Host` and `X-Forwarded-For` to the API: `docs/security-headers.md`. - Request form (`/request`): files go to the "Requests" folder of a Google shared drive and new-request emails go out through Gmail, both via a service account (`server/src/googleService.js`). `driveUpload(folder, ...)` finds or makes the named folder in the shared drive, so other uses get their own folder. Tools → Media → Files uploads to "Media" and shares each file as anyone-with-the-link (`server/src/routes/files.js`, migration 048); link fields with `files: true` pick from it ("Choose a file"), and link cards take its first-page preview. Needs a `/api/admin/files` nginx block (51m). Off until `GOOGLE_SERVICE_ACCOUNT` plus `GOOGLE_SHARED_DRIVE` (the bare id, not a URL) / `GOOGLE_MAIL_FROM` are set. Needs its own nginx block. Setup: `docs/google-drive-and-mail.md`. - Profile accounts (migration 076): admins invite an email (Data → Profile accounts), the person sets a password from the link or signs in with any Google account under that email, claims their People record (an admin approves), then edits it and hides parts at `/account`. Public reads of people go through the `v_people_public` view, never `people`. Discord linking is off until `DISCORD_CLIENT_ID` and `DISCORD_CLIENT_SECRET` are set: `docs/profile-accounts.md`. +- Planning Center (migration 085): Data → Planning Center compares a Planning Center People list (Site settings → Planning Center) with the site's people and applies what an admin picks: link (`people.pco_id`), update the name and private email and phone, or add unpublished. Off until `PCO_APP_ID` and `PCO_SECRET` are set: `docs/planning-center.md`. - Google sign-in for @nextgenerationofunity.org admin accounts: on when `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` are set on the service. Accounts made by admin-cli get in; with access groups set (Site settings → Access, plus `GOOGLE_DIRECTORY_AS`), anyone in one gets a Google-only account whose role follows the group, rechecked at sign-in, hourly and by Panel → Re-sync now (`server/src/accessGroups.js`); superadmins and admin-cli accounts are never changed by groups. Passwords still work. Setup: `docs/google-sign-in.md`. ## Git workflow @@ -62,7 +63,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu - All pages use `PageShell.tsx` as the wrapper unless explicitly noted otherwise. - Pages live in `src/pages/`; section-level components go in `src/pages/sections/`. - `src/data/` holds only hardcoded data shared across multiple section files (e.g. `historyDecades.ts`, map grid). Everything else comes from SQLite, through hooks in `src/lib/`. -- Navigation (header and footer links, page titles and intros, hidden pages) is edited in Pages → Navigation (`site_nav*` tables, `server/src/siteNav.js`, read through `src/lib/useSiteNav.ts`). `navConfig.ts` only holds the defaults the app starts from before that loads. Routes are in `App.tsx`; a static page's default title and intro in `site.json`'s `pages`. A hidden page answers Not found below viewer (server and app both). +- Pages are rows of `site_pages` (migration 080), edited in Pages → Page management: address, title, intro, Hidden (Not found below viewer) and Disabled (out of the menus, sitemap and search). Every page is a page of sections, the front page included (its hero and bands are section types: `src/pages/sections/Bands.tsx`, their settings in `section_*` tables read by `server/src/sectionData.js`; forms and embeds are section types too, `src/pages/sections/FormSections.tsx`), and new ones are made there; `PageAtPath.tsx` (the `*` route) draws whatever page is at an address. The pages the code links to (`CORE_PAGES` in `server/src/admin-schema/sitePages.js`: /give, /feedback, /request, /qr, /privacy, /terms) keep their address and can't be deleted. Record routes (`/events/:id`...) stay in `App.tsx`, and their first path segments are reserved. Menu links are Pages → Navigation (`site_nav_links`, `server/src/siteNav.js`, read through `src/lib/useSiteNav.ts`); `navConfig.ts` only holds the defaults the app starts from before that loads. - `api.ts` is the shared caching client used by frontend data hooks. - `docs/updating-data-in-code.md`: where content that isn't in the database lives (admin dropdown labels, fixed value lists, nav, banner, decades, map grid) and how to change it. Keep it current when adding a dropdown or code-owned content. - Images: every record image (logos, photos, backgrounds, block images) is an upload, in a folder by use: `/uploads/logos/`, `/uploads/images/`, `/uploads/thumbnails/` (saved previews), `/uploads/captions/` (videos' .vtt files); a logo or icon image field sets `folder: "logos"` (`docs/media-uploads.md`, Folders). A bare filename resolves to `/uploads/` (`src/lib/media.ts`, and `server/src/pageMeta.js` for previews). Only the site's own chosen assets, the NGU logos in the nav, footer and admin, are bundled from `src/assets/logos/`. Logo images hide themselves on load error (`onError`). @@ -84,6 +85,7 @@ In dev, Vite proxies `/api` to the target set in `vite.config.ts`, so the API mu Descriptor-driven: `server/src/admin-crud.js` and `server/src/admin-schema/` (server, one file per entity, registered in `admin-schema.js`) and `src/lib/adminSchema/` (client, one file per entity, registered in `adminSchema.ts`) generate SQL and form fields from declarative entity configs. Adding an entity should mean adding a descriptor, not new CRUD code. - Child collections are deleted and reinserted wholesale. Unsafe for entities referenced by foreign keys elsewhere. - `reindex: false` prevents cross-entity sort order collisions. +- A child collection can have `extensions` of its own (1:1 side tables keyed by the child row's id, eg. a page section's `section_hero`), and both those and its nested collections take a `when` on the row's values (a section's preset). A `when` value can be a list. - `check: (db, id) => void` runs after a save has written everything, inside its transaction; throwing an `HttpError` refuses the save (Site settings uses it for the color contrast check, `server/src/theme.js`). - The `OMIT` sentinel distinguishes unsent fields from deliberate clears. - `admin-schema-sync.js` runs at boot and throws if descriptors don't match live `PRAGMA table_info`. If boot fails after a schema change, update the descriptor or migration so they agree. diff --git a/TODO.md b/TODO.md index 0381195..747cf1a 100644 --- a/TODO.md +++ b/TODO.md @@ -42,14 +42,6 @@ - [ ] Linked from the footer next to the version, or only in the blog? Answer: ## Sections -- [ ] **Hero text that flips**: the headline's word changes (Next, Now, and other words for our generation), or mirrors. - - [ ] Which words, and are they edited in Front page (a list) or fixed? Answer: - - [ ] What motion: a flip like a card, a fade, letters typing, a mirror? Answer: - - [ ] Respect reduced motion by showing one word (the first)? [ ] yes - - [ ] "Next generation of New Thought": is that the line it plays on, or a second line under the headline? Answer: -- [ ] **NGU and partners**: "How does this partner with An Awakened Path and antn" (from the notes; unclear). - - [ ] What is "antn" (an organization's name)? Answer: - - [ ] Is this a section to build (eg. on Organization or Partners), or a question to answer in a blog post? Answer: ## Page Features - [ ] **Full profiles**: people get full profile pages. Profile accounts, claiming and visibility are done (Part 2, Accounts); what's left is the page itself. @@ -78,17 +70,14 @@ ## Mobile ## Page Editing +- [ ] **Page management revamp**, in steps (answers from 2026-10-16: disabled means out of the menus, sitemap and search with the address still working; admins can make new pages; the front page, the Community blog's settings, the form and embed pages and Privacy/Terms all become pages of sections; section types like the hero, stats, featured cards, calendar and countdown can go on any page, each with its own content). + - [x] Step 1, the page registry (Done, below). + - [x] Step 2, the core pages as sections (Done, below). + - [x] Step 3, section types with their own settings and the front page as sections (Done, below). ## Admin ## Data -- [ ] **Planning Center sync to People**: Planning Center People into the site's people records. - - [ ] One way (Planning Center → site), or both? Answer: to site only - - [ ] Who gets synced: everyone, or a Planning Center list or tag (eg. "Website")? Most people in Planning Center shouldn't have a public page. Answer:a specific list - - [ ] Which fields: name, photo, email, phone, birthday? Which win when both sides differ? Answer: - - [ ] How often: a button in Data, hourly, nightly? Answer: manually only - - [ ] Is there a Planning Center API app (personal access token) we can use, and which account owns it? Answer: use the API - - Skipped on 2026-10-16 until the fields (and which side wins) are decided. - [ ] **New Thought young adult directory**: the tabs are built (Part 2, Page features). Content: make the People tags (eg. Authors, Creators), tag people, and set Community's Directories section to them. ## Navigation @@ -122,14 +111,28 @@ # Part 2: Done +## v1.14.0-profiles: page management (branch `page-management`, on top of `page-features`, no PR yet; migrations 080 to 085, back up the database before deploying) +- [x] **Planning Center sync** (Data, migration 085, `docs/planning-center.md`): Data → Planning Center (admins and up) fetches one Planning Center People list (Site settings → Planning Center) and compares each member with the site: linked, or suggested by the same email, else the same name, with the fields that would change (name, sort name, private email and phone) side by side. For each: link (and update; Planning Center wins), link to someone else, make a new unpublished person, or skip; Apply writes it all at once. One way, by hand. Off until `PCO_APP_ID` and `PCO_SECRET` are on the service. Tested against a stand-in for Planning Center's API only. + - [ ] Check with the real list: the token, a list number, a compare, an apply. +- [x] **Rotating words** (Sections, migration 084): text typed as `{Next|Now|Rising}` cycles through its choices, in the hero's headline, section titles (bands' too), headings, paragraphs, callouts and quotes, eg. `{Next|Now} Generation of {Unity|New Thought}`. Five motions (slide, flip like a card, fade, type letter by letter, mirror turning round), from the top or the bottom, a number of seconds per word: defaults in Site settings → Animated words, and a hero or a block can set its own. Each word's space is the longest's, so the line doesn't jump. Less motion (the system's setting, or reading mode) shows the first word, still, and screen readers always get the first; menus, tab titles, search descriptions and newsletters use the first word too (`src/components/RotatingWords.tsx`, `src/lib/words.ts`). + - [ ] Check in a browser: each motion and direction, a group in a section title and a paragraph, the space it keeps on a phone, reduced motion. +- [x] **Section types with their own settings, and the front page as sections** (migration 083): the front page is Home in Page management, a page of sections like the others: its hero first, then its bands in their old order (hidden ones stay hidden), each a section type that can go on any page with content of its own: Hero (words, buttons, photos, video, livestream or event), Event countdown, Event calendar, Numbers, Featured cards, Connect nav, and a Timeline shown as the rail of featured moments. The Community blog's slots, pinned posts and feeds moved into its section, so it can go on any page too. Any section can be Hidden. The Front page editor is gone (its fields are each section's), and so are its tables and the Community page's. On the front page the bands look as they did and any other section is a band in the same style; on other pages a band brings its own heading. The National Retreats band became an Events section with an All retreats button. The newsletter's "featured cards" come from the front page's featured card sections. Admin engine: a child collection can have its own side tables and gated nested collections. + - [ ] Check in a browser: the front page (every band, the countdown overlapping the hero, reading mode, the menu's Home dropdown), editing the hero and a band in Page management, a Hero and a Numbers section put on another page, hiding a section, the Community blog (pinned posts, feeds), a draft preview of the front page, the newsletter's featured cards. +- [x] **Core pages as sections** (migrations 081, 082): Feedback, Request, QR codes, Give, Privacy and Terms are pages of sections now, edited in Page management like any other. Their forms and embeds are section types any page can use (Website feedback form, Request form, Data request form, Giving button, QR code maker); Give's words, and all of Privacy and Terms, are blocks (headings, paragraphs, lists), with "Last updated" in the section's blurb. The privacy contact email was written into the policy's text and its Site settings field is gone. These pages keep their address (the site's code links to them) and can't be deleted. The privacy notice's link now goes to #cookies-and-browser-storage. + - [ ] Check in a browser: each of the six pages (reading width of Privacy and Terms, the giving modal opening), editing a Privacy paragraph, a Request form section put on another page. +- [x] **Page registry** (migration 080): every page of the site is a row in Pages → Page management (admins and up): its address, title, intro, Hidden (Not found below viewer) and Disabled (out of the menus, the sitemap and search; the address still works), and the order of its admin card. New pages are made there, as pages of sections at the address given (any address but the admin's, the API's, the records' and the account pages'). The admin home's Pages group opens with a Page management banner (New page, Menus), then a card per page. The six page editors (Retreats, Community...) are one editor now; site.json's `pages` and Navigation's page list moved into the registry and are gone. The fixed pages (Feedback, Request, Give, QR codes, Privacy, Terms, the front page) take their words from it too and can't be deleted. + - [ ] Check in a browser: the admin home's banner and page cards, making a page (address, sections) and opening it, hiding and disabling one (menus, the page signed out), renaming Feedback, the Under page select in Navigation. + ## v1.14.0-profiles: page features (branch `page-features`, with `nav-access` under it, no PR yet; migrations 078 and 079, back up the database before deploying) - [x] **Featured event label** (Mobile): the "Featured event" badge left the headline; from lg up it sits above the event's card it names, and on a phone (the card under the words) it's left out. - [x] **Site version names**: the tag's words after the number are the version's name, `v1.13.2-region-cards` → "The Region Cards Update" (`src/lib/version.ts`), shown with the number in the site's footer and beside the version in the admin's footer and home. - [x] **Image converter** (Tools → Image converter): pictures to JPG, PNG or WebP in the browser (nothing uploaded): pick or drop several, a quality slider for JPG and WebP, download each or all. JPG fills transparency white. Media's images each have a Download as… (JPG, PNG, WebP) doing the same (`src/lib/convertImage.ts`). - [x] **Directory tabs** (migration 078): the People directory preset takes several People tags, a tab each in the order picked (Directory: tags under the section); one tag shows without tabs, reading mode lists every tag. Each section's old single tag became its first. - [x] **Blog post tabs** (migration 079): a Tab block in a post (its text the tab's title) starts a tab holding the blocks after it; blocks before the first Tab are the intro above the tabs. The contents list follows the open tab, a link to a heading in another tab opens it, and Download PDF and reading mode show every tab under its title. Outside a post a Tab block reads as a heading. +- [x] **Featured event card height** (Sections): from lg up the event's photo sits beside its words instead of above them, with tighter type and buttons, so the card is about as tall as the hero's text beside it; stacked as before on a phone. The photo stays whole (16:9). +- [x] **Word import, more of it** (Page Features): a line starting `Tab:` (any style) starts a tab; the Quote style becomes a Quote (a dash and a name at the end is who said it), Intense Quote a Callout, a line of `---` a Divider, a YouTube, Vimeo or Facebook link alone on its line a Video, and `Button: Register` with Register linked a Button. Blog posts → What becomes what (beside Import from Word) shows the whole mapping; `docs/importing.md` too. The note after an import counts tabs and the rest. - [x] **Side nav sun into the footer** (Navigation): the sun is far bigger than the sticky layer that carries it, so once the last section went up past the list it hung over the footer. It now fades out as the list leaves with the last section, and back in on the way up. - - [ ] Check in a browser: the side nav sun fading at the end of a long page (2xl screen) and with a tall footer; the featured event hero at phone and desktop width, the footers' version line, converting a PNG with transparency to JPG and a JPG to WebP (and Download as in Media), a Directories section with two tags and with one, a post with an intro and three tabs (contents, keyboard arrows, PDF, reading mode). + - [ ] Check in a browser: the featured event card beside a two-line headline at 1024, 1280 and 1536px; What becomes what and a real Word document with Tab: lines, a quote and a video link; the side nav sun fading at the end of a long page (2xl screen) and with a tall footer; the featured event hero at phone and desktop width, the footers' version line, converting a PNG with transparency to JPG and a JPG to WebP (and Download as in Media), a Directories section with two tags and with one, a post with an intro and three tabs (contents, keyboard arrows, PDF, reading mode). ## Page Editing (branch `nav-access`, no PR yet; migration 077) - [x] **Drafts of every record** (migration 077, `docs/drafts.md`): an existing record of any kind (events, people, organizations, blog posts, the front page, the site pages, Navigation, Site settings...) can be saved as a draft instead of going live. One draft per record; anyone who can edit it can save, preview, publish or discard it. Opening a record with a draft opens the draft, saying who saved it and when, and warning when the live record was saved since. Lists mark records with a draft. diff --git a/docs/importing.md b/docs/importing.md index 3d770f2..1c77c96 100644 --- a/docs/importing.md +++ b/docs/importing.md @@ -18,6 +18,19 @@ authors and a cover, then tick Published. | Tables | Table blocks: a row per line, cells split by `\|`, the first row the header | | Bold, italic, links (http, https, mailto) | `**bold**`, `*italic*`, `[text](url)`, in paragraphs, list items and table cells | +And lines written a certain way, in any style: + +| In the document | In the post | +| --- | --- | +| A line starting `Tab:`, eg. `Tab: Overview` | A Tab block: the post is split into tabs from there (the blocks before the first are the intro above the tabs) | +| The Quote style | A Quote block; a dash and a name at the end (`... - Jane Doe`) is who said it | +| The Intense Quote style | A Callout block | +| A line of `---` alone | A Divider | +| A YouTube, Vimeo or Facebook link alone on its line (the link text can be anything) | A Video block | +| `Button: Register`, with "Register" linked | A Button block, its label and link | + +The same table is on Blog posts, beside Import from Word (What becomes what). + A post with three headings or more gets **Show contents** turned on. The URL ID is the title as a slug, with `-2`, `-3` when it's taken. diff --git a/docs/performance.md b/docs/performance.md index 5744786..e0822bc 100644 --- a/docs/performance.md +++ b/docs/performance.md @@ -41,15 +41,14 @@ also take a separate `http2 on;`. ## The bundle -Only the home page is in the main bundle. Every other page, and the -whole admin, loads when first visited (`src/App.tsx`). A tab still -running an old build that asks for a page removed by a deploy reloads -once to pick up the new one. +Every page, the front page included, and the whole admin, loads when +first visited (`src/App.tsx`). A tab still running an old build that +asks for a page removed by a deploy reloads once to pick up the new +one. -The home page asks for events and the timeline alongside its own data -(`src/pages/Home.tsx`), and the server tells the browser to fetch -`/api/front-page` and the first hero photo while the JS downloads -(`preload` in `server/src/pageMeta.js`). +The server tells the browser to fetch the front page's data +(`/api/site-pages/home`) and its hero's first photo while the JS +downloads (`preload` in `server/src/pageMeta.js`). ## Images diff --git a/docs/planning-center.md b/docs/planning-center.md new file mode 100644 index 0000000..3627500 --- /dev/null +++ b/docs/planning-center.md @@ -0,0 +1,46 @@ +# Planning Center + +Admin → Data → Planning Center (admins and up) brings one Planning +Center People list into the site's people, by hand (migration 085). +One way: nothing is sent to Planning Center. + +## Setup + +1. In Planning Center, make (or pick) a People **list** of the people who + should be on the site, eg. "Website". Its number is in its address: + `people.planningcenteronline.com/lists/1234567`. +2. Admin → Panel → Site settings → **Planning Center → People list**: that + number. +3. A personal access token: https://api.planningcenteronline.com/oauth/applications + → Personal Access Tokens → New, as an account that can see that list. + Put its two halves on the service (`systemctl edit ngu-api`): + + ``` + [Service] + Environment=PCO_APP_ID=... + Environment=PCO_SECRET=... + ``` + + then `systemctl restart ngu-api`. (`PCO_BASE` overrides the API's + address, for testing.) + +## Using it + +**Compare with Planning Center** fetches the list. Each member shows: + +- the site person they're **linked** to, or one **suggested** by the + same email (private or public), else the same name; +- for that person, each field that would change: name, sort name + ("Last, First"), private email and private phone, the site's value + beside Planning Center's. + +For each, choose **Link to** the suggestion (and whether to update it +from Planning Center), link to **someone else**, **make a new person** +(unpublished, to fill in and publish later), or **Skip**. **Apply** +writes what you chose, all at once; nothing changes before. Planning +Center wins where both have a value; a blank in Planning Center leaves +the site's. Once linked, a person is matched by Planning Center's id +from then on, whatever their name or email becomes. + +Code: `server/src/planningCenter.js` (the API, the comparison, the +writes), `server/src/routes/pco.js`, `src/pages/admin/AdminPco.tsx`. diff --git a/docs/seo.md b/docs/seo.md index cb2652f..9b9cf26 100644 --- a/docs/seo.md +++ b/docs/seo.md @@ -23,7 +23,7 @@ same build. | --- | --- | | Site name, address, default description | `site.json`: `title`, `url`, `description` (blank uses the front page's subhead) | | Default preview image | `site.json`: `openGraph.image`, eg. `/uploads/` from Admin → Tools → Media. Blank means pages without their own image have none. | -| Static pages (Retreats, Community, History…) | `site.json`: `pages`. The page's heading and intro read the same entry, so they can't drift. A new static page needs an entry. | +| The site's pages (Retreats, Community, History…) | Admin → Pages → Page management (`site_pages`). The page's heading and intro read the same row, so they can't drift. Disabled pages are `noindex` and out of the sitemap; hidden ones are a 404 to search engines. | | Records (events, organizations, teams, awards, people, posts) | The database: the record's name, then its tagline or first paragraph; its own image (an event's card background, else its logo; a post's cover; a person's photo; an organization's logo). SVGs aren't used as previews. | | Whether search may list it | `site.json` `robots.index` for the whole site; per record, published and listed is indexed, published but unlisted is `noindex`, anything else is a 404. `/admin` is always `noindex`. | diff --git a/docs/updating-data-in-code.md b/docs/updating-data-in-code.md index 23a1d96..0a26bc9 100644 --- a/docs/updating-data-in-code.md +++ b/docs/updating-data-in-code.md @@ -15,8 +15,8 @@ what a dropdown in the admin editor says. - [Renaming what a dropdown shows](#renaming-what-a-dropdown-shows) - [Adding, removing or renaming a stored value](#adding-removing-or-renaming-a-stored-value) - [Every dropdown in the editor](#every-dropdown-in-the-editor) -- [Front page section names](#front-page-section-names) -- [Front page stat sources](#front-page-stat-sources) +- [Front page sections](#front-page-sections) +- [Stat sources](#stat-sources) - [Other content that lives in code](#other-content-that-lives-in-code) - [Writing text in the editor](#writing-text-in-the-editor) - [Making the change](#making-the-change) @@ -36,7 +36,8 @@ what a dropdown in the admin editor says. | The **label** a dropdown shows in the admin | code | [one file](#renaming-what-a-dropdown-shows) | | The **list of allowed values** behind a fixed dropdown | database CHECK + code | [a migration and three files](#adding-removing-or-renaming-a-stored-value) | | Navigation, colors, the site banner, history decades, the map grid | code | [the file named below](#other-content-that-lives-in-code) | -| A static page's title and intro (also its search title and description), the site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address and the pages' defaults. See `docs/seo.md` | +| A page's title and intro (also its search title and description), its address, Hidden and Disabled | the database (`site_pages`, 080) | Admin → Pages → Page management (admins and up), where new pages are made too | +| The site's name, description, preview image, icons, search indexing, privacy contact email | the database, over `site.json` | Admin → Panel → Site settings (superadmins). Blank uses `site.json`, which also holds the site's address. See `docs/seo.md` | | Uploaded images | disk + the `media` table | Admin → Tools → Media, or any image field. See `docs/media-uploads.md` | The rule of thumb from `CLAUDE.md`: data belongs in the database, @@ -153,8 +154,9 @@ together, in one branch: 3. **`src/lib/adminSchema/.ts`**: the `options` on the form field, and on the list filter if there is one. 4. **Anywhere the public site renders or relies on the value**, listed in - the table below (for example `EVENT_TYPES` for event types, or the - `SECTIONS` map in `Home.tsx` for front page sections). + the table below (for example `EVENT_TYPES` for event types, or + `PRESETS` in `SitePage.tsx` and `BANDS` in `sections/Bands.tsx` for + section types). If the server descriptor and the database disagree, the API refuses to start: `admin-schema-sync.js` compares them at boot and throws with a @@ -183,16 +185,15 @@ also in `server/src/admin-schema/` and a CHECK): | Timeline → Kind (+ list filter) | milestone, event, organization, award, people | no | `KIND_NAMES` in `src/pages/sections/history/TimelineEntry.tsx` | | Timeline → Points at (+ list filter) | event, organization, award, person, team | no | `refHref` in `src/lib/hrefs.ts` | | Timeline → Precision (and on events/orgs) | year, month, day | no | the history page's grouping | -| Front page → Countdown → Only this type | retreat, class, workshop, meeting, other | **yes** | `server/src/routes/home.js` (picks the countdown event). The same values as Events → Type, so adding a type widens both CHECKs. | -| Front page → Background | brand, photos | **yes** | `HeroStage.tsx` | -| Front page → Feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/routes/home.js` | -| Front page → Sections → Section | countdown, retreats, calendar, stats, timeline, connect, featured | **yes**, `FRONT_PAGE_SECTIONS` | `SECTIONS` in `src/pages/Home.tsx`; see [below](#front-page-section-names) | -| Front page → Stats → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` | `STAT_QUERIES` in `server/src/routes/home.js`; see [below](#front-page-stat-sources) | -| 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 Content → Columns (073) | 2, 3, 4 | **yes**, inline in `src/lib/adminSchema/frontPage.ts` | `GRID_COLUMNS` in `FeaturedCards.tsx`; the CHECK on `front_page.featured_columns` | -| Front page → Featured cards → Size (073; front page only, regions and the Community blog stay automatic) | normal, wide, tall, large | **yes**, inline in `src/lib/adminSchema/frontPage.ts` | `SPANS` and `sizeOf` in `FeaturedCards.tsx`; the CHECK on `featured_cards.size` | -| 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/`. | +| Pages → Sections → Countdown: only this type | retreat, class, workshop, meeting, other | **yes** | `server/src/sectionData.js` (picks the countdown event). The same values as Events → Type, so adding a type widens both CHECKs. | +| Pages → Sections → Hero: background | brand, photos | **yes** | `HeroStage.tsx` | +| Pages → Sections → Hero: feature | none, livestream, video, event | **yes** | `HeroStage.tsx`; the event is picked in `server/src/sectionData.js` | +| Pages → Sections → Numbers → Number Source | manual, years_since, regions, … | **yes**, `STAT_SOURCES` in `src/lib/adminSchema/sitePages.ts` | `STAT_QUERIES` in `server/src/sectionData.js`; see [below](#stat-sources) | +| Featured cards → Card type (a Community blog's pinned community posts offer link and video only) | record, link, video | **yes**, `FEATURED_KINDS` | `FeaturedCards.tsx` (how each kind draws), `loadFeaturedCards` in `server/src/shape.js` | +| Pages → Sections → Featured cards: columns (073) | 2, 3, 4 | **yes**, inline in `src/lib/adminSchema/sitePages.ts` | `GRID_COLUMNS` in `FeaturedCards.tsx`; the CHECK on `section_featured.columns` | +| Featured cards → Size (073; featured card sections only, regions and the Community blog stay automatic) | normal, wide, tall, large | **yes**, inline in `src/lib/adminSchema/sitePages.ts` | `SPANS` and `sizeOf` in `FeaturedCards.tsx`; the CHECK on `featured_cards.size` | +| 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 (section type) | community_blog, group_map, region_list, partner_list, events, timeline, people_directory, feedback_form, request_form, data_request_form, giving, qr_maker, hero, countdown, calendar, stats, featured_cards, connect | **yes**, `PRESETS` in `src/lib/adminSchema/sitePages.ts`, every page offers them all | `PRESETS` in `src/pages/SitePage.tsx`; the bands (hero, countdown, calendar, numbers, featured cards, connect, and a timeline shown as a rail) in `src/pages/sections/Bands.tsx`, their data from `server/src/sectionData.js`; forms and embeds in `src/pages/sections/FormSections.tsx`. A People directory shows each tag's first `DIRECTORY_PREVIEW` people (`src/pages/sections/PeopleDirectory.tsx`), linking to `/directory/`. | | 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 | @@ -209,67 +210,49 @@ code): | People → Directories → Tag; Pages → Sections → Directory: tag | `person_tag_types` | Data → People tags | | Organizations and Events → Tags → Tag | `tags` | Data → Tags | | Organizations → Contacts → Type | `contact_types` | Data → Contact types | -| Event → Scope (+ list filter); Front page → Countdown → Only this scope | `event_scopes` | the `event_scopes` table (migration only) | +| Event → Scope (+ list filter); Pages → Sections → Countdown: only this scope | `event_scopes` | the `event_scopes` table (migration only) | | Event hosts → Organization; affiliations; team and award "Organization" / "Awarded by"; person → Home organization | `organizations` | organizations, labeled by name, except ministries (they have no page to link to) | | Event hosts / event people / team members / timeline people → Person | `people` | people | -| Community → Community blog: pinned posts (ours) → Post | `blog_posts` | blog posts, newest first | +| Pages → Sections → Blog: pinned posts (ours) → Post | `blog_posts` | blog posts, newest first | | Timeline → Record; Featured cards → Record | `record_refs` | every event, organization (but ministries), award, person and team, narrowed by the type picked beside it | | Affiliations → Team | `teams` | teams, filtered to the chosen organization | | Person awards → Award | `awards` | awards, labeled "Award (Organization)" | -| Person awards → Presented at; Front page → Count down to; Front page → Featured event | `events` | events | +| Person awards → Presented at; Pages → Sections → Count down to, Hero: featured event | `events` | events | --- -## Front page section names +## Front page sections -"Section name" means three different things on the front page, and -each is changed in a different place: +The front page is a page of sections like the others (Admin → Pages → +Page management → Home, migration 083): the hero first, then its +bands, each a section with a type. Its heading is the section's title +(up to 60 characters on the front page), its anchor the section's URL +ID (`#retreats`, `#calendar`, `#numbers`, `#connect`), which the +header's Home dropdown lists (not the hero or the countdown). Rename +a heading freely; change a URL ID only if you mean to break links to +it. The names in the section type dropdown are `PRESETS` in +`src/lib/adminSchema/sitePages.ts`. -| What you see | Where it's set | -| --- | --- | -| **The heading on the page** ("National Retreats", "What's on") | **Admin → Pages → Front page → Page sections → Heading.** Blank uses the default below. | -| The default heading when that field is blank | `SECTIONS` in `src/pages/Home.tsx`, the `title` of each entry | -| **The name in the admin's Section dropdown** ("Events Carousel (National Retreats)") | `FRONT_PAGE_SECTIONS` in `src/lib/adminSchema/frontPage.ts` | -| The links in the header's Home dropdown | the bands shown, under their headings (`src/lib/navSections.ts`) | - -To rename a band **for visitors**, use the admin. To rename how it -reads **in the editor's dropdown**, edit `FRONT_PAGE_SECTIONS`: - -```ts -const FRONT_PAGE_SECTIONS = [ - ["countdown", "Event Countdown"], - ["retreats", "Events Carousel (National Retreats)"], // ← the right-hand side is the label - ["calendar", "Event Calendar"], - ... -]; -``` - -The subnav links jump to each band by its anchor: the `id` passed in -each band's `render` in `Home.tsx` (`#retreats`, `#calendar`, -`#numbers`, `#connect`, and `#hero` for the hero). If you rename a -heading in Front page → Sections, its anchor stays: leave the band's -`id` alone unless you mean to break links to it. - -**Adding a new kind of band** (not just renaming one) is a feature, -not a relabel: it needs a component, an entry in `SECTIONS` in -`Home.tsx`, the key added to `FRONT_PAGE_SECTIONS`, to the -`enumeration("section", …)` in `server/src/admin-schema/frontPage.js`, to the -`FrontPageSectionKey` type in `src/lib/useFrontPage.ts`, and to the -CHECK on `front_page_sections.section` via a migration. +**Adding a new kind of band** is a feature, not a relabel: its +component and an entry in `BANDS` (`src/pages/sections/Bands.tsx`), +its settings table (a migration) and extension or collection in +`sectionsChild` (`server/src/admin-schema/sitePages.js`), its data in +`server/src/sectionData.js`, its fields in `src/lib/adminSchema/sitePages.ts`, +and its value added to the CHECK on `page_sections.preset`. --- -## Front page stat sources +## Stat sources -The numbers band's "Number Source" dropdown works the same way: +A Numbers section's "Number Source" dropdown works the same way: -- **Relabel a source:** `STAT_SOURCES` in `src/lib/adminSchema/frontPage.ts`. +- **Relabel a source:** `STAT_SOURCES` in `src/lib/adminSchema/sitePages.ts`. - **Change what a count counts:** its query in `STAT_QUERIES` in - `server/src/routes/home.js`. Keep it counting exactly what the + `server/src/sectionData.js`. Keep it counting exactly what the matching public page shows (published rows), or the number and the page will disagree. -- **Add a source:** the CHECK on `front_page_stats.source` (migration), - the `enumeration("source", …)` in `server/src/admin-schema/frontPage.js`, +- **Add a source:** the CHECK on `section_stats.source` (migration), + the `enumeration("source", …)` in `server/src/admin-schema/sitePages.js`, `STAT_SOURCES`, and a query in `STAT_QUERIES`. --- @@ -278,19 +261,18 @@ The numbers band's "Number Source" dropdown works the same way: | What | File | Notes | | --- | --- | --- | -| Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | Admin → Pages → Navigation (the database, `075_site_nav.sql`); `src/navConfig.ts` is only the defaults the app starts from before it loads | Links: where each shows (header pages, header buttons, footer Get in Touch, footer bottom row), order, label, a header page set under another's menu, a filled button, new tab. Pages: title, intro and Hidden (Not found below viewer, out of the menus and the sitemap; `server/src/siteNav.js`). Each page's sections aren't listed there: they follow the page itself, through `src/lib/navSections.ts` (the site pages' sections from Admin → Pages; the front page's bands it shows, with `src/lib/frontPageBands.ts` giving each band's anchor and default heading). A new static page needs a route in `src/App.tsx` and an entry in `site.json`'s `pages` (its default title and intro, and what Navigation's Page select offers); a new page of sections also needs its id in `site_pages`' CHECK and a descriptor in both admin schemas, like Shop (075). | -| Section titles, blurbs and colors on Feedback, Privacy, Terms | the page file in `src/pages/` | the `SECTIONS` array at the top. | +| Header and footer navigation, each page's sections (the header dropdowns, mobile menu and footer site map) | Admin → Pages → Navigation (the database, `075_site_nav.sql`); `src/navConfig.ts` is only the defaults the app starts from before it loads | Links: where each shows (header pages, header buttons, footer Get in Touch, footer bottom row), order, label, a header page set under another's menu, a filled button, new tab. Each page's sections aren't listed there: they follow the page itself, through `src/lib/navSections.ts` (every page's sections from Admin → Pages → Page management, the front page's included, but its hero and countdown). A new page is made in Page management, no code: it's a page of sections at the address given. | | Site-wide announcement banner | `src/data/bannerConfig.ts` | `enabled: false` hides it. Bump `id` when the message changes, so people who dismissed the old one see the new one. | | History page decade headers | `src/data/historyDecades.ts` | Title, tagline and blurb per decade. | | Group map tiles and area names | `src/data/mapGrid.ts` | `AREAS` (tile positions) and `AREA_NAMES`. Which region paints which tile is in the database (Admin → Data → Organizations → a region → Map areas). | | Feedback form types | `src/data/feedbackTypes.ts` **and** `TYPES` in `server/src/routes/feedback.js` | Keep the ids identical in both; the server stores unknown ids as `general`. Labels and hints are client-only. `DATA_REQUEST` ('privacy') isn't a tile: the Privacy page's form sends it, and the server requires an email for it. | | Request form types (what `/request` can ask for) | `src/data/requestTypes.ts` **and** `CATEGORIES` in `server/src/routes/requests.js` **and** the CHECK on `feedback.category` (`046_content_requests.sql`) | Ids and allowed actions (new, update) identical in all three; a new id needs a migration. Labels, hints, the name field's question and each type's `fields` (the details it asks for, and where each lands in the admin editor: a field path, a link row or a description paragraph) are client-only: the server stores whatever detail keys come as JSON (`feedback.details`, 049), so adding a field needs no migration. A button to the form opened on one type: `request: { type, label }` on a section manifest entry, or `` (`src/components/RequestLink.tsx`). | | The site's colors, light and dark | the database over `src/index.css` | Admin → Panel → Site settings → Colors (superadmins): pick a color, set its light and/or dark value; saving refuses anything that makes text hard to read. The defaults are `THEME_DEFAULTS` in `server/src/themeDefaults.js` (the admin and the contrast check read it) and the same values as CSS in `src/index.css`; the build stops if the two differ. The admin's labels for them are `THEME_LABELS` in `src/lib/adminSchema/siteSettings.ts`. Change a token's value in both modes and every use follows. Use the token utilities (`text-muted`, `bg-surface`, `border-brand/20`) or `var(--color-…)`, not hex. A color that arrives as data (a page accent, an event's or region's color) goes through `src/lib/color.ts`: `withAlpha` for tints, `accentText` for text in it, `readableOn` for text on it. | -| The icons a Front page "Find your way in" path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. | +| The icons a Connect nav section's path can pick | `src/data/pathIcons.ts` (keys and labels) **and** `ICONS` in `src/pages/sections/home/Pathfinder.tsx` (the Phosphor icon for each key) | Add a line to both. A path saved with an emoji from before the list shows it as it is. | | A page section's accent color | `BRAND` and `ACCENTS` in `src/lib/color.ts` | Pages pick from these (`accent: ACCENTS.green`); add a color there, not a hex in a page. Each is readable as text on white and the tints. | | The palette (the 16-color grid the theme is drawn from) | `PALETTE` in `src/lib/color.ts` | Four families, a column each. `PALETTE_LIGHT` / `PALETTE_DARK` are the fills things colored by data use (a person's initials tile, `paletteFill`); the page background's layers (how many circles, their sizes and parallax speeds) are `LAYERS` in `src/components/PageBackdrop.tsx` and its shades are in `PageBackdrop.css`; the admin home's two alternating group colors are `BLOCK_COLORS` in `src/pages/admin/AdminHome.tsx`. | | The accessibility panel's choices (bottom right of every public page) | `SETTINGS` in `src/components/AccessibilityPanel.tsx`; the color blind modes are `VISIONS` and `SWAPS` in `src/lib/color.ts` | Each choice is an attribute on `` styled in `src/index.css`, and `index.html` sets it again before the first paint, so a new one goes in all three. A color blind mode replaces all three color families, teal, green and amber (`SWAPS`, picked by simulating each type: see the comment there), in code, in data colors as they load (`src/lib/api.ts`, never under /admin), in CSS (the `--pal-*` variables in `src/index.css`, which hold the same values as `SWAPS`: change both) and in the theme tokens drawn from them. A palette hex in a component or CSS file should be `var(--pal--)` (eg. `var(--pal-amber-2)`), or a color blind mode won't reach it. Reading mode is `src/components/ReaderView.tsx`, which reads the hidden page and writes out its headings, paragraphs, links and described pictures. A part it can't read well (a carousel, tabs, details behind a click, a map) draws its own text version when `useReadingMode()` (`src/lib/readingMode.ts`) is on: the hero, pathfinder, stats, history rail, event lists, calendar (the next six weeks), featured cards, org lists and groups map, history timeline, schedule, people tiles and video player; the countdown draws nothing. A new component with any of those should do the same. Something saved or sent (the newsletter's colors) is a stored hex, which is never swapped. | -| Privacy Policy and Terms wording | `src/pages/Privacy.tsx`, `src/pages/Terms.tsx` | The `PARTS` list, and `LAST_UPDATED` whenever the wording changes. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. | +| Privacy Policy and Terms wording | the database (082) | Admin → Pages → Page management → Privacy Policy or Terms of Service: their sections' blocks, and the "Last updated" date in the section's blurb whenever the wording changes. The privacy contact email is in the policy's text. The Privacy page must stay true of the code: what the feedback form stores, what the browser keeps, which embeds wait for a click. | | Event type labels and plurals (public site) | `src/lib/eventTypes.ts` | Also the order of the type filter chips. | | Event and person role labels (public site) | `ROLE_LABEL` in `src/pages/EventDetail.tsx` and `src/pages/PersonDetail.tsx` | | | Organization kind labels ("Region", "Group") | the Kind options in `src/lib/adminSchema/organizations.ts` (admin) | | @@ -305,6 +287,14 @@ The numbers band's "Number Source" dropdown works the same way: ## Writing text in the editor +Rotating words: type the choices in braces, `{Next|Now|Rising}`, in a +hero headline, a section title, a heading, a paragraph, a callout or a +quote, and the word cycles through them. How it moves is Admin → +Panel → Site settings → Animated words, or the hero's or block's own +Rotating words fields. Menus, tab titles, search and emails show the +first choice. The component is `src/components/RotatingWords.tsx`; its +motions are CSS in `RotatingWords.css`. + Conventions for any label, help text or option added to the admin, so the editor reads consistently: diff --git a/server/src/admin-crud.js b/server/src/admin-crud.js index c1c0461..18bfdc5 100644 --- a/server/src/admin-crud.js +++ b/server/src/admin-crud.js @@ -139,7 +139,9 @@ function coerceRow(columns, data, { prefix = "" } = {}) { return { values, errors }; } -const applies = (gate, row) => !gate || row[gate.column] === gate.value; +/* A gate on a column's value: one value, or any of a list. */ +const applies = (gate, row) => + !gate || (Array.isArray(gate.value) ? gate.value.includes(row[gate.column]) : row[gate.column] === gate.value); /* ── Read ────────────────────────────────────────────────────── */ @@ -242,6 +244,12 @@ function readChildren(db, child, ownerId) { ) .all(...params); + // A row's own 1:1 side tables (a section's settings for its type: + // its hero's words, its blog's slots). + for (const ext of child.extensions ?? []) { + for (const row of rows) row[ext.key] = readExtension(db, ext, row.id); + } + // Nested collections, to any depth: a page's sections, each // section's blocks, each block's items. The id goes as text: a JS // number binds as REAL, which a TEXT owner column (a section's @@ -411,6 +419,10 @@ export function deleteRow(db, entity, rawId) { } const id = normalizeId(entity, rawId); + // Records the site can't do without (the pages it draws in code). + if (entity.undeletable?.includes(id)) { + throw new HttpError(405, "The site needs this one: it can be hidden or disabled, not deleted."); + } const result = wrapDbErrors(() => db.prepare(`DELETE FROM ${entity.table} WHERE ${entity.idColumn} = ?`).run(id), ); @@ -419,7 +431,7 @@ export function deleteRow(db, entity, rawId) { /* ── Write helpers ───────────────────────────────────────────── */ -function writeExtensions(db, entity, id, payload, parentValues) { +function writeExtensions(db, entity, id, payload, parentValues, prefix = "") { for (const ext of entity.extensions ?? []) { if (!applies(ext.when, parentValues)) { // The gate closed (the kind changed away from this side @@ -431,7 +443,7 @@ function writeExtensions(db, entity, id, payload, parentValues) { } const { values, errors } = coerceRow(ext.columns, payload[ext.key] ?? {}, { - prefix: `${ext.key}.`, + prefix: `${prefix}${ext.key}.`, }); if (Object.keys(errors).length) { throw new HttpError(422, "Validation failed", errors); @@ -584,8 +596,13 @@ function writeRows(db, child, ownerId, incomingRaw, prefix, parentValues) { .run(...params), ); + const rowId = Number(result.lastInsertRowid); + // Its own side tables, gated on its values (a section's preset), + // then its collections, gated the same way. + if (child.extensions) writeExtensions(db, child, rowId, raw, values, rowPrefix); for (const child2 of child.children ?? []) { - writeRows(db, child2, String(result.lastInsertRowid), raw[child2.key], `${rowPrefix}${child2.key}.`, values); + if (!applies(child2.when, values)) continue; + writeRows(db, child2, String(rowId), raw[child2.key], `${rowPrefix}${child2.key}.`, values); } }); } diff --git a/server/src/admin-schema-sync.js b/server/src/admin-schema-sync.js index 5c671d0..2ad77c3 100644 --- a/server/src/admin-schema-sync.js +++ b/server/src/admin-schema-sync.js @@ -85,6 +85,13 @@ function collectGroups(entity) { ...Object.keys(child.owner.inherit ?? {}), ].filter(Boolean), }); + for (const ext of child.extensions ?? []) { + groups.push({ + table: ext.table, + columns: ext.columns ?? [], + engineSupplied: [ext.idColumn, ext.owner?.column, ext.owner?.kindColumn].filter(Boolean), + }); + } for (const nested of child.children ?? []) walk(nested); }; diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js index 31039af..824c108 100644 --- a/server/src/admin-schema.js +++ b/server/src/admin-schema.js @@ -18,9 +18,14 @@ regions or groups row should exist) children ordered collections, replaced wholesale on save; `readRole` on one hides it from lesser roles, as - on an extension (an organization's contacts) + on an extension (an organization's contacts). A + child may have `extensions` of its own (a page + section's settings for its type), and its nested + collections a `when` on its values singleton the one id this entity ever has; the engine - refuses create and delete (see front_page) + refuses create and delete (see navigation) + undeletable ids the engine refuses to delete (the pages the + site draws in code) check (db, id) => void, run after a save has written everything, inside its transaction: throw an HttpError to refuse it (site settings' colors) @@ -50,7 +55,6 @@ import { people } from "./admin-schema/people.js"; import { teams } from "./admin-schema/teams.js"; import { awards } from "./admin-schema/awards.js"; import { timeline } from "./admin-schema/timeline.js"; -import { frontPage } from "./admin-schema/frontPage.js"; import { blogPosts } from "./admin-schema/blog.js"; import { siteSettings } from "./admin-schema/siteSettings.js"; import { siteNav } from "./admin-schema/siteNav.js"; @@ -59,14 +63,7 @@ import { personTagTypes } from "./admin-schema/personTags.js"; import { tags } from "./admin-schema/tags.js"; import { contactTypes } from "./admin-schema/contactTypes.js"; import { redirects } from "./admin-schema/redirects.js"; -import { - communityPage, - retreatsPage, - resourcesPage, - organizationPage, - historyPage, - shopPage, -} from "./admin-schema/sitePages.js"; +import { pages } from "./admin-schema/sitePages.js"; export const ENTITIES = { organizations, @@ -79,14 +76,8 @@ export const ENTITIES = { teams, awards, timeline, - front_page: frontPage, blog_posts: blogPosts, - community_page: communityPage, - retreats_page: retreatsPage, - resources_page: resourcesPage, - organization_page: organizationPage, - history_page: historyPage, - shop_page: shopPage, + pages, navigation: siteNav, site_settings: siteSettings, newsletters, @@ -116,6 +107,8 @@ export const OPTION_QUERIES = { // Link fields with `redirects: true` pick from these (068). redirects: "SELECT id, id || ' (' || target_url || ')' AS label FROM redirects ORDER BY id", blog_posts: "SELECT id, title AS label FROM blog_posts ORDER BY published_on DESC, title", + // Navigation's Under page: a page by its address (080). + site_pages: "SELECT path AS id, title || ' (' || path || ')' AS label FROM site_pages ORDER BY sort_order, title", // org_id rides along so the affiliation row can filter the list // down to teams of the organization it already names. diff --git a/server/src/admin-schema/columns.js b/server/src/admin-schema/columns.js index d524795..b39f6d5 100644 --- a/server/src/admin-schema/columns.js +++ b/server/src/admin-schema/columns.js @@ -164,6 +164,10 @@ export const blocksChild = (ownerKind) => ({ text("cite"), // Video blocks only (066): an uploaded video's WebVTT file. text("captions"), + // Its rotating words (084): blank keeps the site's. + enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]), + enumeration("word_direction", ["top", "bottom"]), + int("word_seconds"), // People blocks only (054): whose team's tiles to show. text("team_id"), ], diff --git a/server/src/admin-schema/frontPage.js b/server/src/admin-schema/frontPage.js deleted file mode 100644 index bc2be0b..0000000 --- a/server/src/admin-schema/frontPage.js +++ /dev/null @@ -1,129 +0,0 @@ -import { text, url, int, bool, enumeration, featuredCardsChild } from "./columns.js"; - -/* ── Front page ────────────────────────────────────────────────── - - A singleton: one row, id 'home', seeded by the schema and never - created by the admin. `singleton` tells the engine to refuse create - and delete, and the CHECK on front_page.id is what makes a second - 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 - their actions as a nested collection, the shape content blocks - and their items already use. */ - -export const frontPage = { - key: "front_page", - table: "front_page", - idColumn: "id", - idKind: "slug", - singleton: "home", - concurrency: "updated_at", - - list: { - columns: ["id", "headline", "hero_backdrop", "hero_feature", "updated_at"], - filters: [], - search: [], - order: "id", - }, - - columns: [ - enumeration("hero_backdrop", ["brand", "photos"]), - enumeration("hero_feature", ["none", "livestream", "video", "event"]), - text("hero_event_id"), - text("eyebrow"), - text("headline"), - text("subhead"), - text("primary_label"), - url("primary_url"), - text("secondary_label"), - url("secondary_url"), - int("slide_seconds"), - url("livestream_url"), - text("livestream_title"), - url("video_url"), - text("video_title"), - text("video_captions"), - text("countdown_event_id"), - text("countdown_scope_id"), - enumeration("countdown_event_type", ["retreat", "class", "workshop", "meeting", "other"]), - int("featured_columns"), - text("video_still"), - ], - - children: [ - { - key: "slides", - table: "front_page_slides", - owner: { column: "page_id" }, - order: "sort_order", - columns: [ - text("media", { required: true }), - text("alt"), - text("caption"), - url("link_url"), - ], - }, - { - key: "sections", - table: "front_page_sections", - owner: { column: "page_id" }, - order: "sort_order", - columns: [ - enumeration( - "section", - ["countdown", "retreats", "calendar", "stats", "timeline", "connect", "featured"], - { required: true }, - ), - text("title"), - text("blurb"), - bool("is_hidden"), - ], - }, - { - key: "stats", - table: "front_page_stats", - owner: { column: "page_id" }, - order: "sort_order", - columns: [ - text("label", { required: true }), - enumeration("source", [ - "manual", - "years_since", - "regions", - "groups", - "partners", - "events_held", - "retreats_held", - "people", - "awards_given", - ]), - text("value"), - text("suffix"), - text("note"), - ], - }, - featuredCardsChild("front_page"), - { - key: "paths", - table: "front_page_paths", - owner: { column: "page_id" }, - order: "sort_order", - columns: [text("label", { required: true }), text("icon"), text("blurb")], - children: [ - { - key: "actions", - table: "front_page_path_actions", - owner: { column: "path_id" }, - order: "sort_order", - columns: [ - text("label", { required: true }), - text("description"), - url("url", { required: true }), - ], - }, - ], - }, - ], -}; diff --git a/server/src/admin-schema/siteNav.js b/server/src/admin-schema/siteNav.js index 2ac245a..23ed540 100644 --- a/server/src/admin-schema/siteNav.js +++ b/server/src/admin-schema/siteNav.js @@ -1,10 +1,9 @@ import { text, bool, enumeration } from "./columns.js"; /* ── Navigation (075_site_nav.sql) ─────────────────────────────── - Pages → Navigation: the header's and footer's links, in order, - and each static page's title, intro and whether it's hidden - (siteNav.js reads it for the site). Admins and up: it can take a - page off the site. */ + Pages → Navigation: the header's and footer's links, in order + (siteNav.js reads them for the site; the pages themselves are + Page management's, sitePages.js). Admins and up. */ export const siteNav = { key: "navigation", table: "site_nav", @@ -33,12 +32,5 @@ export const siteNav = { bool("new_tab"), ], }, - { - key: "pages", - table: "site_nav_pages", - owner: { column: "nav_id" }, - order: "sort_order", - columns: [text("path", { required: true }), text("title"), text("description"), bool("is_hidden")], - }, ], }; diff --git a/server/src/admin-schema/sitePages.js b/server/src/admin-schema/sitePages.js index 5a28fc1..d5be89c 100644 --- a/server/src/admin-schema/sitePages.js +++ b/server/src/admin-schema/sitePages.js @@ -1,18 +1,25 @@ -import { text, url, int, enumeration, featuredCardsChild, blocksChild } from "./columns.js"; +import { HttpError } from "../admin-crud.js"; +import { text, url, int, bool, enumeration, featuredCardsChild, blocksChild } from "./columns.js"; -/* ── The site's own pages (056_site_pages.sql) ─────────────────── +/* ── The site's pages (056_site_pages.sql, 080_page_registry.sql) ── - Community, Retreats, Resources, Organization, History and Shop - (075): one - site_pages row each, edited as its own singleton, with its - sections nested under it and each section's blocks under that + Pages → Page management: every page of the site, one site_pages + row each (its address, title, intro, Hidden and Disabled), with + its sections nested under it and each section's blocks under that (the blocks' items under them, as on any record). A section is either its blocks or a preset, a prebuilt part of the site - (SitePage.tsx draws both). + (SitePage.tsx draws both). New pages are made here. - Community also carries the blog section's settings: the - community_page row (same id) as an extension, and its pinned - posts, cards and feeds, all owned by that id. */ + A section type that needs more than its blocks keeps its settings + in tables of its own (083_section_settings.sql), the section's + extensions and collections here, each gated on its preset: a + hero's words and slides, a countdown's event, a stats band's + numbers, a pathfinder's paths, featured cards, a Community blog's + slots, pinned posts and feeds. The front page is a page of + sections like the rest. */ + +/* Gates on the section's preset. */ +const is = (preset) => ({ column: "preset", value: preset }); const sectionsChild = { key: "sections", @@ -32,12 +39,85 @@ const sectionsChild = { "events", "timeline", "people_directory", + // What used to be whole pages (081). + "feedback_form", + "request_form", + "data_request_form", + "giving", + "qr_maker", + // The front page's bands, on any page (083). + "hero", + "countdown", + "calendar", + "stats", + "featured_cards", + "connect", ]), text("scope_id"), enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]), enumeration("view", ["carousel", "grid", "map"]), // Organization cards (067): the kinds listed by themselves. enumeration("org_kinds", ["partner", "ministry", "partner,ministry"]), + bool("is_hidden"), + ], + extensions: [ + { + key: "hero", + table: "section_hero", + idColumn: "section_id", + when: is("hero"), + columns: [ + text("eyebrow"), + text("headline"), + text("subhead"), + text("primary_label"), + url("primary_url"), + text("secondary_label"), + url("secondary_url"), + enumeration("backdrop", ["brand", "photos"]), + int("slide_seconds"), + enumeration("feature", ["none", "livestream", "video", "event"]), + url("livestream_url"), + text("livestream_title"), + url("video_url"), + text("video_title"), + text("video_captions"), + text("video_still"), + text("event_id"), + // Its rotating words (084). + enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]), + enumeration("word_direction", ["top", "bottom"]), + int("word_seconds"), + ], + }, + { + key: "countdown", + table: "section_countdown", + idColumn: "section_id", + when: is("countdown"), + columns: [text("event_id"), text("scope_id"), enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"])], + }, + { + key: "featured", + table: "section_featured", + idColumn: "section_id", + when: is("featured_cards"), + columns: [int("columns")], + }, + { + key: "blog", + table: "section_blog", + idColumn: "section_id", + when: is("community_blog"), + columns: [ + text("internal_title"), + int("internal_slots"), + text("external_title"), + int("external_slots"), + url("external_url"), + text("external_label"), + ], + }, ], children: [ blocksChild("page_section"), @@ -57,61 +137,128 @@ const sectionsChild = { order: "sort_order", columns: [text("org_id", { required: true })], }, - ], -}; - -const sitePage = (id, more = {}) => ({ - key: `${id}_page`, - table: "site_pages", - idColumn: "id", - idKind: "slug", - singleton: id, - concurrency: "updated_at", - - list: { columns: ["id", "updated_at"], filters: [], search: [], order: "id" }, - - columns: [], - ...more, - children: [sectionsChild, ...(more.children ?? [])], -}); - -export const communityPage = sitePage("community", { - extensions: [ { - key: "blog", - table: "community_page", - idColumn: "id", + key: "slides", + table: "section_slides", + owner: { column: "section_id" }, + order: "sort_order", + when: is("hero"), + columns: [text("media", { required: true }), text("alt"), text("caption"), url("link_url")], + }, + { + key: "stats", + table: "section_stats", + owner: { column: "section_id" }, + order: "sort_order", + when: is("stats"), columns: [ - text("internal_title"), - int("internal_slots"), - text("external_title"), - int("external_slots"), - url("external_url"), - text("external_label"), + text("label", { required: true }), + enumeration("source", [ + "manual", + "years_since", + "regions", + "groups", + "partners", + "events_held", + "retreats_held", + "people", + "awards_given", + ]), + text("value"), + text("suffix"), + text("note"), ], }, - ], - children: [ { - key: "pinned_posts", - table: "community_page_pinned_posts", - owner: { column: "page_id" }, + key: "paths", + table: "section_paths", + owner: { column: "section_id" }, order: "sort_order", + when: is("connect"), + columns: [text("label", { required: true }), text("icon"), text("blurb")], + children: [ + { + key: "actions", + table: "section_path_actions", + owner: { column: "path_id" }, + order: "sort_order", + columns: [text("label", { required: true }), text("description"), url("url", { required: true })], + }, + ], + }, + // Featured cards, and a Community blog's pinned community posts. + { ...featuredCardsChild("page_section"), when: { column: "preset", value: ["featured_cards", "community_blog"] } }, + { + key: "blog_posts", + table: "section_blog_posts", + owner: { column: "section_id" }, + order: "sort_order", + when: is("community_blog"), columns: [text("post_id", { required: true })], }, - featuredCardsChild("community_page"), { key: "feeds", - table: "community_page_feeds", - owner: { column: "page_id" }, + table: "section_feeds", + owner: { column: "section_id" }, order: "sort_order", + when: is("community_blog"), columns: [url("url", { required: true }), text("label")], }, ], -}); +}; -export const retreatsPage = sitePage("retreats"); -export const resourcesPage = sitePage("resources"); -export const organizationPage = sitePage("organization"); -export const historyPage = sitePage("history"); -export const shopPage = sitePage("shop"); + +/* Pages the site's own code links to (the footer's defaults, the + Request buttons, the privacy notice, Tools → QR codes): renamed, + hidden or disabled, but never moved or deleted. */ +export const CORE_PAGES = { home: "/", give: "/give", feedback: "/feedback", request: "/request", qr: "/qr", privacy: "/privacy", terms: "/terms" }; + +/* Addresses a page can't take: the admin, the API, the uploads, the + records' own pages and the account pages. */ +const RESERVED = [ + "admin", "api", "uploads", "assets", "pa", "go", + "events", "regions", "groups", "partners", "organizations", "teams", "awards", "people", "blog", "directory", + "sign-in", "account", "sitemap.xml", "robots.txt", +]; + +/* After a save: the address is one a page may have. */ +function checkPage(db, id) { + const page = db.prepare(`SELECT path FROM site_pages WHERE id = ?`).get(id); + const first = page?.path.split("/")[1]; + if (first && RESERVED.includes(first)) { + throw new HttpError(422, "Validation failed", { path: `/${first} belongs to another part of the site. Pick another address.` }); + } + if (CORE_PAGES[id] && page.path !== CORE_PAGES[id]) { + throw new HttpError(422, "Validation failed", { path: `The site links to this page at ${CORE_PAGES[id]}, so its address stays.` }); + } + if (id !== "home" && page.path === "/") throw new HttpError(422, "Validation failed", { path: "/ is the front page." }); +} + +export const pages = { + key: "pages", + table: "site_pages", + idColumn: "id", + idKind: "slug", + concurrency: "updated_at", + undeletable: Object.keys(CORE_PAGES), + + list: { + columns: ["title", "path", "is_hidden", "is_disabled", "updated_at"], + filters: [], + search: ["title", "path"], + order: "sort_order, title", + }, + + columns: [ + text("path", { required: true }), + text("title", { required: true }), + text("description"), + bool("is_hidden"), + bool("is_disabled"), + int("sort_order"), + ], + + children: [sectionsChild], + + check: checkPage, +}; diff --git a/server/src/admin-schema/siteSettings.js b/server/src/admin-schema/siteSettings.js index db5ef93..f1c2588 100644 --- a/server/src/admin-schema/siteSettings.js +++ b/server/src/admin-schema/siteSettings.js @@ -1,5 +1,5 @@ import { THEME_TOKENS, checkTheme } from "../theme.js"; -import { text, enumeration } from "./columns.js"; +import { text, int, enumeration } from "./columns.js"; /* ── Site settings (035_site_settings.sql) ────────────────────── A singleton of overrides for what site.json says: name, @@ -30,13 +30,18 @@ export const siteSettings = { text("favicon"), text("apple_touch_icon"), enumeration("indexing", ["on", "off"]), - text("privacy_email"), text("notify_emails"), text("access_group_viewer"), text("access_group_editor"), text("access_group_admin"), enumeration("report_daily", ["on", "off"]), enumeration("report_weekly", ["on", "off"]), + // Rotating words' defaults (084). + enumeration("word_motion", ["slide", "flip", "fade", "type", "mirror"]), + enumeration("word_direction", ["top", "bottom"]), + int("word_seconds"), + // Data → Planning Center's list (085). + text("pco_list_id"), ], children: [ diff --git a/server/src/docx.js b/server/src/docx.js index 09d0567..d7b7806 100644 --- a/server/src/docx.js +++ b/server/src/docx.js @@ -14,6 +14,17 @@ cells split by |) bold, italic, links **bold**, *italic*, [text](url) + And a few lines written a certain way (docs/importing.md), any + style: + "Tab: Overview" a tab block (079): the post + is split into tabs there + the Quote style a quote block + the Intense Quote style a callout block + "---" alone a divider + a YouTube, Vimeo or Facebook link a video block + alone on its line + "Button: [Register](https://…)" a button block + Images, text boxes, footnotes and comments aren't carried over; the result counts what was skipped so the editor can say so. @@ -216,7 +227,7 @@ export function readDocx(buf) { if (!text) continue; const level = style === "title" ? 0 : Number(/^heading (\d)/.exec(style)?.[1] ?? NaN); - if (!title && (level === 0 || level === 1)) { + if (!title && (level === 0 || level === 1) && !lineBlock(text, style)) { close(); title = text.replace(/\*/g, ""); continue; @@ -231,6 +242,12 @@ export function readDocx(buf) { continue; } } + const special = lineBlock(text, style); + if (special) { + close(); + blocks.push(special); + continue; + } if (level >= 1) { close(); blocks.push({ type: level <= 2 ? "heading" : "subheading", text: text.replace(/\*/g, "") }); @@ -248,3 +265,37 @@ export function readDocx(buf) { return { title, date, blocks, skipped: counts }; } + +/* ── Lines written a certain way ──────────────────────────────── */ + +const VIDEO_HOST = /^https?:\/\/(www\.)?(youtube\.com|youtu\.be|m\.youtube\.com|vimeo\.com|player\.vimeo\.com|facebook\.com|fb\.watch)\//i; + +/* The one link a line is made of, "[text](url)" or a bare url, or null. */ +function loneLink(text) { + const md = /^\[[^\]]*\]\(([^)\s]+)\)$/.exec(text); + if (md) return md[1]; + return /^https?:\/\/\S+$/.test(text) ? text : null; +} + +/* A block a paragraph stands for by how it's written, or null for an + ordinary one (docs/importing.md). */ +function lineBlock(text, style) { + const plain = text.replace(/\*/g, "").trim(); + const tab = /^tab:\s*(.+)$/i.exec(plain); + if (tab) return { type: "tab", text: tab[1].trim().slice(0, 80) }; + if (/^(-{3,}|_{3,})$/.test(plain)) return { type: "divider" }; + + const button = /^button:\s*\[([^\]]+)\]\(([^)\s]+)\)$/i.exec(text.trim()); + if (button) return { type: "button", text: button[1].replace(/\*/g, ""), href: button[2] }; + + const link = loneLink(text.trim()); + if (link && VIDEO_HOST.test(link)) return { type: "video", href: link }; + + if (style === "intense quote") return { type: "callout", text }; + if (style === "quote") { + // A dash and a name at the end ("… - Jane Doe", any dash) is who said it. + const said = /^(.*\S)\s+[—–-]\s*([^—–-]{2,80})$/.exec(text); + return said ? { type: "quote", text: said[1], cite: said[2].trim() } : { type: "quote", text }; + } + return null; +} diff --git a/server/src/feeds.js b/server/src/feeds.js index 43f826a..6b03564 100644 --- a/server/src/feeds.js +++ b/server/src/feeds.js @@ -2,7 +2,7 @@ FEEDS Reads the RSS and Atom feeds the Community page's blog section - lists (community_page_feeds), for its "newest community posts". + lists (section_feeds, 083), for its "newest community posts". A Substack's feed is https://.substack.com/feed. Each feed is fetched through linkPreview.js's safeGet, so it gets diff --git a/server/src/index.js b/server/src/index.js index a1ec0ea..51c369e 100644 --- a/server/src/index.js +++ b/server/src/index.js @@ -24,7 +24,6 @@ import { rateLimit } from "./rateLimit.js"; import content from "./routes/content.js"; import people from "./routes/people.js"; import history from "./routes/history.js"; -import home from "./routes/home.js"; import directory from "./routes/directory.js"; import blog from "./routes/blog.js"; import sitePages from "./routes/sitePages.js"; @@ -34,6 +33,7 @@ import requests from "./routes/requests.js"; import auth from "./routes/auth.js"; import account from "./routes/account.js"; import profiles from "./routes/profiles.js"; +import pco from "./routes/pco.js"; import admin from "./routes/admin.js"; import panel from "./routes/panel.js"; import adminEntities from "./routes/admin-entities.js"; @@ -192,7 +192,6 @@ app.get("/api/health", (c) => app.route("/api", content); app.route("/api", people); app.route("/api", history); -app.route("/api", home); app.route("/api", directory); app.route("/api", blog); app.route("/api", sitePages); @@ -225,6 +224,7 @@ app.use("/api/account/photo", rateLimit({ windowMs: 15 * 60_000, max: 20 })); app.route("/api/account", account); app.route("/api/admin", admin); app.route("/api/admin", profiles); +app.route("/api/admin", pco); // Before the entity routes, whose /:entity would claim /media. app.route("/api/admin", media); app.route("/api/admin", imports); diff --git a/server/src/migrations/080_page_registry.sql b/server/src/migrations/080_page_registry.sql new file mode 100644 index 0000000..d0fd70a --- /dev/null +++ b/server/src/migrations/080_page_registry.sql @@ -0,0 +1,93 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 080 PAGE REGISTRY +-- +-- Every page of the site is a site_pages row: its address, title +-- and intro (the page's heading and its search text), and two +-- switches, all edited in Pages → Page management, where new pages +-- are made too. site.json's "pages" and Navigation's page list +-- (site_nav_pages, 075) both move here and go: this is the one +-- place a page's words live. +-- +-- path '/retreats'; a new page's own, eg. '/library'. +-- Unique; '/' is the front page. +-- is_hidden Not found to everyone below viewer, out of the +-- menus and sitemap (siteNav.js) +-- is_disabled out of the menus, the sitemap and search; the +-- address still works +-- sort_order the order of the admin home's page cards +-- +-- A page is its sections (page_sections), except the few the site +-- still draws in code (src/pages/fixedPages.ts): the front page, +-- Feedback, Request, Give, QR codes, Privacy and Terms. Those take +-- their title and intro from here all the same, and can't be +-- deleted (admin-schema/pages.js). +-- +-- The id stays a slug, as before (page sections, the Community +-- blog's settings and the drafts key on it), so an existing page +-- keeps its id; its address can change. +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE site_pages_new ( + id TEXT PRIMARY KEY + CONSTRAINT "A page's URL ID can use only lowercase letters, numbers and hyphens." + CHECK (id <> '' AND id NOT GLOB '*[^a-z0-9-]*'), + path TEXT NOT NULL UNIQUE + CONSTRAINT "A page's address starts with / and uses only lowercase letters, numbers, hyphens and /, eg. /library." + CHECK (path = '/' OR (path GLOB '/[a-z0-9]*' AND path NOT GLOB '*[^a-z0-9/-]*' AND path NOT GLOB '*/')), + title TEXT NOT NULL, + description TEXT, + is_hidden INTEGER NOT NULL DEFAULT 0 CHECK (is_hidden IN (0, 1)), + is_disabled INTEGER NOT NULL DEFAULT 0 CHECK (is_disabled IN (0, 1)), + sort_order INTEGER NOT NULL DEFAULT 0, + updated_at TEXT NOT NULL DEFAULT (datetime('now')) +) STRICT; + +INSERT INTO site_pages_new (id, path, title, description, sort_order) VALUES + ('home', '/', 'Home', NULL, 0), + ('retreats', '/retreats', 'Retreats', 'Retreats hosted by Next Generation of Unity, our regions, and our partners throughout the year.', 1), + ('community', '/community', 'Community', 'Groups, regions and the people who make up Next Generation of Unity.', 2), + ('resources', '/resources', 'Resources', 'Teachings, brand assets, and material for groups and partners.', 3), + ('organization', '/organization', 'Organization', 'Our mission, vision and values, the people who lead Next Generation of Unity, and how to reach us.', 4), + ('history', '/history', 'History', 'A near-complete timeline of Next Generation of Unity (NGU), and other Unity Young Adult programs.', 5), + ('shop', '/shop', 'Shop', 'Shirts, stickers and more from Next Generation of Unity. Every purchase supports our retreats and programs.', 6), + ('give', '/give', 'Giving', 'Support the work of Next Generation of Unity.', 7), + ('feedback', '/feedback', 'Feedback', 'Tell us what''s working, what isn''t, and what you''d like to see next.', 8), + ('request', '/request', 'Request', 'Ask for a blog post, an event, or a new or updated group, region, partner, team, award or person on the site.', 9), + ('qr', '/qr', 'QR Codes', 'Codes for flyers, slides and signs, pointing at any page on the site or any link, in your choice of colors.', 10), + ('privacy', '/privacy', 'Privacy Policy', 'How Next Generation of Unity collects, uses, and protects your information.', 11), + ('terms', '/terms', 'Terms of Service', 'The terms that apply when you use this site and our programs.', 12); + +-- Each page's sections' save time comes along. +UPDATE site_pages_new + SET updated_at = (SELECT updated_at FROM site_pages WHERE site_pages.id = site_pages_new.id) + WHERE id IN (SELECT id FROM site_pages); + +-- What Navigation (or before it Site settings) changed. +UPDATE site_pages_new + SET title = COALESCE((SELECT n.title FROM site_nav_pages n WHERE n.path = site_pages_new.path), title), + description = COALESCE((SELECT n.description FROM site_nav_pages n WHERE n.path = site_pages_new.path), description), + is_hidden = COALESCE((SELECT n.is_hidden FROM site_nav_pages n WHERE n.path = site_pages_new.path), is_hidden); + +DROP TABLE site_nav_pages; + +-- The admin edits every page as one entity now ('pages'), so a +-- page's draft (077) moves under it. +UPDATE drafts + SET entity = 'pages', record_id = substr(entity, 1, length(entity) - 5) + WHERE entity IN ('community_page', 'retreats_page', 'resources_page', 'organization_page', 'history_page', 'shop_page'); + +-- page_sections names site_pages; legacy mode leaves it alone +-- through the rename. +PRAGMA legacy_alter_table = ON; +DROP TABLE site_pages; +ALTER TABLE site_pages_new RENAME TO site_pages; +PRAGMA legacy_alter_table = OFF; + +CREATE INDEX site_pages_order_idx ON site_pages (sort_order); + +CREATE TRIGGER site_pages_touch +AFTER UPDATE ON site_pages +FOR EACH ROW WHEN new.updated_at = old.updated_at +BEGIN + UPDATE site_pages SET updated_at = datetime('now') WHERE id = new.id; +END; diff --git a/server/src/migrations/081_section_types.sql b/server/src/migrations/081_section_types.sql new file mode 100644 index 0000000..fed865a --- /dev/null +++ b/server/src/migrations/081_section_types.sql @@ -0,0 +1,65 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 081 SECTION TYPES +-- +-- page_sections.preset takes the parts of the site that were whole +-- pages, so those pages become pages of sections like any other +-- (082 builds them): +-- +-- feedback_form the website feedback form (Feedback) +-- request_form the request form (Request) +-- data_request_form the data request form (Privacy) +-- giving the Church Center giving button (Give) +-- qr_maker the QR code maker (QR codes) +-- +-- and the front page's bands, to go on any page with content of +-- their own (they're offered once they're built): hero, countdown, +-- calendar, stats, featured_cards, connect. +-- +-- The CHECK can't change in place, so the table is rebuilt. +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE page_sections_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + anchor TEXT NOT NULL + CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership." + CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'), + title TEXT NOT NULL + CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav)." + CHECK (length(title) <= 30), + blurb TEXT, + accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')), + preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list', + 'events', 'timeline', 'people_directory', + 'feedback_form', 'request_form', 'data_request_form', 'giving', 'qr_maker', + 'hero', 'countdown', 'calendar', 'stats', 'featured_cards', 'connect')), + -- An events preset's filter and first view. + scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL, + event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')), + view TEXT CHECK (view IN ('carousel', 'grid', 'map')), + -- Organization cards (067): the kinds listed by themselves. + org_kinds TEXT CHECK (org_kinds IN ('partner', 'ministry', 'partner,ministry')), + UNIQUE (page_id, anchor) +) STRICT; + +INSERT INTO page_sections_new + (id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds) +SELECT id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds + FROM page_sections; + +-- page_section_orgs, page_section_tags and content_blocks' owner +-- trigger name page_sections; legacy mode leaves them alone through +-- the rename. +PRAGMA legacy_alter_table = ON; +DROP TABLE page_sections; +ALTER TABLE page_sections_new RENAME TO page_sections; +PRAGMA legacy_alter_table = OFF; + +CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order); + +CREATE TRIGGER page_sections_cleanup +AFTER DELETE ON page_sections +BEGIN + DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT); +END; diff --git a/server/src/migrations/082_core_pages_as_sections.sql b/server/src/migrations/082_core_pages_as_sections.sql new file mode 100644 index 0000000..7283c93 --- /dev/null +++ b/server/src/migrations/082_core_pages_as_sections.sql @@ -0,0 +1,98 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 082 CORE PAGES AS SECTIONS +-- +-- Feedback, Request, QR codes, Give, Privacy and Terms were drawn in +-- code; now each is a page of sections like any other, with what +-- it said put in as blocks, so it's edited in Page management: +-- +-- Feedback a feedback_form section +-- Request a request_form section +-- QR codes a qr_maker section +-- Give a giving section: its two paragraphs, then the +-- Church Center button +-- Privacy the policy as heading, paragraph and list blocks, +-- then a data_request_form section +-- Terms the terms as blocks +-- +-- The privacy contact email (Site settings) was written into the +-- policy's text by the page; it's written into the blocks now, and +-- the setting goes (this text is where it's changed from now on). +-- ═══════════════════════════════════════════════════════════════ + +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('feedback', 0, 'website', 'Website Feedback', 'Found a broken link, spotted something out of date, or want the site to do something it doesn''t? This form goes straight to the people who maintain it.', 'feedback_form'); +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('request', 0, 'request', 'Send a request', 'Tell us what you''d like on the site, or what should change. Attach a Word document with the details and we''ll take it from there.', 'request_form'); +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('qr', 0, 'make', 'Make a QR code', 'Pick a page from the main navigation, any event, organization, team, award, person or blog post, or type any link. Site pages always point at the live site. Choose what sits in the center and the colors; a warning shows if the code might not scan.', 'qr_maker'); +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('give', 0, 'give', 'Give to NGU', 'Your giving funds scholarships, retreats, leadership development and the continued growth of the Next Generation of Unity leaders, teachers and community members.', 'giving'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'give' AND anchor = 'give'), 'body', 0, 'paragraph', 'Gifts are processed securely through Church Center. The form opens right here on the page and you can give once or set up a recurring gift, and you don''t need an account to do either.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'give' AND anchor = 'give'), 'body', 1, 'paragraph', 'If you would like to send a check, please email our Board Treasurer at [treasurer@nextgenerationofunity.org](mailto:treasurer@nextgenerationofunity.org) to get an address.'); +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('privacy', 0, 'privacy', 'Privacy Policy', 'Last updated: October 3, 2026', NULL); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 0, 'heading', 'In short'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 1, 'paragraph', 'We collect some information about the people who use this site and take part in Next Generation of Unity (NGU). We use it to run our programs and this website, we don''t sell it, and we don''t use advertising or tracking cookies.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 2, 'paragraph', 'If you want to see, correct or delete what we hold about you, ' || (CASE WHEN (SELECT privacy_email FROM site_settings WHERE id = 'site') IS NOT NULL THEN 'email [' || (SELECT privacy_email FROM site_settings WHERE id = 'site') || '](mailto:' || (SELECT privacy_email FROM site_settings WHERE id = 'site') || ') or use the ' ELSE 'use the ' END) || '[request form](#requests) below.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 3, 'heading', 'What we collect'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 4, 'paragraph', 'Depending on how you use the site and our programs:'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 5, 'list', NULL); +CREATE TEMP TABLE IF NOT EXISTS _list (id INTEGER); +DELETE FROM _list; +INSERT INTO _list (id) VALUES (last_insert_rowid()); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 0, '**Feedback and requests you send.** Your message, the page it''s about, and, if you give them, your name and email. With it we keep your browser''s description (its user agent) and a scrambled form of your IP address that can''t be turned back into the address; we use it only to spot abuse. Files you attach to a [request](/request) are kept with it.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 1, '**People on the site.** Leaders, speakers and volunteers can appear with a name, photo, role, short bio and public contact details. Staff may also keep private details, such as a birth date, private email, phone number or address, which are never shown on the site and can only be seen by our editors.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 2, '**Server records.** Like most websites, our server keeps short-lived logs of requests (the page asked for, the time, and the IP address that asked) to keep the site running and secure.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 3, '**Staff accounts.** For NGU staff and volunteers who sign in to edit the site: name, email, role, and a record of sign-ins. Passwords are stored only in a form that can''t be read back.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 6, 'heading', 'Young people'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 7, 'paragraph', 'We don''t show information about anyone under 18 on this site: no names, photos or details. If you believe something about a minor appears here, tell us and we''ll take it down.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 8, 'heading', 'How we use it'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 9, 'paragraph', 'To answer you, to run our retreats, groups and other programs, to keep this site accurate and working, and to keep it secure. We don''t sell or rent your information, and we don''t use it for advertising.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 10, 'heading', 'Artificial intelligence'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 11, 'paragraph', 'We used AI tools to help write this website''s code and build its structure. Those tools have no access to our database. Information you give us, and information we hold about the people in our community, is not given to AI systems, and isn''t used to train them.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 12, 'heading', 'Other services'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 13, 'paragraph', 'We try not to rely on other companies, but a few parts of the site are provided by them. When you use those parts, what you enter or do there goes to that company and is covered by its own privacy policy:'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 14, 'list', NULL); +CREATE TEMP TABLE IF NOT EXISTS _list (id INTEGER); +DELETE FROM _list; +INSERT INTO _list (id) VALUES (last_insert_rowid()); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 0, '**Giving** is handled by Church Center (Planning Center), at [ngu.churchcenteronline.com](https://ngu.churchcenteronline.com). Payment details go to them, not to us. Church Center''s script loads when you open our Giving page, and its giving form opens when you press Give; Church Center may use Google Analytics in that form, under its own privacy policy.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 1, '**Videos** come from YouTube, Facebook or Vimeo, and **maps** from Google Maps. Nothing from them loads until you press play or choose to show the map.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 2, '**Links** to social media, Substack and other sites take you to those sites, which follow their own rules.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 3, '**Staff sign-in** can use a Google account on our own domain.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 4, '**Files attached to requests** are stored in our Google Workspace (Google Drive), and our staff may be told of a new request by email through it.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 15, 'paragraph', 'This site runs on a server we rent and manage ourselves; your information is stored there, not with an outside website service, apart from request files as above.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 16, 'heading', 'Cookies and browser storage'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 17, 'paragraph', 'This site doesn''t use advertising or tracking cookies, and doesn''t use Google Analytics. To see which pages are read, we use [Plausible Analytics](https://plausible.io), which we host ourselves on our own server using its free, open-source [Community Edition](https://github.com/plausible/community-edition/): it sets no cookies, doesn''t follow you across sites, and keeps no personal information, only counts of visits to each page; nothing from it is shared or sold. The site also keeps a few small things in your own browser so it works the way you left it:'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 18, 'list', NULL); +CREATE TEMP TABLE IF NOT EXISTS _list (id INTEGER); +DELETE FROM _list; +INSERT INTO _list (id) VALUES (last_insert_rowid()); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 0, 'That you closed the announcement banner or the privacy notice.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 1, 'Whether you chose the light or dark look.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 2, 'Your accessibility choices: the dyslexia-friendly font, reading mode and color blind mode.'); +INSERT INTO content_block_items (block_id, sort_order, text) VALUES ((SELECT id FROM _list), 3, 'For staff who sign in: a sign-in cookie that keeps you signed in, and a short-lived one used while signing in with Google.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 19, 'paragraph', 'None of these are shared with anyone. If you press play on a video or show a map, that service (YouTube, Facebook, Vimeo or Google) may set its own cookies from then on. You can clear all of this in your browser''s settings at any time.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 20, 'heading', 'Your choices'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 21, 'paragraph', 'You can ask to see the information we hold about you, to correct it, or to have it deleted. To do that, ' || (CASE WHEN (SELECT privacy_email FROM site_settings WHERE id = 'site') IS NOT NULL THEN 'email [' || (SELECT privacy_email FROM site_settings WHERE id = 'site') || '](mailto:' || (SELECT privacy_email FROM site_settings WHERE id = 'site') || ') or use the ' ELSE 'use the ' END) || '[request form](#requests) below. We may ask you to confirm it''s you before we change or delete anything, and we''ll tell you when it''s done. Some records we may need to keep, such as records of gifts that the law requires; if so, we''ll say which and why.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 22, 'heading', 'Changes to this policy'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'privacy' AND anchor = 'privacy'), 'body', 23, 'paragraph', 'If we change how we handle information, we''ll update this page and the date at the top. See also our [Terms of Service](/terms).'); +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('privacy', 1, 'requests', 'Data requests', 'Ask to see, correct or delete the information we hold about you.', 'data_request_form'); +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset) VALUES ('terms', 0, 'terms', 'Terms of Service', 'Last updated: September 28, 2026', NULL); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 0, 'heading', 'Using this site'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 1, 'paragraph', 'This website belongs to Next Generation of Unity (NGU). By using it you agree to these terms. If you don''t agree, please don''t use the site.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 2, 'paragraph', 'You''re welcome to read, share and link to anything here. Please don''t try to break or overload the site, get into parts of it you haven''t been given access to, or use it to break the law.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 3, 'heading', 'Our content'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 4, 'paragraph', 'The words, logos, photos and videos on this site belong to NGU or to the people who made them, and are used with permission. You can share them for personal and non-commercial use with credit to NGU. For anything else, including using our name or logo, ask us first.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 5, 'heading', 'What you send us'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 6, 'paragraph', 'When you send feedback or a request, you let us use it to answer you and to improve the site and our programs. Please don''t send anything unlawful, abusive, or someone else''s private information.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 7, 'heading', 'Programs, events and giving'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 8, 'paragraph', 'Dates, places and details of retreats and other events can change. The event''s organizers have the final word, and registering for an event may come with its own terms.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 9, 'paragraph', 'Gifts are made through Church Center (Planning Center), under its terms. Questions about a gift can come to us.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 10, 'heading', 'Other sites'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 11, 'paragraph', 'We link to and show videos, maps and posts from other sites. We don''t control them and aren''t responsible for what they say or do; their own terms and privacy policies apply.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 12, 'heading', 'Staff accounts'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 13, 'paragraph', 'Accounts for editing the site are for NGU staff and volunteers we''ve set up. Keep your password and sign-in to yourself. We can change or close an account at any time.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 14, 'heading', 'No guarantees'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 15, 'paragraph', 'We work to keep this site accurate and running, but it''s provided as it is, without guarantees that it will always be available, complete or free of mistakes. To the extent the law allows, NGU isn''t liable for losses that come from using it.'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 16, 'heading', 'Changes'); +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text) VALUES ('page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'terms' AND anchor = 'terms'), 'body', 17, 'paragraph', 'We may update these terms; the date at the top says when they last changed. How we handle personal information is in our [Privacy Policy](/privacy), and you can reach us through the [feedback form](/feedback).'); + +DROP TABLE IF EXISTS _list; + +ALTER TABLE site_settings DROP COLUMN privacy_email; diff --git a/server/src/migrations/083_section_settings.sql b/server/src/migrations/083_section_settings.sql new file mode 100644 index 0000000..33e0254 --- /dev/null +++ b/server/src/migrations/083_section_settings.sql @@ -0,0 +1,435 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 083 SECTION SETTINGS, AND THE FRONT PAGE AS SECTIONS +-- +-- A section type that needs more than its blocks keeps its settings +-- in a table of its own, one row per section (and its lists in +-- tables under the section), so it can go on any page with content +-- of its own. The admin engine reads and writes them as the section's +-- own side tables (admin-crud.js, a child's extensions): +-- +-- section_hero a hero: words, buttons, backdrop, feature +-- section_slides its photos +-- section_countdown a countdown: the pinned event, or the next +-- one of a scope and type +-- section_stats a stats band's numbers +-- section_paths a pathfinder's paths +-- section_path_actions each path's links +-- section_featured featured cards' columns (the cards are +-- featured_cards owned by 'page_section') +-- section_blog a Community blog's headings and slots +-- section_blog_posts its pinned posts of ours +-- section_feeds the feeds its community posts come from +-- (its pinned community posts are +-- featured_cards owned by 'page_section') +-- +-- page_sections gets is_hidden (any section can be left out without +-- deleting it, as the front page's bands could), and a title of up +-- to 60 characters on the front page, which has no side nav; 30 +-- elsewhere. The table is rebuilt for that. +-- +-- Then what was the front page's own (front_page and its lists, 012 +-- to 074) becomes the home page's sections: the hero first, then +-- each band in its order, hidden ones kept hidden; and the Community +-- page's blog settings (community_page) move into its blog section. +-- Those tables go. A timeline section whose view is 'carousel' is +-- the rail of featured moments the front page showed; the full +-- timeline otherwise. +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE page_sections_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + page_id TEXT NOT NULL REFERENCES site_pages (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + anchor TEXT NOT NULL + CONSTRAINT "A section's URL ID can use only lowercase letters, numbers and hyphens, eg. leadership." + CHECK (anchor <> '' AND anchor NOT GLOB '*[^a-z0-9-]*'), + title TEXT NOT NULL + CONSTRAINT "A section title can be 30 characters at most (it's listed in the page's side nav), 60 on the front page." + CHECK (length(title) <= CASE WHEN page_id = 'home' THEN 60 ELSE 30 END), + blurb TEXT, + accent TEXT CHECK (accent IN ('teal', 'deep', 'green', 'amber')), + preset TEXT CHECK (preset IN ('community_blog', 'group_map', 'region_list', 'partner_list', + 'events', 'timeline', 'people_directory', + 'feedback_form', 'request_form', 'data_request_form', 'giving', 'qr_maker', + 'hero', 'countdown', 'calendar', 'stats', 'featured_cards', 'connect')), + -- An events preset's filter and first view. + scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL, + event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')), + view TEXT CHECK (view IN ('carousel', 'grid', 'map')), + -- Organization cards (067): the kinds listed by themselves. + org_kinds TEXT CHECK (org_kinds IN ('partner', 'ministry', 'partner,ministry')), + is_hidden INTEGER NOT NULL DEFAULT 0 CHECK (is_hidden IN (0, 1)), + UNIQUE (page_id, anchor) +) STRICT; + +INSERT INTO page_sections_new + (id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds) +SELECT id, page_id, sort_order, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds + FROM page_sections; + +PRAGMA legacy_alter_table = ON; +DROP TABLE page_sections; +ALTER TABLE page_sections_new RENAME TO page_sections; +PRAGMA legacy_alter_table = OFF; + +CREATE INDEX page_sections_page_idx ON page_sections (page_id, sort_order); + +-- ── The settings tables ────────────────────────────────────────── + +CREATE TABLE section_hero ( + section_id INTEGER PRIMARY KEY REFERENCES page_sections (id) ON DELETE CASCADE, + eyebrow TEXT, + headline TEXT, + subhead TEXT, + primary_label TEXT, + primary_url TEXT, + secondary_label TEXT, + secondary_url TEXT, + backdrop TEXT NOT NULL DEFAULT 'brand' CHECK (backdrop IN ('brand', 'photos')), + slide_seconds INTEGER NOT NULL DEFAULT 7 CHECK (slide_seconds BETWEEN 3 AND 60), + feature TEXT NOT NULL DEFAULT 'none' CHECK (feature IN ('none', 'livestream', 'video', 'event')), + livestream_url TEXT, + livestream_title TEXT, + video_url TEXT, + video_title TEXT, + video_captions TEXT, + video_still TEXT, + event_id TEXT REFERENCES events (id) ON DELETE SET NULL +) STRICT; + +CREATE TABLE section_slides ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + media TEXT NOT NULL, + alt TEXT, + caption TEXT, + link_url TEXT +) STRICT; +CREATE INDEX section_slides_section_idx ON section_slides (section_id, sort_order); + +CREATE TABLE section_countdown ( + section_id INTEGER PRIMARY KEY REFERENCES page_sections (id) ON DELETE CASCADE, + event_id TEXT REFERENCES events (id) ON DELETE SET NULL, + scope_id TEXT REFERENCES event_scopes (id) ON DELETE SET NULL, + event_type TEXT CHECK (event_type IN ('retreat', 'class', 'workshop', 'meeting', 'other')) +) STRICT; + +CREATE TABLE section_stats ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + label TEXT NOT NULL, + source TEXT NOT NULL DEFAULT 'manual' + CHECK (source IN ('manual', 'years_since', 'regions', 'groups', + 'partners', 'events_held', 'retreats_held', + 'people', 'awards_given')), + value TEXT, + suffix TEXT, + note TEXT +) STRICT; +CREATE INDEX section_stats_section_idx ON section_stats (section_id, sort_order); + +CREATE TABLE section_paths ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + label TEXT NOT NULL, + icon TEXT, + blurb TEXT +) STRICT; +CREATE INDEX section_paths_section_idx ON section_paths (section_id, sort_order); + +CREATE TABLE section_path_actions ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + path_id INTEGER NOT NULL REFERENCES section_paths (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + label TEXT NOT NULL, + description TEXT, + url TEXT NOT NULL +) STRICT; +CREATE INDEX section_path_actions_path_idx ON section_path_actions (path_id, sort_order); + +CREATE TABLE section_featured ( + section_id INTEGER PRIMARY KEY REFERENCES page_sections (id) ON DELETE CASCADE, + columns INTEGER CHECK (columns IN (2, 3, 4)) +) STRICT; + +CREATE TABLE section_blog ( + section_id INTEGER PRIMARY KEY REFERENCES page_sections (id) ON DELETE CASCADE, + internal_title TEXT, + internal_slots INTEGER NOT NULL DEFAULT 3 CHECK (internal_slots BETWEEN 0 AND 12), + external_title TEXT, + external_slots INTEGER NOT NULL DEFAULT 3 CHECK (external_slots BETWEEN 0 AND 12), + external_url TEXT, + external_label TEXT +) STRICT; + +CREATE TABLE section_blog_posts ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + post_id TEXT NOT NULL REFERENCES blog_posts (id) ON DELETE CASCADE +) STRICT; +CREATE INDEX section_blog_posts_section_idx ON section_blog_posts (section_id, sort_order); + +CREATE TABLE section_feeds ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE, + sort_order INTEGER NOT NULL DEFAULT 0, + url TEXT NOT NULL, + label TEXT +) STRICT; +CREATE INDEX section_feeds_section_idx ON section_feeds (section_id, sort_order); + +-- ── featured_cards: owned by a section ─────────────────────────── + +CREATE TABLE featured_cards_new ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + owner_kind TEXT NOT NULL CHECK (owner_kind IN ('page_section', 'organization')), + owner_id TEXT NOT NULL, + sort_order INTEGER NOT NULL DEFAULT 0, + + kind TEXT NOT NULL DEFAULT 'link' + CHECK (kind IN ('record', 'link', 'video')), + + ref_kind TEXT CHECK (ref_kind IN ('event', 'organization', 'person', 'team', 'award')), + ref_id TEXT, + url TEXT, + + eyebrow TEXT, + title TEXT, + blurb TEXT, + image TEXT, + size TEXT CHECK (size IN ('normal', 'wide', 'tall', 'large')), + + CHECK ((ref_kind IS NULL) = (ref_id IS NULL)), + CONSTRAINT "A record card needs a record to point at." + CHECK (kind != 'record' OR ref_kind IS NOT NULL), + CONSTRAINT "A link or video card needs a URL." + CHECK (kind = 'record' OR url IS NOT NULL) +) STRICT; + +-- ── The Community blog into its section ────────────────────────── + +INSERT INTO section_blog (section_id, internal_title, internal_slots, external_title, external_slots, external_url, external_label) +SELECT s.id, c.internal_title, c.internal_slots, c.external_title, c.external_slots, c.external_url, c.external_label + FROM page_sections s, community_page c + WHERE s.page_id = 'community' AND s.preset = 'community_blog' AND c.id = 'community'; + +INSERT INTO section_blog_posts (section_id, sort_order, post_id) +SELECT s.id, p.sort_order, p.post_id + FROM page_sections s JOIN community_page_pinned_posts p ON p.page_id = 'community' + WHERE s.page_id = 'community' AND s.preset = 'community_blog'; + +INSERT INTO section_feeds (section_id, sort_order, url, label) +SELECT s.id, f.sort_order, f.url, f.label + FROM page_sections s JOIN community_page_feeds f ON f.page_id = 'community' + WHERE s.page_id = 'community' AND s.preset = 'community_blog'; + +INSERT INTO featured_cards_new + (owner_kind, owner_id, sort_order, kind, ref_kind, ref_id, url, eyebrow, title, blurb, image, size) +SELECT 'page_section', CAST(s.id AS TEXT), f.sort_order, f.kind, f.ref_kind, f.ref_id, f.url, f.eyebrow, f.title, f.blurb, f.image, f.size + FROM featured_cards f + JOIN page_sections s ON s.page_id = 'community' AND s.preset = 'community_blog' + WHERE f.owner_kind = 'community_page' + AND s.id = (SELECT min(id) FROM page_sections WHERE page_id = 'community' AND preset = 'community_blog'); + +-- ── The front page into the home page's sections ───────────────── + +-- The hero first. +INSERT INTO page_sections (page_id, sort_order, anchor, title, preset) +VALUES ('home', 0, 'hero', 'Welcome', 'hero'); + +INSERT INTO section_hero + (section_id, eyebrow, headline, subhead, primary_label, primary_url, secondary_label, secondary_url, + backdrop, slide_seconds, feature, livestream_url, livestream_title, video_url, video_title, + video_captions, video_still, event_id) +SELECT (SELECT id FROM page_sections WHERE page_id = 'home' AND anchor = 'hero'), + eyebrow, headline, subhead, primary_label, primary_url, secondary_label, secondary_url, + hero_backdrop, slide_seconds, hero_feature, livestream_url, livestream_title, video_url, video_title, + video_captions, video_still, hero_event_id + FROM front_page WHERE id = 'home'; + +INSERT INTO section_slides (section_id, sort_order, media, alt, caption, link_url) +SELECT (SELECT id FROM page_sections WHERE page_id = 'home' AND anchor = 'hero'), sort_order, media, alt, caption, link_url + FROM front_page_slides WHERE page_id = 'home'; + +-- A featured band, hidden, when the front page has cards but no band +-- for them, so they aren't lost. +INSERT INTO front_page_sections (page_id, sort_order, section, is_hidden) +SELECT 'home', 99, 'featured', 1 + WHERE NOT EXISTS (SELECT 1 FROM front_page_sections WHERE page_id = 'home' AND section = 'featured') + AND EXISTS (SELECT 1 FROM featured_cards WHERE owner_kind = 'front_page'); + +-- Each band, in its order: its section type, anchor and heading. +INSERT INTO page_sections (page_id, sort_order, anchor, title, blurb, preset, scope_id, event_type, view, is_hidden) +SELECT 'home', + b.sort_order + 1, + CASE b.section + WHEN 'countdown' THEN 'next-up' + WHEN 'stats' THEN 'numbers' + WHEN 'timeline' THEN 'story' + ELSE b.section + END, + substr(COALESCE(b.title, CASE b.section + WHEN 'countdown' THEN 'Next up' + WHEN 'retreats' THEN 'National Retreats' + WHEN 'calendar' THEN 'What''s on' + WHEN 'stats' THEN 'By the numbers' + WHEN 'timeline' THEN 'Our story so far' + WHEN 'connect' THEN 'Find your way in' + ELSE 'Featured' + END), 1, 60), + b.blurb, + CASE b.section + WHEN 'retreats' THEN 'events' + WHEN 'featured' THEN 'featured_cards' + ELSE b.section + END, + CASE WHEN b.section = 'retreats' THEN 'national' END, + CASE WHEN b.section = 'retreats' THEN 'retreat' END, + CASE WHEN b.section IN ('retreats', 'timeline') THEN 'carousel' END, + b.is_hidden + FROM front_page_sections b + WHERE b.page_id = 'home' + ORDER BY b.sort_order; + +-- The retreats band's link through to the Retreats page, as a button +-- above its carousel. +INSERT INTO content_blocks (owner_kind, owner_id, slot, sort_order, type, text, href) +SELECT 'page_section', CAST(id AS TEXT), 'body', 0, 'button', 'All retreats', '/retreats' + FROM page_sections WHERE page_id = 'home' AND anchor = 'retreats'; + +INSERT INTO section_countdown (section_id, event_id, scope_id, event_type) +SELECT (SELECT id FROM page_sections WHERE page_id = 'home' AND preset = 'countdown'), + countdown_event_id, countdown_scope_id, countdown_event_type + FROM front_page + WHERE id = 'home' AND EXISTS (SELECT 1 FROM page_sections WHERE page_id = 'home' AND preset = 'countdown'); + +INSERT INTO section_stats (section_id, sort_order, label, source, value, suffix, note) +SELECT (SELECT id FROM page_sections WHERE page_id = 'home' AND preset = 'stats'), + sort_order, label, source, value, suffix, note + FROM front_page_stats + WHERE page_id = 'home' AND EXISTS (SELECT 1 FROM page_sections WHERE page_id = 'home' AND preset = 'stats'); + +INSERT INTO section_paths (id, section_id, sort_order, label, icon, blurb) +SELECT id, (SELECT id FROM page_sections WHERE page_id = 'home' AND preset = 'connect'), + sort_order, label, icon, blurb + FROM front_page_paths + WHERE page_id = 'home' AND EXISTS (SELECT 1 FROM page_sections WHERE page_id = 'home' AND preset = 'connect'); + +INSERT INTO section_path_actions (path_id, sort_order, label, description, url) +SELECT a.path_id, a.sort_order, a.label, a.description, a.url + FROM front_page_path_actions a + WHERE a.path_id IN (SELECT id FROM section_paths); + +INSERT INTO section_featured (section_id, columns) +SELECT (SELECT id FROM page_sections WHERE page_id = 'home' AND preset = 'featured_cards'), featured_columns + FROM front_page + WHERE id = 'home' AND EXISTS (SELECT 1 FROM page_sections WHERE page_id = 'home' AND preset = 'featured_cards'); + +INSERT INTO featured_cards_new + (owner_kind, owner_id, sort_order, kind, ref_kind, ref_id, url, eyebrow, title, blurb, image, size) +SELECT 'page_section', (SELECT CAST(id AS TEXT) FROM page_sections WHERE page_id = 'home' AND preset = 'featured_cards'), + sort_order, kind, ref_kind, ref_id, url, eyebrow, title, blurb, image, size + FROM featured_cards + WHERE owner_kind = 'front_page' + AND EXISTS (SELECT 1 FROM page_sections WHERE page_id = 'home' AND preset = 'featured_cards'); + +-- An organization's own cards (072) come along as they are. +INSERT INTO featured_cards_new + (id, owner_kind, owner_id, sort_order, kind, ref_kind, ref_id, url, eyebrow, title, blurb, image, size) +SELECT id, owner_kind, owner_id, sort_order, kind, ref_kind, ref_id, url, eyebrow, title, blurb, image, size + FROM featured_cards WHERE owner_kind = 'organization'; + +-- Drafts of what's gone: the Front page editor is the home page's now. +DELETE FROM drafts WHERE entity = 'front_page'; + +-- ── What's gone ────────────────────────────────────────────────── + +-- The cleanup triggers on events, people, teams, awards and +-- organizations name featured_cards; legacy mode leaves them alone +-- through the rename. +PRAGMA legacy_alter_table = ON; +DROP TABLE featured_cards; +ALTER TABLE featured_cards_new RENAME TO featured_cards; +PRAGMA legacy_alter_table = OFF; +CREATE INDEX featured_cards_owner_idx ON featured_cards (owner_kind, owner_id, sort_order); + +DROP TABLE front_page_path_actions; +DROP TABLE front_page_paths; +DROP TABLE front_page_stats; +DROP TABLE front_page_slides; +DROP TABLE front_page_sections; +DROP TABLE front_page; +DROP TABLE community_page_pinned_posts; +DROP TABLE community_page_feeds; +DROP TABLE community_page; + +-- ── Triggers, last ─────────────────────────────────────────────── + +-- A section's blocks and its featured cards go with it. +CREATE TRIGGER page_sections_cleanup +AFTER DELETE ON page_sections +BEGIN + DELETE FROM content_blocks WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT); + DELETE FROM featured_cards WHERE owner_kind = 'page_section' AND owner_id = CAST(old.id AS TEXT); +END; + +CREATE TRIGGER featured_cards_owner_exists +BEFORE INSERT ON featured_cards +BEGIN + SELECT CASE + WHEN new.owner_kind = 'organization' + AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id) + THEN RAISE(ABORT, 'featured_cards: no such organization') + WHEN new.owner_kind = 'page_section' + AND NOT EXISTS (SELECT 1 FROM page_sections WHERE CAST(id AS TEXT) = new.owner_id) + THEN RAISE(ABORT, 'featured_cards: no such page section') + END; +END; + +CREATE TRIGGER featured_cards_ref_exists +BEFORE INSERT ON featured_cards +BEGIN + SELECT CASE + WHEN new.ref_kind = 'event' + AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such event') + WHEN new.ref_kind = 'organization' + AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such organization') + WHEN new.ref_kind = 'person' + AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such person') + WHEN new.ref_kind = 'team' + AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such team') + WHEN new.ref_kind = 'award' + AND NOT EXISTS (SELECT 1 FROM awards WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such award') + END; +END; + +CREATE TRIGGER featured_cards_ref_exists_update +BEFORE UPDATE OF ref_kind, ref_id ON featured_cards +BEGIN + SELECT CASE + WHEN new.ref_kind = 'event' + AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such event') + WHEN new.ref_kind = 'organization' + AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such organization') + WHEN new.ref_kind = 'person' + AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such person') + WHEN new.ref_kind = 'team' + AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such team') + WHEN new.ref_kind = 'award' + AND NOT EXISTS (SELECT 1 FROM awards WHERE id = new.ref_id) + THEN RAISE(ABORT, 'featured_cards: no such award') + END; +END; diff --git a/server/src/migrations/084_rotating_words.sql b/server/src/migrations/084_rotating_words.sql new file mode 100644 index 0000000..ee64302 --- /dev/null +++ b/server/src/migrations/084_rotating_words.sql @@ -0,0 +1,37 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 084 ROTATING WORDS +-- +-- A word typed as {Next|Now|Rising} in a title or text cycles +-- through its choices (src/components/RotatingWords.tsx). How it +-- moves: +-- +-- word_motion slide, flip, fade, type or mirror +-- word_direction top or bottom: where a sliding or flipping word +-- comes from +-- word_seconds how long each word shows, 1 to 20 +-- +-- Site settings hold the defaults (null: slide, from the bottom, 3 +-- seconds); a hero and a content block can each set their own, null +-- keeping the site's. +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE site_settings ADD COLUMN word_motion TEXT + CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')); +ALTER TABLE site_settings ADD COLUMN word_direction TEXT + CHECK (word_direction IN ('top', 'bottom')); +ALTER TABLE site_settings ADD COLUMN word_seconds INTEGER + CHECK (word_seconds BETWEEN 1 AND 20); + +ALTER TABLE section_hero ADD COLUMN word_motion TEXT + CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')); +ALTER TABLE section_hero ADD COLUMN word_direction TEXT + CHECK (word_direction IN ('top', 'bottom')); +ALTER TABLE section_hero ADD COLUMN word_seconds INTEGER + CHECK (word_seconds BETWEEN 1 AND 20); + +ALTER TABLE content_blocks ADD COLUMN word_motion TEXT + CHECK (word_motion IN ('slide', 'flip', 'fade', 'type', 'mirror')); +ALTER TABLE content_blocks ADD COLUMN word_direction TEXT + CHECK (word_direction IN ('top', 'bottom')); +ALTER TABLE content_blocks ADD COLUMN word_seconds INTEGER + CHECK (word_seconds BETWEEN 1 AND 20); diff --git a/server/src/migrations/085_planning_center.sql b/server/src/migrations/085_planning_center.sql new file mode 100644 index 0000000..a9febe1 --- /dev/null +++ b/server/src/migrations/085_planning_center.sql @@ -0,0 +1,17 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 085 PLANNING CENTER +-- +-- Data → Planning Center brings one Planning Center People list into +-- the site's people, by hand (planningCenter.js, routes/pco.js): +-- +-- people.pco_id the Planning Center person a record is +-- linked to, once an admin confirms the +-- match; one record each +-- site_settings.pco_list_id which list (Site settings → Planning +-- Center), eg. 1234567 +-- ═══════════════════════════════════════════════════════════════ + +ALTER TABLE people ADD COLUMN pco_id TEXT; +CREATE UNIQUE INDEX people_pco_id_idx ON people (pco_id) WHERE pco_id IS NOT NULL; + +ALTER TABLE site_settings ADD COLUMN pco_list_id TEXT; diff --git a/server/src/pageMeta.js b/server/src/pageMeta.js index 464cacc..f6054e4 100644 --- a/server/src/pageMeta.js +++ b/server/src/pageMeta.js @@ -14,16 +14,17 @@ ── Where it comes from ── /site.json (SITE_CONFIG): the site's name, address, default description and image, icons, and each static page's title and - description. Laid over it: Panel → Site settings (the - site_settings table, 035) and Pages → Navigation's page titles - (site_nav_pages, 075), where anything set wins and anything - blank falls back to site.json. siteFor(db) does the merge. The + default description and image, and icons. Laid over it: Panel → + Site settings (the site_settings table, 035), where anything set + wins and anything blank falls back to site.json. siteFor(db) does + the merge. Each page's title and intro are its site_pages row's + (Pages → Page management, 080). The pages read the same merged values (renderPage writes them into the HTML as window.__SITE__, see src/lib/site.ts), so a heading and its search title can't drift. The database: records' names, taglines, first paragraphs and images. A blank site description falls back to the front page's - subhead. + hero's subhead. ── Rules ── published, listed indexed, in the sitemap @@ -47,7 +48,7 @@ import { fileURLToPath } from "node:url"; import { loadBlocks, paragraphs } from "./shape.js"; import { themeCss } from "./theme.js"; import { driveReady } from "./googleService.js"; -import { hiddenFrom, hiddenPaths, navFor } from "./siteNav.js"; +import { allPages, hiddenFrom, navFor, pageAt } from "./siteNav.js"; const here = path.dirname(fileURLToPath(import.meta.url)); @@ -75,24 +76,15 @@ const origin = (site) => (site.url ?? "").replace(/\/$/, ""); /* site.json with the admin's Site settings laid over it: a value set there wins, a blank one falls back. indexing 'on' / 'off' overrides - robots.index for this database only. Page overrides (Pages → - Navigation) apply only to pages site.json knows. */ + robots.index for this database only. pages: every page's title + and intro, by path (site_pages). */ export function siteFor(db) { const base = loadSite(); const row = db.prepare(`SELECT * FROM site_settings WHERE id = 'site'`).get() ?? {}; - const pages = { ...(base.pages ?? {}) }; - const overrides = db - .prepare(`SELECT path, title, description FROM site_nav_pages WHERE nav_id = 'site'`) - .all(); - for (const page of overrides) { - const known = pages[page.path]; - if (!known) continue; - pages[page.path] = { - title: page.title || known.title, - description: page.description || known.description, - }; - } + const pages = Object.fromEntries( + allPages(db).map((page) => [page.path, { title: page.title, description: page.description ?? "" }]), + ); return { ...base, @@ -108,7 +100,8 @@ export function siteFor(db) { ...base.robots, index: row.indexing ? row.indexing === "on" : base.robots?.index !== false, }, - privacyEmail: row.privacy_email || base.privacyEmail || "", + // Rotating words' defaults (084): blank is the app's own. + words: { motion: row.word_motion ?? null, direction: row.word_direction ?? null, seconds: row.word_seconds ?? null }, // The admin's colors (theme.js): only #rrggbb values and fixed // text, so safe inside