v1.14.0-profiles: profile accounts, drafts, page management, Planning Center #32

Merged
ngu-git-admin merged 15 commits from page-management into main 2026-10-28 07:00:10 +00:00
28 changed files with 878 additions and 70 deletions
Showing only changes of commit 31afa889d6 - Show all commits

28
TODO.md
View file

@ -60,16 +60,13 @@
- [ ] Which page showed the wrong picture, and where (Discord, iMessage, Facebook)? Answer: - [ ] Which page showed the wrong picture, and where (Discord, iMessage, Facebook)? Answer:
- [ ] Is it production (not deployed yet?) or the SVG skip? Should an SVG logo get a PNG copy made at upload for previews? Answer: - [ ] Is it production (not deployed yet?) or the SVG skip? Should an SVG logo get a PNG copy made at upload for previews? Answer:
- [ ] Should event pages prefer the card background ("banner") over the event photo? Answer: - [ ] Should event pages prefer the card background ("banner") over the event photo? Answer:
- [ ] **Blog page tabs**: tabs within a blog post, at the top.
- [ ] each tab would switch the active display of content and table of contents, there could be some title/intro content above the tabs.
- [ ] **Gamification synced to Discord**: points, badges or levels on the site, synced to Discord. Linking a profile to Discord is done (Part 2, Accounts); the bot, points and badges are next. - [ ] **Gamification synced to Discord**: points, badges or levels on the site, synced to Discord. Linking a profile to Discord is done (Part 2, Accounts); the bot, points and badges are next.
- [ ] What earns points: going to events, writing for the blog, volunteering, Discord activity? Answer: all of the above, we could create badges on profiles. - [ ] What earns points: going to events, writing for the blog, volunteering, Discord activity? Answer: all of the above, we could create badges on profiles.
- [ ] Where are they shown: on full profiles, a leaderboard, only in Discord? Answer: shown on profiles when logged in, no leaderboard for now, and when using a command in discord. this content would not show on the public bio section of a user when viewing from a people tile. - [ ] Where are they shown: on full profiles, a leaderboard, only in Discord? Answer: shown on profiles when logged in, no leaderboard for now, and when using a command in discord. this content would not show on the public bio section of a user when viewing from a people tile.
- [ ] Which way does it sync: site → Discord roles, Discord → site, or both? Is there a Discord bot already (or only the reports webhook)? Answer: would like a bot built, for if things in discord update or affect gamification shown on the website. most things will be assigned to users by moderators. - [ ] Which way does it sync: site → Discord roles, Discord → site, or both? Is there a Discord bot already (or only the reports webhook)? Answer: would like a bot built, for if things in discord update or affect gamification shown on the website. most things will be assigned to users by moderators.
- [ ] How do we match a person to their Discord account (they link it themselves)? Answer: they can link it, admins can overwrite and update/set - [ ] How do we match a person to their Discord account (they link it themselves)? Answer: they can link it, admins can overwrite and update/set
- [ ] **Site version names**: each update gets a name, "The ___ Update", Minecraft style. - [ ] **Site version names**: in the footers now (Part 2, Page features); still to show them in the changelog once it's built (Pages: Website changelog).
- [ ] Shown where: the footer next to the version, the changelog, both? Answer: both
- [ ] Does the tag suffix become the name (v1.13.2-region-cards → "The Region Cards Update"), or a name of its own? Answer: yeah the tag.
## Accessibility Features ## Accessibility Features
- [ ] Check the mobile fixes on a real phone (or the browser's phone view at 320, 375 and 430px), light and dark: every page, the menu, the hero, the retreat carousel, people tiles and their details, the community map, schedule blocks, the banner. - [ ] Check the mobile fixes on a real phone (or the browser's phone view at 320, 375 and 430px), light and dark: every page, the menu, the hero, the retreat carousel, people tiles and their details, the community map, schedule blocks, the banner.
@ -79,9 +76,6 @@
- [ ] A Listen button in the Accessibility panel, or on each page by its title? Answer: - [ ] A Listen button in the Accessibility panel, or on each page by its title? Answer:
## Mobile ## Mobile
- [ ] **Featured event label on the front page**: where it sits doesn't make sense, at least on mobile.
- [ ] Where should it go: above the card, on the card's photo, or dropped on mobile? Answer: droppd on mobile
- [ ] Same change on desktop? move above the section on the right displaying the featured event.
## Page Editing ## Page Editing
@ -94,17 +88,12 @@
- [ ] Which fields: name, photo, email, phone, birthday? Which win when both sides differ? Answer: - [ ] 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 - [ ] 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 - [ ] Is there a Planning Center API app (personal access token) we can use, and which account owns it? Answer: use the API
- [ ] **New Thought young adult directory**: things like authors and TikTok and Instagram creators. - Skipped on 2026-10-16 until the fields (and which side wins) are decided.
- [ ] section in the community page, Directories. tabs with different people lists, we have musicians already. - [ ] **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.
- [ ] Do they agree to be listed, or is it a public list of public accounts? Answer: we add them to the list as admins
## Navigation ## Navigation
## Tools ## Tools
- [ ] **File conversion**: a simple tool, eg. WebP to JPG.
- [ ] Which conversions: images only (WebP, JPG, PNG, HEIC?), or also documents (Word to PDF) and video? Answer: image converson
- [ ] In the browser (nothing uploaded, images only), or on the server (more formats)? Answer: images only.
- [ ] Also a "Download as JPG" on files in the Media library? [ ] yes
## Content ## Content
- [ ] **Newsletter: featured partners and new partnerships**, maybe as a blog post. - [ ] **Newsletter: featured partners and new partnerships**, maybe as a blog post.
@ -133,6 +122,15 @@
# Part 2: Done # Part 2: Done
## Page features (branch `page-features`, on top of `nav-access`, 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] **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).
## Page Editing (branch `nav-access`, no PR yet; migration 077) ## 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. - [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.
- [x] **Preview on the real page**: Preview saves the draft and opens the record's page in a new tab with it applied, under an amber "Previewing a draft" bar, for signed-in admin accounts only; anyone else sees the live page. The server answers that tab's reads from a second connection holding the draft in a transaction it rolls back, so no page needed code of its own. - [x] **Preview on the real page**: Preview saves the draft and opens the record's page in a new tab with it applied, under an amber "Previewing a draft" bar, for signed-in admin accounts only; anyone else sees the live page. The server answers that tab's reads from a second connection holding the draft in a transaction it rolls back, so no page needed code of its own.

View file

@ -152,6 +152,8 @@ export const blocksChild = (ownerKind) => ({
"table", "table",
"cards", "cards",
"people", "people",
// A blog post's tab (079): its text is the tab's title.
"tab",
], ],
{ required: true }, { required: true },
), ),

View file

