NGU-Web/src/lib/adminSchema/siteSettings.ts
Zaldimmar dc53af238f Add a Request form, with files in Google Drive and email notices
One form at /request for blog posts, events, and new or updated
chapters, regions (updates only), partners, teams, awards and people.
?type= opens it on one; buttons on the Community sections, blog posts,
Retreats and the front page calendar do. Files (.docx, PDF, JPEG, PNG)
go to a Google Drive folder through a service account.

Requests are feedback rows of type 'content' (migration 046), in a
third Forms queue: files download from Drive, a .docx can become a
draft blog post, and deleting a request deletes its files. New content
and data requests email the addresses in Site settings through Gmail.

Setup: docs/google-drive-and-mail.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 15:54:00 -05:00

193 lines
6.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import siteConfiguration from "../../../site.json";
import { mediaUrl } from "../media.ts";
import { THEME_DEFAULTS } from "../../../server/src/themeDefaults.js";
/* ── Site settings (035_site_settings.sql) ───────────────────────
Overrides for site.json, superadmins only: every blank falls back
to what site.json says, which is shown as the default. */
const SITE_PAGES: [string, string][] = Object.entries(siteConfiguration.pages).map(
([path, page]) => [path, `${page.title} (${path})`],
);
/* The palette an admin can change, in the order the dropdown lists
it: token and label. The defaults come from the server's list
(server/src/themeDefaults.js), which the build checks against
src/index.css, so there's one copy of each colour to change. */
const THEME_LABELS: [string, string][] = [
["ink", "Headings"],
["body", "Body text"],
["muted", "Secondary text and quiet borders"],
["link", "Links and teal text"],
["brand", "Brand teal (borders, rules, rings)"],
["action", "Buttons (under white text)"],
["action-hover", "Buttons, hovered"],
["surface", "Page and card background"],
["tint", "Tinted sections and panels"],
["tint-soft", "Faint panels and hovered rows"],
["danger", "Errors and warnings"],
["danger-tint", "Error panel background"],
];
const THEME_COLORS: [string, string, string, string][] = THEME_LABELS.map(([token, label]) => [
token,
label,
THEME_DEFAULTS[token][0],
THEME_DEFAULTS[token][1],
]);
const defaultHelp = (row, column: 2 | 3) => {
const entry = THEME_COLORS.find(([token]) => token === row?.token);
return entry ? `Default: ${entry[column]}` : undefined;
};
export const siteSettings = {
key: "site_settings",
label: "Site settings",
singular: "site settings",
idLabel: "Settings",
singleton: "site",
writeRole: "superadmin",
list: { columns: [], filters: [] },
groups: [
{
legend: "The site",
note: "Anything left blank uses site.json, so the build and these settings agree until you change one.",
fields: [
{ path: "site_name", label: "Site name", help: `Default: ${siteConfiguration.title}` },
{
path: "description",
label: "Description",
widget: "textarea",
full: true,
help: "Search engines and link previews show this for pages without their own. Default: site.json's, or the front page's subhead.",
},
{
path: "preview_image",
label: "Preview image",
widget: "image",
resolve: mediaUrl,
full: true,
help: "Shown when a page without its own image is shared. 1200 × 630 works everywhere.",
},
],
},
{
legend: "Icons",
fields: [
{
path: "favicon",
label: "Favicon",
widget: "image",
resolve: mediaUrl,
full: true,
help: "The browser-tab icon: a square PNG (512px) or an SVG. Keep original when uploading an SVG.",
},
{
path: "apple_touch_icon",
label: "Home-screen icon",
widget: "image",
resolve: mediaUrl,
full: true,
help: "For iPhones saving the site to their home screen: a square PNG, 180px, no transparency.",
},
],
},
{
legend: "Search engines",
fields: [
{
path: "indexing",
label: "Let search engines list this site",
widget: "select",
options: [
["on", "On: pages can appear in Google"],
["off", "Off: hidden from search (use on the dev server)"],
],
blankLabel: `Default: site.json (${siteConfiguration.robots?.index === false ? "off" : "on"})`,
help: "Applies to this server's database only, so dev can be off while production is on.",
},
],
},
{
legend: "Privacy",
fields: [
{
path: "privacy_email",
label: "Privacy contact email",
help: `The Privacy page gives this for privacy questions and data requests, eg. privacy@nextgenerationofunity.org. ${
siteConfiguration.privacyEmail ? `Default: ${siteConfiguration.privacyEmail}` : "Default: none, the page offers its request form only"
}.`,
},
],
},
{
legend: "Notices",
fields: [
{
path: "notify_emails",
label: "Email new requests to",
help: "Who gets an email for each new content request (the Request form) and data request (the Privacy page), separated by commas, eg. web@nextgenerationofunity.org, board@nextgenerationofunity.org. Needs Gmail set up on the server (docs/google-drive-and-mail.md). Default: none, check Forms instead.",
},
],
},
],
children: [
{
key: "colors",
label: "Colours",
note: "Change any of the site's colours, for light mode, dark mode or both; a blank keeps the default. Saving refuses a palette that would make text hard to read (under 4.5:1). Changes show on the next page load.",
addLabel: "Change a colour",
title: (row) => THEME_COLORS.find(([token]) => token === row.token)?.[1] ?? "New colour",
blank: { token: "", light: "", dark: "" },
fields: [
{
path: "token",
label: "Colour",
widget: "select",
options: THEME_COLORS.map(([token, label]) => [token, label]),
required: true,
},
{
path: "light",
label: "Light mode",
widget: "color",
placeholder: (row) => THEME_COLORS.find(([token]) => token === row?.token)?.[2],
help: (row) => defaultHelp(row, 2),
},
{
path: "dark",
label: "Dark mode",
widget: "color",
placeholder: (row) => THEME_COLORS.find(([token]) => token === row?.token)?.[3],
help: (row) => defaultHelp(row, 3),
},
],
},
{
key: "pages",
label: "Page titles and intros",
note: "Change a static page's heading and intro, which are also its search title and description. Blank fields keep site.json's.",
addLabel: "Change a page",
title: (row) => SITE_PAGES.find(([path]) => path === row.path)?.[1] ?? "New page",
blank: { path: "", title: "", description: "" },
fields: [
{ path: "path", label: "Page", widget: "select", options: SITE_PAGES, required: true },
{
path: "title",
label: "Title",
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.title ?? ""}` : undefined),
},
{
path: "description",
label: "Intro",
widget: "textarea",
full: true,
help: (row) => (row?.path ? `Default: ${siteConfiguration.pages[row.path]?.description ?? ""}` : undefined),
},
],
},
],
};