Website 1.2.0: starter pages on a new install, and a site icon
A new install had no pages, so the home page and its live preview showed only the header and footer (found on cross-demo2). The backend now adds the fixed pages with starter text at startup. Settings -> Site icon sets the favicon, with a default from the church's colour and initial. The Latest message's Card layout has its name; the media picker's placeholder has enough contrast. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* The site's own settings (WEBSITE-1.0-PLAN §10, "Settings"), live at once (they aren't the site's
|
||||
* design): the Coming soon line (§5), and the search engines' verification codes (ROADMAP-v3 §11:
|
||||
* Google Search Console and Bing Webmaster Tools), shown as `<meta>` tags on the home page. Also the
|
||||
* Google Search Console and Bing Webmaster Tools), shown as `<meta>` tags on the home page, and the
|
||||
* site's icon (1.2.0: the favicon, a picture from the media library; without one the site uses the
|
||||
* church's icon from its profile, else one made from its colour and initial). Also the
|
||||
* menu's order, and the audit log.
|
||||
*/
|
||||
import { z } from 'zod';
|
||||
@@ -18,13 +20,14 @@ const schema = z.object({
|
||||
comingSoonText: z.string().trim().max(300).optional(),
|
||||
googleVerification: code.optional(),
|
||||
bingVerification: code.optional(),
|
||||
faviconId: z.string().uuid().nullable().optional(),
|
||||
});
|
||||
|
||||
export type SiteSettings = { comingSoonText: string; googleVerification: string | null; bingVerification: string | null };
|
||||
export type SiteSettings = { comingSoonText: string; googleVerification: string | null; bingVerification: string | null; faviconId: string | null };
|
||||
|
||||
export async function getSettings(ctx: Ctx): Promise<SiteSettings> {
|
||||
const [coming, google, bing] = await Promise.all([ctx.settings.get('coming_soon_text'), ctx.settings.get('google_verification'), ctx.settings.get('bing_verification')]);
|
||||
return { comingSoonText: coming || 'Our new website is on its way.', googleVerification: google || null, bingVerification: bing || null };
|
||||
const [coming, google, bing, favicon] = await Promise.all([ctx.settings.get('coming_soon_text'), ctx.settings.get('google_verification'), ctx.settings.get('bing_verification'), ctx.settings.get('favicon_media_id')]);
|
||||
return { comingSoonText: coming || 'Our new website is on its way.', googleVerification: google || null, bingVerification: bing || null, faviconId: favicon || null };
|
||||
}
|
||||
|
||||
export async function saveSettings(ctx: Ctx, body: unknown, by: { id: string; role: string }) {
|
||||
@@ -35,10 +38,14 @@ export async function saveSettings(ctx: Ctx, body: unknown, by: { id: string; ro
|
||||
throw new ApiError(400, 'VALIDATION', 'Some settings need another look.', fields);
|
||||
}
|
||||
const s = r.data;
|
||||
if (s.faviconId && !(await ctx.db.mediaAsset.findUnique({ where: { id: s.faviconId } }))) {
|
||||
throw new ApiError(400, 'VALIDATION', 'Some settings need another look.', { faviconId: 'That picture isn\'t in the media library' });
|
||||
}
|
||||
await ctx.settings.setMany({
|
||||
...(s.comingSoonText !== undefined ? { coming_soon_text: s.comingSoonText || null } : {}),
|
||||
...(s.googleVerification !== undefined ? { google_verification: s.googleVerification || null } : {}),
|
||||
...(s.bingVerification !== undefined ? { bing_verification: s.bingVerification || null } : {}),
|
||||
...(s.faviconId !== undefined ? { favicon_media_id: s.faviconId || null } : {}),
|
||||
});
|
||||
await audit(ctx, { actorId: by.id, actorRole: by.role, action: 'settings_changed', targetType: 'settings', targetId: null, metadata: { fields: Object.keys(s) } });
|
||||
return getSettings(ctx);
|
||||
@@ -59,7 +66,7 @@ export async function orderPages(ctx: Ctx, body: unknown, by: { id: string }) {
|
||||
}
|
||||
|
||||
const ACTIONS: Record<string, string> = {
|
||||
site_published: 'Published the site', change_discarded: 'Discarded a change', version_restored: 'Restored a version',
|
||||
site_published: 'Published the site', change_discarded: 'Discarded a change', version_restored: 'Restored a version', starter_pages_added: 'Added the starter pages',
|
||||
preview_link_created: 'Made a preview link', preview_link_revoked: 'Stopped a preview link',
|
||||
first_owner_signed_in: 'Signed in as the first Owner', admin_signed_in: 'Signed in', admin_signed_out: 'Signed out',
|
||||
admin_sign_in_refused: 'Was refused sign-in (no role here)', website_user_added: 'Gave someone access',
|
||||
|
||||
Reference in New Issue
Block a user