@ -36,12 +36,19 @@ const sectionsChild = {
text("scope_id"), text("scope_id"),
enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]), enumeration("event_type", ["retreat", "class", "workshop", "meeting", "other"]),
enumeration("view", ["carousel", "grid", "map"]), enumeration("view", ["carousel", "grid", "map"]),
text("tag_id"),
// Organization cards (067): the kinds listed by themselves. // Organization cards (067): the kinds listed by themselves.
enumeration("org_kinds", ["partner", "ministry", "partner,ministry"]), enumeration("org_kinds", ["partner", "ministry", "partner,ministry"]),
], ],
children: [ children: [
blocksChild("page_section"), blocksChild("page_section"),
{
// A People directory's tags (078), a tab each, in order.
key: "tags",
table: "page_section_tags",
owner: { column: "section_id" },
order: "sort_order",
columns: [text("tag_id", { required: true })],
},
{ {
// Organization cards (067): a hand-picked list, shown instead. // Organization cards (067): a hand-picked list, shown instead.
key: "orgs", key: "orgs",

View file

@ -0,0 +1,66 @@
-- ═══════════════════════════════════════════════════════════════
-- 078 DIRECTORY TABS
--
-- A People directory section (page_sections.preset
-- 'people_directory') shows several People tags, a tab each, in
-- the order picked: Community's Directories, eg. Musicians, Authors,
-- Creators. page_section_tags holds them; each section's one tag_id
-- becomes its first, and the column goes (page_sections is rebuilt,
-- since a column with a REFERENCES can't be dropped in place).
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE page_section_tags (
id INTEGER PRIMARY KEY AUTOINCREMENT,
section_id INTEGER NOT NULL REFERENCES page_sections (id) ON DELETE CASCADE,
sort_order INTEGER NOT NULL DEFAULT 0,
tag_id TEXT NOT NULL REFERENCES person_tag_types (id) ON DELETE CASCADE
) STRICT;
CREATE INDEX page_section_tags_section_idx ON page_section_tags (section_id, sort_order);
INSERT INTO page_section_tags (section_id, sort_order, tag_id)
SELECT id, 0, tag_id FROM page_sections WHERE tag_id IS NOT NULL;
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')),
-- 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;

View file

@ -0,0 +1,76 @@
-- ═══════════════════════════════════════════════════════════════
-- 079 TAB BLOCKS
--
-- A blog post can be split into tabs: a 'tab' block (its text the
-- tab's title) starts a tab holding the blocks after it, up to the
-- next one; the blocks before the first are the intro above the
-- tabs. The post's contents follow the open tab (BlogPost.tsx).
-- content_blocks.type's CHECK can't change in place, so the table is
-- rebuilt, then its index and owner trigger are made again.
-- ═══════════════════════════════════════════════════════════════
CREATE TABLE content_blocks_new (
id INTEGER PRIMARY KEY AUTOINCREMENT,
owner_kind TEXT NOT NULL
CHECK (owner_kind IN ('organization', 'event', 'person', 'team', 'blog_post', 'page_section',
'newsletter')),
owner_id TEXT NOT NULL,
slot TEXT NOT NULL DEFAULT 'body' CHECK (slot IN ('card', 'body', 'both')),
sort_order INTEGER NOT NULL DEFAULT 0,
type TEXT NOT NULL
CHECK (type IN ('heading', 'subheading', 'paragraph',
'list', 'links', 'quote', 'image', 'divider',
'video', 'button', 'callout', 'schedule', 'table', 'cards',
'people', 'tab')),
text TEXT,
media TEXT,
href TEXT,
alt TEXT,
cite TEXT,
team_id TEXT REFERENCES teams (id) ON DELETE SET NULL,
captions TEXT
) STRICT;
INSERT INTO content_blocks_new
(id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions)
SELECT id, owner_kind, owner_id, slot, sort_order, type, text, media, href, alt, cite, team_id, captions
FROM content_blocks;
-- The block items and the owners' cleanup triggers name
-- content_blocks; legacy mode leaves them alone through the rename.
PRAGMA legacy_alter_table = ON;
DROP TABLE content_blocks;
ALTER TABLE content_blocks_new RENAME TO content_blocks;
PRAGMA legacy_alter_table = OFF;
CREATE INDEX content_blocks_owner_idx
ON content_blocks (owner_kind, owner_id, slot, sort_order);
CREATE TRIGGER content_blocks_owner_exists
BEFORE INSERT ON content_blocks
BEGIN
SELECT CASE
WHEN new.owner_kind = 'event'
AND NOT EXISTS (SELECT 1 FROM events WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such event')
WHEN new.owner_kind = 'organization'
AND NOT EXISTS (SELECT 1 FROM organizations WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such organization')
WHEN new.owner_kind = 'person'
AND NOT EXISTS (SELECT 1 FROM people WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such person')
WHEN new.owner_kind = 'team'
AND NOT EXISTS (SELECT 1 FROM teams WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such team')
WHEN new.owner_kind = 'blog_post'
AND NOT EXISTS (SELECT 1 FROM blog_posts WHERE id = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such blog post')
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, 'content_blocks: no such page section')
WHEN new.owner_kind = 'newsletter'
AND NOT EXISTS (SELECT 1 FROM newsletters WHERE CAST(id AS TEXT) = new.owner_id)
THEN RAISE(ABORT, 'content_blocks: no such newsletter')
END;
END;

View file

@ -49,7 +49,7 @@ sitePages.get("/site-pages/:id", (c) => {
const rows = db const rows = db
.prepare( .prepare(
`SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, tag_id, org_kinds `SELECT id, anchor, title, blurb, accent, preset, scope_id, event_type, view, org_kinds
FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`, FROM page_sections WHERE page_id = ? ORDER BY sort_order, id`,
) )
.all(id); .all(id);
@ -64,6 +64,17 @@ sitePages.get("/site-pages/:id", (c) => {
.all(id)) { .all(id)) {
picked.set(section_id, [...(picked.get(section_id) ?? []), org_id]); picked.set(section_id, [...(picked.get(section_id) ?? []), org_id]);
} }
// A People directory's tags (078), in order.
const tags = new Map();
for (const { section_id, tag_id } of db
.prepare(
`SELECT t.section_id, t.tag_id FROM page_section_tags t
JOIN page_sections s ON s.id = t.section_id
WHERE s.page_id = ? ORDER BY t.section_id, t.sort_order, t.id`,
)
.all(id)) {
tags.set(section_id, [...(tags.get(section_id) ?? []), tag_id]);
}
// A hidden page is only for those signed in: never kept. // A hidden page is only for those signed in: never kept.
const send = hidden ? (body) => c.json(body, 200, NO_STORE) : (body) => json(c, body); const send = hidden ? (body) => c.json(body, 200, NO_STORE) : (body) => json(c, body);
@ -74,6 +85,7 @@ sitePages.get("/site-pages/:id", (c) => {
...section, ...section,
blocks: blocks.get(String(sectionId)) ?? [], blocks: blocks.get(String(sectionId)) ?? [],
org_ids: picked.get(sectionId) ?? [], org_ids: picked.get(sectionId) ?? [],
tag_ids: tags.get(sectionId) ?? [],
})), })),
}, },
}); });

View file

@ -87,6 +87,7 @@ const AdminClips = lazyPage(() => import("./pages/admin/AdminClips.tsx"))
const AdminVideoFrames = lazyPage(() => import("./pages/admin/AdminVideoFrames.tsx")) const AdminVideoFrames = lazyPage(() => import("./pages/admin/AdminVideoFrames.tsx"))
const AdminNewsletter = lazyPage(() => import("./pages/admin/AdminNewsletter.tsx")) const AdminNewsletter = lazyPage(() => import("./pages/admin/AdminNewsletter.tsx"))
const AdminProfiles = lazyPage(() => import("./pages/admin/AdminProfiles.tsx")) const AdminProfiles = lazyPage(() => import("./pages/admin/AdminProfiles.tsx"))
const AdminConvert = lazyPage(() => import("./pages/admin/AdminConvert.tsx"))
const EntityList = lazyPage(() => import("./pages/admin/EntityList.tsx")) const EntityList = lazyPage(() => import("./pages/admin/EntityList.tsx"))
const EntityEdit = lazyPage(() => import("./pages/admin/EntityEdit.tsx")) const EntityEdit = lazyPage(() => import("./pages/admin/EntityEdit.tsx"))
@ -155,6 +156,7 @@ export default function App() {
<Route path="requests" element={<AdminFeedback kind="content" />} /> <Route path="requests" element={<AdminFeedback kind="content" />} />
<Route path="media" element={<AdminMedia />} /> <Route path="media" element={<AdminMedia />} />
<Route path="newsletter" element={<AdminNewsletter />} /> <Route path="newsletter" element={<AdminNewsletter />} />
<Route path="convert" element={<AdminConvert />} />
<Route element={<RequireRole role="editor" />}> <Route element={<RequireRole role="editor" />}>
<Route path="thumbnails" element={<AdminVideoFrames />} /> <Route path="thumbnails" element={<AdminVideoFrames />} />
</Route> </Route>

View file

@ -63,10 +63,13 @@ export default function ContentBlocks({
accent = BRAND, accent = BRAND,
className = '', className = '',
presentAt, presentAt,
anchorPrefix = '',
}: { }: {
blocks?: ContentBlock[] | null blocks?: ContentBlock[] | null
accent?: string accent?: string
className?: string className?: string
/** Put before each heading's id: a blog post's tab (contents.ts, splitTabs). */
anchorPrefix?: string
/** An event page's presentation route: each schedule gets a Present /** An event page's presentation route: each schedule gets a Present
* button to it, `?block=<n>` naming which schedule (from 0). */ * button to it, `?block=<n>` naming which schedule (from 0). */
presentAt?: string presentAt?: string
@ -74,7 +77,7 @@ export default function ContentBlocks({
if (!blocks?.length) return null if (!blocks?.length) return null
// Headings get ids so a post's contents (PostContents) and a shared // Headings get ids so a post's contents (PostContents) and a shared
// link (#getting-there) can point at them. // link (#getting-there) can point at them.
const { idAt } = headingAnchors(blocks) const { idAt } = headingAnchors(blocks, anchorPrefix)
// The heading level a block's own headings take: under the last // The heading level a block's own headings take: under the last
// heading (h3) or subheading (h4) before it, else the section's h2. // heading (h3) or subheading (h4) before it, else the section's h2.
let under = 2 let under = 2
@ -182,6 +185,9 @@ function Block({
const reading = useReadingMode() const reading = useReadingMode()
switch (block.type) { switch (block.type) {
// A blog post's tab marker (BlogPost.tsx splits the post at
// them); anywhere else, it reads as a heading.
case 'tab':
case 'heading': case 'heading':
return ( return (
<h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent) }}> <h3 id={anchor} className="text-2xl font-bold" style={{ color: accentText(accent) }}>

View file

@ -2,6 +2,7 @@ import { Link } from "react-router-dom";
import { useNavSections } from "../lib/navSections.ts"; import { useNavSections } from "../lib/navSections.ts";
import { useSiteNav } from "../lib/useSiteNav.ts"; import { useSiteNav } from "../lib/useSiteNav.ts";
import { useAuth } from "../lib/auth.tsx"; import { useAuth } from "../lib/auth.tsx";
import { VERSION_NAME, VERSION_NUMBER } from "../lib/version.ts";
import SiteLink from "./SiteLink.tsx"; import SiteLink from "./SiteLink.tsx";
import siteLogo from "../assets/logos/NGU_Logo.svg"; import siteLogo from "../assets/logos/NGU_Logo.svg";
import PlatformIcon from "./PlatformIcon.tsx"; import PlatformIcon from "./PlatformIcon.tsx";
@ -146,7 +147,13 @@ export default function Footer() {
</nav> </nav>
<div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4"> <div className="border-t border-white/10 pt-8 flex flex-col md:flex-row items-center justify-between gap-4">
<p className="text-white/65 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p> <div className="text-center md:text-left">
<p className="text-white/65 text-sm">© 2026 Next Generation of Unity. All rights reserved.</p>
<p className="mt-1 text-white/50 text-xs">
{VERSION_NUMBER}
{VERSION_NAME && <> · {VERSION_NAME}</>}
</p>
</div>
<div className="flex flex-wrap justify-center gap-x-6 gap-y-2"> <div className="flex flex-wrap justify-center gap-x-6 gap-y-2">
{nav.legal.map((link) => ( {nav.legal.map((link) => (
<SiteLink key={`${link.label}${link.path}`} link={link} className={footerLinkClass}> <SiteLink key={`${link.label}${link.path}`} link={link} className={footerLinkClass}>

View file

@ -15,7 +15,12 @@
width 0.6s ease-in-out, width 0.6s ease-in-out,
height 0.6s ease-in-out, height 0.6s ease-in-out,
left 0.6s ease-in-out, left 0.6s ease-in-out,
top 0.6s ease-in-out; top 0.6s ease-in-out,
opacity 0.4s ease-in-out;
}
/* The page has scrolled into the footer (PageShell.tsx, leaving). */
.side-nav-circle[data-leaving] {
opacity: 0;
} }
.side-nav-circle[data-family="green"] { .side-nav-circle[data-family="green"] {
background: var(--pal-green-3); background: var(--pal-green-3);

View file

@ -215,7 +215,12 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
// Stuck: the page has scrolled the list up to its place under the // Stuck: the page has scrolled the list up to its place under the
// header. The circle then becomes the corner sun (below). // header. The circle then becomes the corner sun (below).
// Leaving: the last section is going up past the list, so the list
// goes with it into the footer; the sun, far bigger than its sticky
// layer, would hang over the footer, so it fades out.
const [stuck, setStuck] = useState(false); const [stuck, setStuck] = useState(false);
const [leaving, setLeaving] = useState(false);
const listHeight = listBox?.height ?? 0;
useEffect(() => { useEffect(() => {
const column = columnRef.current; const column = columnRef.current;
if (!sideNav || !column) return; if (!sideNav || !column) return;
@ -223,7 +228,9 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
const measure = () => { const measure = () => {
frame = 0; frame = 0;
const header = parseFloat(getComputedStyle(column).getPropertyValue("--header-h")) || 80; const header = parseFloat(getComputedStyle(column).getPropertyValue("--header-h")) || 80;
setStuck(column.getBoundingClientRect().top + listTop <= header + STUCK_TOP + 1); const box = column.getBoundingClientRect();
setStuck(box.top + listTop <= header + STUCK_TOP + 1);
setLeaving(box.bottom <= header + STUCK_TOP + listHeight + CIRCLE_MARGIN);
}; };
const onScroll = () => { const onScroll = () => {
if (!frame) frame = requestAnimationFrame(measure); if (!frame) frame = requestAnimationFrame(measure);
@ -236,7 +243,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
window.removeEventListener("resize", onScroll); window.removeEventListener("resize", onScroll);
if (frame) cancelAnimationFrame(frame); if (frame) cancelAnimationFrame(frame);
}; };
}, [sideNav, listTop]); }, [sideNav, listTop, listHeight]);
// The circle's box, from its layer's top left (which sticks with // The circle's box, from its layer's top left (which sticks with
// the list). At rest: `rest` above. Stuck: a sun in the corner, // the list). At rest: `rest` above. Stuck: a sun in the corner,
@ -314,6 +321,7 @@ export default function PageShell({ title, intro, sections, sideNav = false }: P
<div <div
className="side-nav-circle absolute rounded-full" className="side-nav-circle absolute rounded-full"
data-family={circleFamily(activeAccent)} data-family={circleFamily(activeAccent)}
data-leaving={leaving || undefined}
style={{ style={{
width: circleBox.width, width: circleBox.width,
height: circleBox.height, height: circleBox.height,

View file

@ -0,0 +1,45 @@
import { useId, useState } from 'react'
import { OUTPUT_FORMATS, convertImage, renamed, saveBlob, type OutputType } from '../../lib/convertImage.ts'
/* A Media library image saved as JPG, PNG or WebP, converted in the
browser (src/lib/convertImage.ts). */
export default function DownloadAs({ url, name }: { url: string; name: string }) {
const id = useId()
const [state, setState] = useState<'idle' | 'busy' | string>('idle')
async function download(type: OutputType) {
setState('busy')
try {
const response = await fetch(url)
if (!response.ok) throw new Error(`Couldn't fetch the picture (HTTP ${response.status}).`)
saveBlob(await convertImage(await response.blob(), type), renamed(name, type))
setState('idle')
} catch (err) {
setState(err instanceof Error ? err.message : "Couldn't convert it.")
}
}
return (
<span className="inline-flex flex-wrap items-center gap-1">
<label htmlFor={id} className="sr-only">
Download {name} as
</label>
<select
id={id}
value=""
disabled={state === 'busy'}
onChange={(e) => e.target.value && download(e.target.value as OutputType)}
className="border border-muted/25 bg-surface px-1 py-0.5 text-xs text-link"
>
<option value="">{state === 'busy' ? 'Converting…' : 'Download as…'}</option>
{OUTPUT_FORMATS.map((format) => (
<option key={format.type} value={format.type}>
{format.label}
</option>
))}
</select>
{state !== 'idle' && state !== 'busy' && <span className="text-xs text-danger">{state}</span>}
</span>
)
}

View file

@ -1,17 +1,42 @@
import { mediaUrl } from "../media.ts"; import { mediaUrl } from "../media.ts";
import { PUBLISHED_FIELD, LISTED_FIELD, blocksChild } from "./shared.ts"; import { PUBLISHED_FIELD, LISTED_FIELD, BLOCK_TYPES, TEXT_TYPES, blocksChild } from "./shared.ts";
/* ── Blog (031_blog.sql) ───────────────────────────────────────── /* ── Blog (031_blog.sql) ─────────────────────────────────────────
Posts at /blog/:id. The Community page's blog section is edited Posts at /blog/:id. The Community page's blog section is edited
with that page (sitePages.ts). */ with that page (sitePages.ts). */
/* A post's body is the content blocks without the card/body choice: /* A post's body is the content blocks without the card/body choice:
a post only has a body. */ a post only has a body. Posts also take Tab blocks (079), which
split the post into tabs (BlogPost.tsx, splitTabs). */
const TAB_TYPE = [
"tab",
"Tab",
"Starts a tab, titled by its text, holding the blocks after it up to the next Tab. Blocks before the first Tab are the intro above the tabs. The contents list follows the open tab.",
];
const POST_BLOCK_TYPES = [...BLOCK_TYPES, TAB_TYPE];
const blogBlocksChild = { const blogBlocksChild = {
...blocksChild, ...blocksChild,
label: "Post body", label: "Post body",
note: "The post, top to bottom. The first paragraph doubles as the excerpt when that's left blank.", note: "The post, top to bottom. The first paragraph doubles as the excerpt when that's left blank. Add Tab blocks to split it into tabs.",
fields: blocksChild.fields.filter((field) => field.path !== "slot"), fields: blocksChild.fields
.filter((field) => field.path !== "slot")
.map((field) =>
field.path === "type"
? {
...field,
options: POST_BLOCK_TYPES.map(([value, label]) => [value, label]),
help: (row) => POST_BLOCK_TYPES.find(([value]) => value === row?.type)?.[2],
}
: field.path === "text"
? {
...field,
label: (row) => (row?.type === "tab" ? "Tab title" : (field.label as any)(row)),
when: { path: "type", value: [...TEXT_TYPES, "tab"] },
help: (row) => (row?.type === "tab" ? "eg. Overview" : (field.help as any)(row)),
}
: field,
),
}; };
export const blogPosts = { export const blogPosts = {

View file

@ -102,19 +102,6 @@ const sectionsChild = (presets: string[]) => ({
}, },
] ]
: []), : []),
...(presets.includes("people_directory")
? [
{
path: "tag_id",
label: "Directory: tag",
widget: "select",
optionsFrom: "person_tag_types",
blankLabel: "Default: none (shows nothing)",
help: "Shows the first of its people and links to the full directory",
when: { path: "preset", value: "people_directory" },
},
]
: []),
...(presets.includes("partner_list") ...(presets.includes("partner_list")
? [ ? [
{ {
@ -146,6 +133,16 @@ const sectionsChild = (presets: string[]) => ({
: []), : []),
], ],
children: [ children: [
{
key: "tags",
label: "Directory: tags",
note: "Each People tag is a tab, in this order, eg. Musicians, Authors, Creators: the first of its people, and a link to its full directory. One tag shows without tabs. Tags are made under Data → People tags.",
addLabel: "Add tag",
when: { path: "preset", value: "people_directory" },
title: (row, options) => options?.person_tag_types?.find((t) => t.id === row.tag_id)?.label ?? "New tag",
blank: { tag_id: "" },
fields: [{ path: "tag_id", label: "Tag", widget: "select", optionsFrom: "person_tag_types", required: true }],
},
{ {
key: "orgs", key: "orgs",
label: "Cards: organizations", label: "Cards: organizations",

View file

@ -25,8 +25,9 @@ const slug = (text: string) =>
.slice(0, 60) || 'section' .slice(0, 60) || 'section'
/* One entry per heading or subheading block, in order, and the id /* One entry per heading or subheading block, in order, and the id
for each block index that is one. */ for each block index that is one. prefix keeps a blog post's tabs
export function headingAnchors(blocks?: ContentBlock[] | null): { apart (splitTabs): "Overview" in two tabs is two ids. */
export function headingAnchors(blocks?: ContentBlock[] | null, prefix = ''): {
entries: ContentsEntry[] entries: ContentsEntry[]
idAt: Map<number, string> idAt: Map<number, string>
} { } {
@ -40,9 +41,39 @@ export function headingAnchors(blocks?: ContentBlock[] | null): {
const base = slug(text) const base = slug(text)
const n = (seen.get(base) ?? 0) + 1 const n = (seen.get(base) ?? 0) + 1
seen.set(base, n) seen.set(base, n)
const id = n === 1 ? base : `${base}-${n}` const id = `${prefix}${n === 1 ? base : `${base}-${n}`}`
idAt.set(index, id) idAt.set(index, id)
entries.push({ id, text, level: block.type === 'heading' ? 1 : 2 }) entries.push({ id, text, level: block.type === 'heading' ? 1 : 2 })
}) })
return { entries, idAt } return { entries, idAt }
} }
/* ── A blog post's tabs (079) ──────────────────────────────────
A 'tab' block starts a tab, titled by its text, holding the
blocks after it up to the next; the blocks before the first are
the intro above the tabs. Each tab's heading ids start with its
own, so the same heading in two tabs is two ids; the intro's
keep their plain ids. */
export type PostTab = { id: string; title: string; prefix: string; blocks: ContentBlock[] }
export function splitTabs(blocks?: ContentBlock[] | null): { intro: ContentBlock[]; tabs: PostTab[] } {
const intro: ContentBlock[] = []
const tabs: PostTab[] = []
const seen = new Map<string, number>()
for (const block of blocks ?? []) {
if (block.type === 'tab') {
const title = (block.text ?? '').trim() || `Part ${tabs.length + 1}`
const base = `tab-${slug(title)}`
const n = (seen.get(base) ?? 0) + 1
seen.set(base, n)
const id = n === 1 ? base : `${base}-${n}`
tabs.push({ id, title, prefix: `${id}-`, blocks: [] })
} else if (tabs.length) {
tabs[tabs.length - 1].blocks.push(block)
} else {
intro.push(block)
}
}
return { intro, tabs }
}

72
src/lib/convertImage.ts Normal file
View file

@ -0,0 +1,72 @@
/* ═══════════════════════════════════════════════════════════════
IMAGE CONVERSION, in the browser
Tools → Image converter and the Media library's Download as: a
picture redrawn on a canvas and saved as another format. Nothing
is uploaded. Reads whatever this browser can show (JPEG, PNG,
WebP, GIF's first frame, AVIF, BMP, SVG; HEIC in Safari only).
JPEG has no transparency, so a JPEG's see-through parts are
filled white.
═══════════════════════════════════════════════════════════════ */
export const OUTPUT_FORMATS = [
{ type: 'image/jpeg', label: 'JPG', ext: 'jpg', lossy: true },
{ type: 'image/png', label: 'PNG', ext: 'png', lossy: false },
{ type: 'image/webp', label: 'WebP', ext: 'webp', lossy: true },
] as const
export type OutputType = (typeof OUTPUT_FORMATS)[number]['type']
/* An SVG with no size of its own is drawn this wide. */
const SVG_EDGE = 2048
function loadImage(blob: Blob): Promise<HTMLImageElement> {
const url = URL.createObjectURL(blob)
return new Promise((resolve, reject) => {
const img = new Image()
img.onload = () => resolve(img)
img.onerror = () => reject(new Error("This browser can't read that picture."))
img.src = url
}).finally(() => URL.revokeObjectURL(url)) as Promise<HTMLImageElement>
}
/** The picture as `type`; quality 0 to 1 for JPG and WebP. */
export async function convertImage(blob: Blob, type: OutputType, quality = 0.9): Promise<Blob> {
const img = await loadImage(blob)
const width = img.naturalWidth || SVG_EDGE
const height = img.naturalHeight || SVG_EDGE
const canvas = document.createElement('canvas')
canvas.width = width
canvas.height = height
const context = canvas.getContext('2d')
if (!context) throw new Error("This browser can't draw the picture.")
if (type === 'image/jpeg') {
context.fillStyle = '#ffffff'
context.fillRect(0, 0, width, height)
}
context.drawImage(img, 0, 0, width, height)
const out = await new Promise<Blob | null>((resolve) => canvas.toBlob(resolve, type, quality))
// A browser that can't write the format (old Safari and WebP)
// hands back a PNG, or nothing.
if (!out || out.type !== type) throw new Error(`This browser can't save ${type.split('/')[1].toUpperCase()}.`)
return out
}
/** A file name with the new format's extension. */
export function renamed(name: string, type: OutputType): string {
const ext = OUTPUT_FORMATS.find((f) => f.type === type)?.ext ?? 'img'
const stem = name.replace(/\.[^./]+$/, '') || 'image'
return `${stem}.${ext}`
}
/** Hands the browser a file to save. */
export function saveBlob(blob: Blob, filename: string) {
const url = URL.createObjectURL(blob)
const a = document.createElement('a')
a.href = url
a.download = filename
document.body.appendChild(a)
a.click()
a.remove()
setTimeout(() => URL.revokeObjectURL(url), 1000)
}

View file

@ -38,6 +38,7 @@ export type ContentBlock = {
| 'callout' | 'callout'
| 'schedule' | 'schedule'
| 'table' | 'table'
| 'tab'
| 'cards' | 'cards'
| 'people' | 'people'
text?: string | null text?: string | null

View file

@ -15,8 +15,8 @@ export type SitePageSection = {
scope_id?: string | null scope_id?: string | null
event_type?: string | null event_type?: string | null
view?: string | null view?: string | null
/** A people_directory preset's tag (Data → People tags). */ /** A people_directory preset's tags (Data → People tags), a tab each, in order. */
tag_id?: string | null tag_ids: string[]
/** Organization cards: the kinds listed ('partner', 'ministry' or both, comma separated). */ /** Organization cards: the kinds listed ('partner', 'ministry' or both, comma separated). */
org_kinds?: string | null org_kinds?: string | null
/** Organization cards: a hand-picked list, in order, shown instead. */ /** Organization cards: a hand-picked list, in order, shown instead. */

View file

@ -2,9 +2,27 @@
SITE VERSION: src/lib/version.ts SITE VERSION: src/lib/version.ts
One string, bumped by hand when the working directory name One string, bumped by hand when the working directory name
changes. The admin footer is the only thing reading it today; changes. Read by the admin's footer and home, and the site's
keep it here rather than in a component so the panel, an about footer.
box or a build banner can read the same value later.
Each version has a name, Minecraft style: the tag's words after
the number, "v1.13.2-region-cards" → "The Region Cards Update".
A version with no words after its number has no name.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
export const SITE_VERSION = "NGU-Web.v1.13.2-region-cards"; export const SITE_VERSION = "NGU-Web.v1.13.2-region-cards";
/** The number, eg. v1.13.2. */
export const VERSION_NUMBER: string = SITE_VERSION.match(/v\d+(?:\.\d+)*/)?.[0] ?? SITE_VERSION
/** The version's name from its tag, eg. The Region Cards Update, or null. */
export const VERSION_NAME: string | null = (() => {
const words = SITE_VERSION.match(/v\d+(?:\.\d+)*-(.+)$/)?.[1]
if (!words) return null
const title = words
.split('-')
.filter(Boolean)
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ')
return `The ${title} Update`
})()

View file

@ -8,9 +8,16 @@
There's no /blog index on purpose: the Community page's blog There's no /blog index on purpose: the Community page's blog
section is where posts are listed, so "back" goes there. section is where posts are listed, so "back" goes there.
Tab blocks (079) split the body into tabs (contents.ts,
splitTabs): the blocks before the first are an intro above them,
and the contents list follows the open tab. A link to a heading
in another tab (#tab-…) opens that tab. Printed (Download PDF) or
in reading mode, every tab shows, each under its title.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { Link, useParams } from "react-router-dom" import { useEffect, useId, useState, type KeyboardEvent } from "react"
import { Link, useLocation, useParams } from "react-router-dom"
import PageShell, { type ShellSection } from "../components/PageShell.tsx" import PageShell, { type ShellSection } from "../components/PageShell.tsx"
import PageState from "../components/PageState.tsx" import PageState from "../components/PageState.tsx"
@ -18,9 +25,11 @@ import ContentBlocks from "../components/ContentBlocks.tsx"
import PeopleTiles from "../components/PeopleTiles.tsx" import PeopleTiles from "../components/PeopleTiles.tsx"
import { mediaUrl } from "../lib/media.ts" import { mediaUrl } from "../lib/media.ts"
import { postDate, useBlogPost } from "../lib/useBlog.ts" import { postDate, useBlogPost } from "../lib/useBlog.ts"
import { accentText, BRAND } from "../lib/color.ts" import { accentText, BRAND, readableOn, withAlpha } from "../lib/color.ts"
import { useReadingMode } from "../lib/readingMode.ts"
import { jumpTo } from "../lib/focus.ts"
import PostContents from "../components/PostContents.tsx" import PostContents from "../components/PostContents.tsx"
import { headingAnchors } from "../lib/contents.ts" import { headingAnchors, splitTabs, type PostTab } from "../lib/contents.ts"
import QrCode from "../components/QrCode.tsx" import QrCode from "../components/QrCode.tsx"
import RequestLink from "../components/RequestLink.tsx" import RequestLink from "../components/RequestLink.tsx"
import { siteUrl } from "../lib/site.ts" import { siteUrl } from "../lib/site.ts"
@ -34,6 +43,22 @@ const BACK = { to: "/community#blog", label: "Community Blog" }
export default function BlogPost() { export default function BlogPost() {
const { id } = useParams() const { id } = useParams()
const { data: post, loading, error, notFound, reload } = useBlogPost(id) const { data: post, loading, error, notFound, reload } = useBlogPost(id)
const [tabIndex, setTabIndex] = useState(0)
const reading = useReadingMode()
const { hash } = useLocation()
// A link into another tab (#tab-…) opens it, then goes to the heading.
useEffect(() => {
if (!post || !hash.startsWith("#tab-")) return
const target = decodeURIComponent(hash.slice(1))
const found = splitTabs(post.blocks).tabs
const index = found.findIndex((tab) => target === tab.id || target.startsWith(tab.prefix))
if (index < 0) return
setTabIndex(index)
// The tab's own id is its printed title, hidden on screen: opening
// it is enough. A heading inside it is scrolled to once it shows.
if (target !== found[index].id) requestAnimationFrame(() => jumpTo(target))
}, [post, hash])
if (!post) { if (!post) {
return ( return (
@ -49,8 +74,16 @@ export default function BlogPost() {
) )
} }
// Two headings or more make a list worth showing. const { intro, tabs } = splitTabs(post.blocks)
const contents = post.show_contents ? headingAnchors(post.blocks).entries : [] const current = Math.min(tabIndex, Math.max(tabs.length - 1, 0))
// Two headings or more make a list worth showing: the intro's and
// the open tab's.
const contents = post.show_contents
? tabs.length
? [...headingAnchors(intro).entries, ...headingAnchors(tabs[current].blocks, tabs[current].prefix).entries]
: headingAnchors(post.blocks).entries
: []
const withContents = contents.length >= 2 const withContents = contents.length >= 2
const postUrl = siteUrl(`/blog/${post.id}`) const postUrl = siteUrl(`/blog/${post.id}`)
@ -146,7 +179,14 @@ export default function BlogPost() {
/> />
)} )}
<ContentBlocks blocks={post.blocks} accent={BRAND} /> {tabs.length ? (
<>
<ContentBlocks blocks={intro} accent={BRAND} />
<PostTabs tabs={tabs} current={current} onSelect={setTabIndex} all={reading} />
</>
) : (
<ContentBlocks blocks={post.blocks} accent={BRAND} />
)}
<div className="flex flex-wrap items-center gap-3 border-t border-brand/15 pt-6 text-sm text-muted print:hidden"> <div className="flex flex-wrap items-center gap-3 border-t border-brand/15 pt-6 text-sm text-muted print:hidden">
Have a story to share? Have a story to share?
@ -190,3 +230,86 @@ export default function BlogPost() {
/> />
) )
} }
/* The post's tabs: a row of buttons, then the open tab's blocks. The
others stay in the page, hidden, so print shows them all; `all`
(reading mode) shows every tab, each under its title. */
function PostTabs({
tabs,
current,
onSelect,
all,
}: {
tabs: PostTab[]
current: number
onSelect: (index: number) => void
all: boolean
}) {
const baseId = useId()
// Arrows move one tab and wrap; Home and End jump to the ends.
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const last = tabs.length - 1
const next =
e.key === "ArrowRight" ? (current + 1) % tabs.length
: e.key === "ArrowLeft" ? (current + last) % tabs.length
: e.key === "Home" ? 0
: e.key === "End" ? last
: null
if (next === null) return
e.preventDefault()
onSelect(next)
document.getElementById(`${baseId}-tab-${next}`)?.focus()
}
return (
<div className="space-y-6">
{!all && (
<div role="tablist" aria-label="Parts of this post" className="flex flex-wrap gap-2 print:hidden">
{tabs.map((tab, index) => {
const selected = index === current
return (
<button
key={tab.id}
id={`${baseId}-tab-${index}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={`${baseId}-panel-${index}`}
tabIndex={selected ? 0 : -1}
onClick={() => onSelect(index)}
onKeyDown={onKey}
className="btn border px-5 py-2 text-sm transition-colors"
style={
selected
? { background: BRAND, borderColor: BRAND, color: readableOn(BRAND) }
: { borderColor: withAlpha(BRAND, 33), color: accentText(BRAND) }
}
>
{tab.title}
</button>
)
})}
</div>
)}
{tabs.map((tab, index) => (
<div
key={tab.id}
id={`${baseId}-panel-${index}`}
role={all ? undefined : "tabpanel"}
aria-labelledby={all ? undefined : `${baseId}-tab-${index}`}
className={all || index === current ? "space-y-6" : "hidden space-y-6 print:block"}
>
<h2
id={tab.id}
className={`text-3xl font-bold ${all ? "" : "hidden print:block"}`}
style={{ color: accentText(BRAND) }}
>
{tab.title}
</h2>
<ContentBlocks blocks={tab.blocks} accent={BRAND} anchorPrefix={tab.prefix} />
</div>
))}
</div>
)
}

View file

@ -31,7 +31,7 @@ import OrgListCards from './sections/OrgList-Card.tsx'
import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx' import EventListCards, { EventCardsToggle } from './sections/EventList-Cards.tsx'
import CommunityBlog from './sections/CommunityBlog.tsx' import CommunityBlog from './sections/CommunityBlog.tsx'
import HistoryTimeline from './sections/history/HistoryTimeline.tsx' import HistoryTimeline from './sections/history/HistoryTimeline.tsx'
import PeopleDirectory, { DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx' import { DirectoryTabs, DIRECTORY_PREVIEW } from './sections/PeopleDirectory.tsx'
/* Year the program starts: decades ending before it get the /* Year the program starts: decades ending before it get the
pre-program look on the timeline. */ pre-program look on the timeline. */
@ -91,8 +91,8 @@ const PRESETS: Record<string, (section: SitePageSection) => Record<string, any>>
}), }),
timeline: () => ({ Component: Timeline }), timeline: () => ({ Component: Timeline }),
people_directory: (section) => ({ people_directory: (section) => ({
Component: PeopleDirectory, Component: DirectoryTabs,
props: { tag: section.tag_id, limit: DIRECTORY_PREVIEW }, props: { tags: section.tag_ids, limit: DIRECTORY_PREVIEW },
}), }),
} }

View file

@ -0,0 +1,196 @@
/* ═══════════════════════════════════════════════════════════════
ADMIN: IMAGE CONVERTER (Tools → Image converter, everyone)
Pictures turned into JPG, PNG or WebP in the browser
(src/lib/convertImage.ts): pick or drop any number, choose the
format (and quality, for JPG and WebP), download each. Nothing is
uploaded or kept. The Media library's Download as does the same
for a picture already there.
═══════════════════════════════════════════════════════════════ */
import { useId, useState } from "react";
import { OUTPUT_FORMATS, convertImage, renamed, saveBlob, type OutputType } from "../../lib/convertImage.ts";
const MUTED = "var(--color-muted)";
const button =
"btn border border-brand px-4 py-2 text-sm text-link transition-colors hover:bg-tint disabled:cursor-default disabled:opacity-50";
const primary =
"btn bg-action px-5 py-2.5 text-white transition-colors hover:bg-action-hover disabled:bg-muted/25";
type Item = { file: File; result?: Blob; error?: string };
const kb = (bytes: number) => (bytes >= 1024 * 1024 ? `${(bytes / 1024 / 1024).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`);
export default function AdminConvert() {
const inputId = useId();
const formatId = useId();
const qualityId = useId();
const [items, setItems] = useState<Item[]>([]);
const [type, setType] = useState<OutputType>("image/jpeg");
const [quality, setQuality] = useState(90);
const [busy, setBusy] = useState(false);
const [over, setOver] = useState(false);
const lossy = OUTPUT_FORMATS.find((f) => f.type === type)?.lossy;
const add = (files: FileList | null) => {
const pictures = [...(files ?? [])].filter((file) => file.type.startsWith("image/") || /\.(heic|heif)$/i.test(file.name));
setItems((current) => [...current, ...pictures.map((file) => ({ file }))]);
};
async function convertAll() {
setBusy(true);
const next: Item[] = [];
for (const item of items) {
try {
next.push({ file: item.file, result: await convertImage(item.file, type, quality / 100) });
} catch (err) {
next.push({ file: item.file, error: err instanceof Error ? err.message : "Couldn't convert it." });
}
}
setItems(next);
setBusy(false);
}
const done = items.filter((item) => item.result);
return (
<div>
<div className="flex flex-wrap items-baseline gap-3">
<h1 className="text-2xl font-bold text-link">Image converter</h1>
<p className="text-sm" style={{ color: MUTED }}>
Turn pictures into JPG, PNG or WebP. Done in your browser: nothing is uploaded.
</p>
</div>
<section className="mt-6 bg-raised p-5 shadow-md">
<label
htmlFor={inputId}
onDragOver={(e) => {
e.preventDefault();
setOver(true);
}}
onDragLeave={() => setOver(false)}
onDrop={(e) => {
e.preventDefault();
setOver(false);
add(e.dataTransfer.files);
}}
className={`block cursor-pointer border-2 p-8 text-center text-sm transition-colors ${
over ? "border-brand bg-tint" : "border-muted/30"
}`}
>
<span className="font-semibold text-link">Choose pictures</span> or drop them here
<span className="mt-1 block text-xs" style={{ color: MUTED }}>
JPEG, PNG, WebP, GIF, AVIF, BMP or SVG (HEIC in Safari only)
</span>
<input
id={inputId}
type="file"
accept="image/*,.heic,.heif"
multiple
className="sr-only"
onChange={(e) => {
add(e.target.files);
e.target.value = "";
}}
/>
</label>
<div className="mt-5 flex flex-wrap items-end gap-4">
<div>
<label htmlFor={formatId} className="block text-sm font-medium text-body">
Save as
</label>
<select
id={formatId}
value={type}
onChange={(e) => {
setType(e.target.value as OutputType);
setItems((current) => current.map(({ file }) => ({ file })));
}}
className="mt-1 border border-muted/25 bg-surface px-3 py-2 text-sm text-body"
>
{OUTPUT_FORMATS.map((format) => (
<option key={format.type} value={format.type}>
{format.label}
</option>
))}
</select>
</div>
{lossy && (
<div>
<label htmlFor={qualityId} className="block text-sm font-medium text-body">
Quality: {quality}
</label>
<input
id={qualityId}
type="range"
min={40}
max={100}
value={quality}
onChange={(e) => {
setQuality(Number(e.target.value));
setItems((current) => current.map(({ file }) => ({ file })));
}}
className="mt-2 w-48 accent-[var(--color-action)]"
/>
</div>
)}
<button type="button" className={primary} disabled={busy || items.length === 0} onClick={convertAll}>
{busy ? "Converting…" : `Convert ${items.length || ""}`.trim()}
</button>
{done.length > 1 && (
<button
type="button"
className={button}
onClick={() => done.forEach((item) => saveBlob(item.result as Blob, renamed(item.file.name, type)))}
>
Download all
</button>
)}
{items.length > 0 && (
<button type="button" className={button} disabled={busy} onClick={() => setItems([])}>
Clear
</button>
)}
</div>
{type === "image/jpeg" && (
<p className="mt-2 text-xs" style={{ color: MUTED }}>
JPG has no transparency: see-through parts turn white.
</p>
)}
</section>
{items.length > 0 && (
<ul className="mt-6 divide-y divide-brand/10 bg-raised shadow-md">
{items.map((item, index) => (
<li key={`${item.file.name}-${index}`} className="flex flex-wrap items-center gap-3 px-4 py-3 text-sm">
<span className="min-w-0 flex-1 truncate text-body" title={item.file.name}>
{item.file.name}
</span>
<span style={{ color: MUTED }}>{kb(item.file.size)}</span>
{item.result ? (
<>
<span className="text-body">→ {kb(item.result.size)}</span>
<button
type="button"
className={button}
onClick={() => saveBlob(item.result as Blob, renamed(item.file.name, type))}
>
Download {renamed(item.file.name, type)}
</button>
</>
) : item.error ? (
<span className="text-danger">{item.error}</span>
) : (
<span style={{ color: MUTED }}>Ready</span>
)}
</li>
))}
</ul>
)}
</div>
);
}

View file

@ -26,7 +26,7 @@ import { ArrowRight, ArrowUpRight } from "@phosphor-icons/react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { useAuth } from "../../lib/auth.tsx"; import { useAuth } from "../../lib/auth.tsx";
import { useWideAdminPage } from "../../lib/adminWidth.tsx"; import { useWideAdminPage } from "../../lib/adminWidth.tsx";
import { SITE_VERSION } from "../../lib/version.ts"; import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts"; import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import { PALETTE } from "../../lib/color.ts"; import { PALETTE } from "../../lib/color.ts";
import { DATA_NAV, FORMS_NAV, PAGES_NAV, PANEL_NAV, TOOLS_NAV, target, visibleItems } from "./adminNav.ts"; import { DATA_NAV, FORMS_NAV, PAGES_NAV, PANEL_NAV, TOOLS_NAV, target, visibleItems } from "./adminNav.ts";
@ -187,7 +187,7 @@ export default function AdminHome() {
</PanelSection> </PanelSection>
<PanelSection title="Site"> <PanelSection title="Site">
<p className="font-mono text-xs text-muted/80">{SITE_VERSION}</p> <p className="font-mono text-xs text-muted/80">{SITE_VERSION}{VERSION_NAME && ` · ${VERSION_NAME}`}</p>
<a <a
href="/" href="/"
target="_blank" target="_blank"

View file

@ -26,7 +26,7 @@ import { Link, NavLink, Outlet, useLocation, useNavigate } from "react-router-do
import { useAuth } from "../../lib/auth.tsx"; import { useAuth } from "../../lib/auth.tsx";
import { AdminTitleContext } from "../../lib/adminTitle.tsx"; import { AdminTitleContext } from "../../lib/adminTitle.tsx";
import { AdminWidthContext, type AdminWidth } from "../../lib/adminWidth.tsx"; import { AdminWidthContext, type AdminWidth } from "../../lib/adminWidth.tsx";
import { SITE_VERSION } from "../../lib/version.ts"; import { SITE_VERSION, VERSION_NAME } from "../../lib/version.ts";
import { ROLE_LABELS, isSuper } from "../../lib/roles.ts"; import { ROLE_LABELS, isSuper } from "../../lib/roles.ts";
import siteLogo from "../../assets/logos/NGU_Logo.svg"; import siteLogo from "../../assets/logos/NGU_Logo.svg";
import ThemeToggle from "../../components/ThemeToggle.tsx"; import ThemeToggle from "../../components/ThemeToggle.tsx";
@ -226,7 +226,7 @@ export default function AdminLayout() {
<img src={siteLogo} alt="NGU" className="h-6 w-auto" /> <img src={siteLogo} alt="NGU" className="h-6 w-auto" />
</Link> </Link>
<span className="ml-auto font-mono text-xs text-muted/70"> <span className="ml-auto font-mono text-xs text-muted/70">
{SITE_VERSION} {SITE_VERSION}{VERSION_NAME && ` · ${VERSION_NAME}`}
</span> </span>
</div> </div>
</footer> </footer>

View file

@ -17,6 +17,7 @@
a page (an image field stores the path, not a foreign key). a page (an image field stores the path, not a foreign key).
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import DownloadAs from "../../components/admin/DownloadAs.tsx";
import { useEffect, useState, type FormEvent } from "react"; import { useEffect, useState, type FormEvent } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -641,6 +642,9 @@ export default function AdminMedia() {
> >
Open Open
</a> </a>
{item.content_type?.startsWith("image/") && (
<DownloadAs url={item.url} name={item.original_name} />
)}
{roleCanWrite(user) && ( {roleCanWrite(user) && (
<RenameControl <RenameControl
item={item} item={item}

View file

@ -201,6 +201,11 @@ export const TOOLS_NAV = {
label: "Media", label: "Media",
blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.", blurb: "Uploaded images: logos, photos and backgrounds, ready to reuse.",
}, },
{
to: "/admin/convert",
label: "Image converter",
blurb: "Turn pictures into JPG, PNG or WebP, in your browser. Images in Media can also be downloaded as any of them.",
},
{ {
to: "/admin/clips", to: "/admin/clips",
label: "Video clips", label: "Video clips",

View file

@ -11,14 +11,21 @@
"Vocals, piano · Gospel, folk"), or their tagline without one; "Vocals, piano · Gospel, folk"), or their tagline without one;
their details panel adds their links. With a limit, the first that their details panel adds their links. With a limit, the first that
many show and a link leads to the full directory. many show and a link leads to the full directory.
DirectoryTabs is the preset with several tags (078): a tab each,
in the order picked (Community's Directories: Musicians, Authors,
Creators). One tag shows without tabs; reading mode lists every
tag's people, each under its name.
═══════════════════════════════════════════════════════════════ */ ═══════════════════════════════════════════════════════════════ */
import { ArrowRight } from '@phosphor-icons/react' import { ArrowRight } from '@phosphor-icons/react'
import { useId, useState, type KeyboardEvent } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
import { PeopleTilesView } from '../../components/PeopleTiles.tsx' import { PeopleTilesView } from '../../components/PeopleTiles.tsx'
import { useDirectory } from '../../lib/useDirectory.ts' import { useDirectory } from '../../lib/useDirectory.ts'
import { accentText, BRAND } from '../../lib/color.ts' import { useReadingMode } from '../../lib/readingMode.ts'
import { accentText, BRAND, readableOn, withAlpha } from '../../lib/color.ts'
/* How many people a section shows before "See the full directory". */ /* How many people a section shows before "See the full directory". */
export const DIRECTORY_PREVIEW = 12 export const DIRECTORY_PREVIEW = 12
@ -78,3 +85,95 @@ export default function PeopleDirectory({ tag, limit, accent = BRAND }: PeopleDi
</div> </div>
) )
} }
/* ── Several tags, a tab each ────────────────────────────────── */
type DirectoryTabsProps = {
tags: string[]
limit?: number
accent?: string
}
export function DirectoryTabs({ tags, limit, accent = BRAND }: DirectoryTabsProps) {
const [active, setActive] = useState(0)
const baseId = useId()
const reading = useReadingMode()
if (tags.length <= 1) return <PeopleDirectory tag={tags[0]} limit={limit} accent={accent} />
if (reading) {
return (
<>
{tags.map((tag) => (
<div key={tag} className="mb-10">
<div className="mx-auto max-w-6xl px-6">
<h3 className="mb-4 text-xl font-bold">
<TagName tag={tag} />
</h3>
</div>
<PeopleDirectory tag={tag} limit={limit} accent={accent} />
</div>
))}
</>
)
}
const current = Math.min(active, tags.length - 1)
// Arrows move one tab and wrap; Home and End jump to the ends.
const onKey = (e: KeyboardEvent<HTMLButtonElement>) => {
const last = tags.length - 1
const next =
e.key === 'ArrowRight' ? (current + 1) % tags.length
: e.key === 'ArrowLeft' ? (current + last) % tags.length
: e.key === 'Home' ? 0
: e.key === 'End' ? last
: null
if (next === null) return
e.preventDefault()
setActive(next)
document.getElementById(`${baseId}-tab-${next}`)?.focus()
}
return (
<>
<div className="mx-auto max-w-6xl px-6">
<div role="tablist" aria-label="Directories" className="mb-8 flex flex-wrap gap-2">
{tags.map((tag, index) => {
const selected = index === current
return (
<button
key={tag}
id={`${baseId}-tab-${index}`}
type="button"
role="tab"
aria-selected={selected}
aria-controls={`${baseId}-panel`}
tabIndex={selected ? 0 : -1}
onClick={() => setActive(index)}
onKeyDown={onKey}
className="btn border px-5 py-2 text-sm transition-colors"
style={
selected
? { background: accent, borderColor: accent, color: readableOn(accent) }
: { borderColor: withAlpha(accent, 33), color: accentText(accent) }
}
>
<TagName tag={tag} />
</button>
)
})}
</div>
</div>
<div id={`${baseId}-panel`} role="tabpanel" aria-labelledby={`${baseId}-tab-${current}`}>
<PeopleDirectory key={tags[current]} tag={tags[current]} limit={limit} accent={accent} />
</div>
</>
)
}
/* A tag's name, from its directory (asked once, and kept for its tab). */
function TagName({ tag }: { tag: string }) {
const { data } = useDirectory(tag)
return <>{data?.name ?? tag}</>
}

View file

@ -19,9 +19,11 @@
video a featured video under a "Featured video" badge. video a featured video under a "Featured video" badge.
Never autoplays: an embed waits for play, a file Never autoplays: an embed waits for play, a file
shows the browser's player shows the browser's player
event an event's card under a "Featured event" badge: event an event's card, under a "Featured event" badge
its photo, dates, place and buttons. The API picks from lg up (on a phone the card sits under the
the event (pinned, else the countdown's) words and the badge is left out): its photo, dates,
place and buttons. The API picks the event (pinned,
else the countdown's)
A choice with nothing to show falls back: photos with no photos A choice with nothing to show falls back: photos with no photos
to brand, a feature with no link set (or no event to show) to to brand, a feature with no link set (or no event to show) to
@ -125,6 +127,12 @@ export default function HeroStage({ hero }: { hero: Hero | null }) {
{feature === 'event' && hero?.event && ( {feature === 'event' && hero?.event && (
<div className="lg:col-span-7"> <div className="lg:col-span-7">
{/* Over the card it names, not over the headline beside it;
on a phone the card under the words speaks for itself. */}
<p className="mb-4 hidden items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] text-white backdrop-blur lg:inline-flex">
<Star className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" />
Featured event
</p>
<EventPanel event={hero.event} /> <EventPanel event={hero.event} />
</div> </div>
)} )}
@ -151,12 +159,7 @@ function Words({ hero, feature }: { hero: Hero; feature: HeroFeature }) {
</span> </span>
)} )}
</p> </p>
) : feature === 'event' ? ( ) : feature === 'event' ? null : feature === 'video' ? (
<p className="mb-6 inline-flex items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] backdrop-blur">
<Star className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" />
Featured event
</p>
) : feature === 'video' ? (
<p className="mb-6 inline-flex items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] backdrop-blur"> <p className="mb-6 inline-flex items-center gap-3 bg-white/10 px-4 py-1.5 text-sm font-semibold uppercase tracking-[0.2em] backdrop-blur">
<Play className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" /> <Play className="text-[var(--pal-amber-2)]" weight="fill" aria-hidden="true" />
Featured video Featured video