Website 1.3.0, agent 1.6.0, contracts 1.19.0: demo data for the Church Website
Eight demo churches, two per template (the second on the template's other recommended variants and header), loaded from the Hub on demo sites with `crosscode demo <church> website --profile <p>`. A profile replaces the content only: the church's profile from Accounts, the site settings, the site icon and the admins stay, and the copy names the church. - contracts: WEBSITE_DEMO_PROFILES, DEMO_PRODUCTS, SEED_WEBSITE_DEMO_MIN_AGENT; seed-demo takes an optional product (events by default) - agent: a Website seed-demo job runs `crosscode demo <church> website` - crosscode script: backup, demo as the site's user, reload, health check Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,17 +3,24 @@
|
||||
* illustrated images (no photos of anyone), loaded into a template for development, the Hub's demo
|
||||
* sites and the crosscode-site screenshots. `npm run demo -- --template bold`.
|
||||
*
|
||||
* 1.3.0: also the eight demo profiles (seeds.ts, `npm run demo -- --profile bold-plant`), which
|
||||
* keep the church's own profile (Accounts' organisation settings), the site settings, the site
|
||||
* icon and the admins, and name the church in the copy. A template alone (development, e2e) is
|
||||
* still Acacia Hill, profile and all, exactly as before.
|
||||
*
|
||||
* It replaces the Website's content (never the admins), so the script refuses on a site that has
|
||||
* been published unless told otherwise.
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { CHURCH_SCHEMA, type Church, type WebsiteTemplate } from '@crosscode/contracts';
|
||||
import { CHURCH_SCHEMA, WEBSITE_TEMPLATES, type agent, type Church, type WebsiteTemplate } from '@crosscode/contracts';
|
||||
import type { Ctx } from '../context.js';
|
||||
import { churchProfile } from '../church/profile.js';
|
||||
import type { SectionData } from '../site/sections.js';
|
||||
import { publish } from '../site/snapshot.js';
|
||||
import { defaultDesign } from '../site/variants.js';
|
||||
import { TEMPLATE_HEADERS, TEMPLATE_VARIANTS, SECTION_TYPES, defaultDesign, type SiteDesign } from '../site/variants.js';
|
||||
import { DEMO_SEEDS, type DemoSeed } from './seeds.js';
|
||||
|
||||
export const DEMO_COLOURS = { primary: '#1d5c63', accent: '#e0a458' };
|
||||
|
||||
@@ -48,8 +55,8 @@ export function demoProfile(publicUrl: string): Church {
|
||||
}
|
||||
|
||||
/** An illustrated "photo": hills, a sun and a path in the church's colours (SVG, no people). */
|
||||
export function illustration(seed: number, w = 1600, h = 1000): string {
|
||||
const hues = [DEMO_COLOURS.primary, DEMO_COLOURS.accent, '#7fb7be', '#f3e3c3', '#284b52'];
|
||||
export function illustration(seed: number, w = 1600, h = 1000, colours: { primary: string; accent: string } = DEMO_COLOURS): string {
|
||||
const hues = [colours.primary, colours.accent, '#7fb7be', '#f3e3c3', '#284b52'];
|
||||
const c = (i: number) => hues[(seed + i) % hues.length];
|
||||
const y = (f: number) => Math.round(h * f);
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${w} ${h}" width="${w}" height="${h}">
|
||||
@@ -64,26 +71,17 @@ export function illustration(seed: number, w = 1600, h = 1000): string {
|
||||
|
||||
type Ids = Record<string, string>;
|
||||
|
||||
async function demoMedia(ctx: Ctx, uploadDir: string): Promise<Ids> {
|
||||
const items: [string, string, number][] = [
|
||||
['hero', 'The hills behind Acacia Hill at sunrise (illustration)', 0],
|
||||
['collage2', 'A path through the veld (illustration)', 1],
|
||||
['collage3', 'Evening over the valley (illustration)', 2],
|
||||
['welcome', 'The church garden (illustration)', 3],
|
||||
['pastor', 'Illustration standing in for the pastor\'s photo', 4],
|
||||
['invite', 'A sunny Sunday morning (illustration)', 5],
|
||||
['kids', 'Illustration for Kids church', 6],
|
||||
['youth', 'Illustration for Youth', 7],
|
||||
['care', 'Illustration for Care and prayer', 8],
|
||||
['music', 'Illustration for Worship', 9],
|
||||
];
|
||||
const HEX = /^#[0-9a-f]{6}$/i;
|
||||
|
||||
async function demoMedia(ctx: Ctx, uploadDir: string, alts: Record<string, string>, colours: { primary: string; accent: string }): Promise<Ids> {
|
||||
const items: [string, number][] = [['hero', 0], ['collage2', 1], ['collage3', 2], ['welcome', 3], ['pastor', 4], ['invite', 5], ['kids', 6], ['youth', 7], ['care', 8], ['music', 9]];
|
||||
const ids: Ids = {};
|
||||
fs.mkdirSync(path.join(uploadDir, 'demo'), { recursive: true });
|
||||
for (const [key, alt, seed] of items) {
|
||||
for (const [key, seed] of items) {
|
||||
const filename = `demo/${key}.svg`;
|
||||
const svg = illustration(seed);
|
||||
const svg = illustration(seed, 1600, 1000, colours);
|
||||
fs.writeFileSync(path.join(uploadDir, filename), svg);
|
||||
const row = await ctx.db.mediaAsset.create({ data: { filename, mime: 'image/svg+xml', bytes: Buffer.byteLength(svg), width: 1600, height: 1000, alt } });
|
||||
const row = await ctx.db.mediaAsset.create({ data: { filename, mime: 'image/svg+xml', bytes: Buffer.byteLength(svg), width: 1600, height: 1000, alt: alts[key]! } });
|
||||
ids[key] = row.id;
|
||||
}
|
||||
return ids;
|
||||
@@ -91,57 +89,160 @@ async function demoMedia(ctx: Ctx, uploadDir: string): Promise<Ids> {
|
||||
|
||||
export const defaultUploadDir = () => path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'uploads');
|
||||
|
||||
/** Replaces the content with the demo church's on `template`, then publishes it. */
|
||||
export async function loadDemo(ctx: Ctx, template: WebsiteTemplate, opts: { uploadDir?: string; publishedBy?: string } = {}) {
|
||||
/** The development demo church (Acacia Hill), on any template: what a template alone loads. */
|
||||
const CLASSIC: Omit<DemoSeed, 'template'> & { pastorName: string; ctaText: string; descriptions: Record<string, string>; alts: Record<string, string> } = {
|
||||
id: 'classic', label: 'Acacia Hill (development)', alternate: false,
|
||||
hero: { headline: 'A home for everyone on the hill', subline: 'Sundays at 08:30 and 10:00 in Westridge, Pretoria. Come as you are.', button: { label: 'Plan your visit', href: '/visit' } },
|
||||
serviceNote: 'Kids church runs during the 10:00 service. Parking on Acacia Avenue and behind the hall.',
|
||||
welcome: {
|
||||
heading: 'Welcome to Acacia Hill', mission: 'Loving God, loving our neighbours, from Westridge to the nations.',
|
||||
body: 'We are a family of ordinary people who have found good news in Jesus. Whether you have followed him for years or are just curious, there is a seat for you here, and coffee after the service.',
|
||||
quote: 'We would love to meet you. Come and say hello at the welcome table.',
|
||||
},
|
||||
ministriesIntro: 'There is something for every age and stage.',
|
||||
teamIntro: null,
|
||||
invitation: { heading: 'We saved you a seat', text: 'New here? Let us know you are coming and we will meet you at the door.', button: { label: 'Plan your visit', href: '/visit' } },
|
||||
visit: {
|
||||
expect: 'Services last about an hour and a quarter. We sing together, pray, and hear a message from the Bible. Dress is casual.',
|
||||
kids: 'Kids church (ages 3 to 12) runs during the 10:00 service. Sign your children in at the kids desk in the hall.',
|
||||
cta: 'Questions before you come?',
|
||||
},
|
||||
ctaText: 'Send us a WhatsApp and we will get back to you.',
|
||||
about: { story: 'Acacia Hill began in 1998 as a Bible study in a lounge in Westridge. Today we are a church of all ages that meets in the old school hall on Acacia Avenue.', quote: 'Love one another. As I have loved you, so you must love one another.', by: 'John 13:34' },
|
||||
give: 'Thank you for giving. You can give by EFT to Acacia Hill Church (demo details only: this is not a real account).',
|
||||
ministries: [
|
||||
['kids', 'Kids church', 'Ages 3 to 12, every Sunday at 10:00.'],
|
||||
['youth', 'Youth', 'High schoolers, Friday nights at 18:30.'],
|
||||
['worship', 'Worship', 'Musicians and sound, rehearsing on Thursdays.'],
|
||||
['care', 'Care and prayer', 'Meals, visits and prayer for anyone who needs it.'],
|
||||
],
|
||||
leaders: [['Thandi Mokoena', 'Lead pastor'], ['Pieter van Wyk', 'Associate pastor'], ['Lerato Dlamini', 'Kids and families'], ['Johan Botha', 'Worship']],
|
||||
pastorName: 'Pastor Thandi Mokoena',
|
||||
series: ['hope-for-today', 'Hope for today'],
|
||||
messages: [['hope-that-holds', 'A hope that holds', 3, 'Psalm 23'], ['bread-for-the-road', 'Bread for the road', 10, 'Psalm 23'], ['the-good-shepherd', 'The good shepherd', 17, 'Psalm 23']],
|
||||
events: [
|
||||
['family-picnic', 'Family picnic', 6, 'Bring a blanket and something to share. Games for the kids.'],
|
||||
['carols-by-candlelight', 'Carols by candlelight', 20, 'Our Christmas carol service on the lawn.'],
|
||||
['new-here-lunch', 'New here lunch', 34, 'Meet the pastors over lunch after the 10:00 service.'],
|
||||
],
|
||||
venue: 'Acacia Hill Church',
|
||||
descriptions: {
|
||||
home: 'Acacia Hill Church in Westridge, Pretoria: Sundays at 08:30 and 10:00. Come as you are.',
|
||||
visit: 'What to expect on your first Sunday at Acacia Hill Church.',
|
||||
about: 'Our story, what we believe and what we value.',
|
||||
ministries: 'Kids, youth, worship, care and prayer at Acacia Hill.',
|
||||
leadership: 'The team who lead Acacia Hill Church.',
|
||||
events: 'What is coming up at Acacia Hill Church.',
|
||||
messages: 'Sunday messages from Acacia Hill Church.',
|
||||
give: 'How to give to Acacia Hill Church.',
|
||||
contact: 'Find Acacia Hill Church in Westridge, Pretoria.',
|
||||
},
|
||||
alts: {
|
||||
hero: 'The hills behind Acacia Hill at sunrise (illustration)', collage2: 'A path through the veld (illustration)', collage3: 'Evening over the valley (illustration)',
|
||||
welcome: 'The church garden (illustration)', pastor: 'Illustration standing in for the pastor\'s photo', invite: 'A sunny Sunday morning (illustration)',
|
||||
kids: 'Illustration for Kids church', youth: 'Illustration for Youth', care: 'Illustration for Care and prayer', music: 'Illustration for Worship',
|
||||
},
|
||||
};
|
||||
|
||||
/** A demo profile's design: the template's defaults, or (alternate) its second recommendations and header. */
|
||||
export function seedDesign(template: WebsiteTemplate, alternate: boolean): SiteDesign {
|
||||
const design = defaultDesign(template);
|
||||
if (!alternate) return design;
|
||||
const variants = Object.fromEntries(SECTION_TYPES.map((s) => {
|
||||
const options = TEMPLATE_VARIANTS[template][s] as readonly string[];
|
||||
return [s, options[1] ?? options[0]!];
|
||||
})) as SiteDesign['variants'];
|
||||
const headers = TEMPLATE_HEADERS[template] as readonly string[];
|
||||
return { ...design, variants, style: { ...design.style, header: headers[1] ?? headers[0]! } };
|
||||
}
|
||||
|
||||
export const isDemoTemplate = (v: string): v is WebsiteTemplate => (WEBSITE_TEMPLATES as readonly string[]).includes(v);
|
||||
|
||||
/**
|
||||
* Replaces the content with a demo, then publishes it. `what`: a template (the Acacia Hill church,
|
||||
* its profile saved too) or a demo profile (keeps the church's profile; Acacia Hill's is saved
|
||||
* only on a site that has none at all, so the site still has a name).
|
||||
*/
|
||||
export async function loadDemo(ctx: Ctx, what: WebsiteTemplate | agent.WebsiteDemoProfile, opts: { uploadDir?: string; publishedBy?: string } = {}) {
|
||||
const db = ctx.db;
|
||||
const uploadDir = opts.uploadDir ?? ctx.config.uploadDir ?? defaultUploadDir();
|
||||
for (const m of ['section', 'page', 'ministry', 'leader', 'message', 'messageSeries', 'simpleEvent', 'mediaAsset', 'siteVersion', 'siteDesign'] as const) {
|
||||
const classic = isDemoTemplate(what);
|
||||
const seed: DemoSeed = classic ? { ...CLASSIC, template: what } : DEMO_SEEDS[what];
|
||||
const extra = classic ? CLASSIC : null;
|
||||
|
||||
// The church: Acacia Hill for a template; else whoever the site belongs to.
|
||||
let church = classic ? null : await churchProfile(ctx);
|
||||
if (!church) {
|
||||
church = demoProfile(ctx.config.publicUrl);
|
||||
await ctx.settings.set('church_profile_local', JSON.stringify(church));
|
||||
}
|
||||
const name = church.name;
|
||||
const short = church.shortName || church.name;
|
||||
const city = church.contact?.address?.city || church.contact?.address?.suburb || 'town';
|
||||
const t = (s: string) => s.replaceAll('{name}', name).replaceAll('{short}', short).replaceAll('{city}', city);
|
||||
const brand = church.branding?.colours;
|
||||
const colours = classic || !brand?.primary || !HEX.test(brand.primary)
|
||||
? DEMO_COLOURS
|
||||
: { primary: brand.primary, accent: brand.accent && HEX.test(brand.accent) ? brand.accent : DEMO_COLOURS.accent };
|
||||
|
||||
// The site icon is a setting, so its picture stays; every other picture goes with the content.
|
||||
const faviconId = classic ? null : await ctx.settings.get('favicon_media_id');
|
||||
for (const m of ['section', 'page', 'ministry', 'leader', 'message', 'messageSeries', 'simpleEvent', 'siteVersion', 'siteDesign', 'slugHistory', 'previewLink'] as const) {
|
||||
await (db[m] as unknown as { deleteMany: (a?: object) => Promise<unknown> }).deleteMany({});
|
||||
}
|
||||
const img = await demoMedia(ctx, uploadDir);
|
||||
const design = defaultDesign(template);
|
||||
await db.siteDesign.create({ data: { id: 1, template, variants: design.variants as never, home: design.home as never, style: design.style as never } });
|
||||
await ctx.settings.set('church_profile_local', JSON.stringify(demoProfile(ctx.config.publicUrl)));
|
||||
await db.mediaAsset.deleteMany(faviconId ? { where: { NOT: { id: faviconId } } } : undefined);
|
||||
|
||||
const [pastorName] = seed.leaders[0]!;
|
||||
const ministryNames = seed.ministries.map(([, n]) => t(n));
|
||||
const alts = extra?.alts ?? {
|
||||
hero: `${t(seed.hero.headline)} (illustration)`, collage2: 'A path through the veld (illustration)', collage3: 'Evening over the valley (illustration)',
|
||||
welcome: `${short} (illustration)`, pastor: `Illustration standing in for ${pastorName}'s photo`, invite: 'A sunny Sunday morning (illustration)',
|
||||
kids: `Illustration for ${ministryNames[0]}`, youth: `Illustration for ${ministryNames[1]}`, music: `Illustration for ${ministryNames[2]}`, care: `Illustration for ${ministryNames[3]}`,
|
||||
};
|
||||
const img = await demoMedia(ctx, uploadDir, alts, colours);
|
||||
const design = classic ? defaultDesign(seed.template) : seedDesign(seed.template, seed.alternate);
|
||||
await db.siteDesign.create({ data: { id: 1, template: seed.template, variants: design.variants as never, home: design.home as never, style: design.style as never } });
|
||||
|
||||
const speaker = extra?.pastorName ?? pastorName;
|
||||
const home: SectionData = {
|
||||
hero: { headline: 'A home for everyone on the hill', subline: 'Sundays at 08:30 and 10:00 in Westridge, Pretoria. Come as you are.', images: [img.hero!, img.collage2!, img.collage3!], videoId: null, button: { label: 'Plan your visit', href: '/visit' } },
|
||||
serviceTimes: { heading: 'Join us this Sunday', note: 'Kids church runs during the 10:00 service. Parking on Acacia Avenue and behind the hall.' },
|
||||
hero: { headline: t(seed.hero.headline), subline: t(seed.hero.subline), images: [img.hero!, img.collage2!, img.collage3!], videoId: null, button: seed.hero.button },
|
||||
serviceTimes: { heading: 'Join us this Sunday', note: t(seed.serviceNote) },
|
||||
welcome: {
|
||||
heading: 'Welcome to Acacia Hill', mission: 'Loving God, loving our neighbours, from Westridge to the nations.',
|
||||
body: 'We are a family of ordinary people who have found good news in Jesus. Whether you have followed him for years or are just curious, there is a seat for you here, and coffee after the service.',
|
||||
imageId: img.welcome!, pastor: { name: 'Pastor Thandi Mokoena', role: 'Lead pastor', quote: 'We would love to meet you. Come and say hello at the welcome table.', photoId: img.pastor! },
|
||||
heading: t(seed.welcome.heading), mission: t(seed.welcome.mission), body: t(seed.welcome.body),
|
||||
imageId: img.welcome!, pastor: { name: speaker, role: seed.leaders[0]![1], quote: t(seed.welcome.quote), photoId: img.pastor! },
|
||||
},
|
||||
ministries: { heading: 'Find your place', intro: 'There is something for every age and stage.' },
|
||||
team: { heading: 'Our team', intro: null },
|
||||
ministries: { heading: 'Find your place', intro: t(seed.ministriesIntro) },
|
||||
team: { heading: 'Our team', intro: seed.teamIntro ? t(seed.teamIntro) : null },
|
||||
events: { heading: 'Coming up', count: 3 },
|
||||
latestMessage: { heading: 'Latest message' },
|
||||
invitation: { heading: 'We saved you a seat', text: 'New here? Let us know you are coming and we will meet you at the door.', button: { label: 'Plan your visit', href: '/visit' }, imageId: img.invite! },
|
||||
invitation: { heading: t(seed.invitation.heading), text: t(seed.invitation.text), button: seed.invitation.button, imageId: img.invite! },
|
||||
};
|
||||
const d = (kind: string, fallback: string) => extra?.descriptions[kind] ?? t(fallback);
|
||||
const pages: { kind: string; slug: string; title: string; position: number; description: string; sections: { type: string; variant?: string; data: unknown }[] }[] = [
|
||||
{ kind: 'home', slug: 'home', title: 'Home', position: 0, description: 'Acacia Hill Church in Westridge, Pretoria: Sundays at 08:30 and 10:00. Come as you are.', sections: Object.entries(home).map(([type, data]) => ({ type, data })) },
|
||||
{ kind: 'home', slug: 'home', title: 'Home', position: 0, description: d('home', `${seed.hero.subline}`), sections: Object.entries(home).map(([type, data]) => ({ type, data })) },
|
||||
{
|
||||
kind: 'visit', slug: 'visit', title: 'Plan your visit', position: 1, description: 'What to expect on your first Sunday at Acacia Hill Church.', sections: [
|
||||
{ type: 'text', data: { heading: 'What to expect', body: 'Services last about an hour and a quarter. We sing together, pray, and hear a message from the Bible. Dress is casual.' } },
|
||||
{ type: 'image-text', variant: 'image-text', data: { heading: 'Bringing children', body: 'Kids church (ages 3 to 12) runs during the 10:00 service. Sign your children in at the kids desk in the hall.', imageId: img.kids, button: null } },
|
||||
{ type: 'cta', data: { heading: 'Questions before you come?', text: 'Send us a WhatsApp and we will get back to you.', button: { label: 'Contact us', href: '/contact' } } },
|
||||
kind: 'visit', slug: 'visit', title: 'Plan your visit', position: 1, description: d('visit', 'What to expect on your first Sunday at {name}.'), sections: [
|
||||
{ type: 'text', data: { heading: 'What to expect', body: t(seed.visit.expect) } },
|
||||
{ type: 'image-text', variant: 'image-text', data: { heading: 'Bringing children', body: t(seed.visit.kids), imageId: img.kids, button: null } },
|
||||
{ type: 'cta', data: { heading: t(seed.visit.cta), text: extra?.ctaText ?? 'Send us a message and we will get back to you.', button: { label: 'Contact us', href: '/contact' } } },
|
||||
],
|
||||
},
|
||||
{
|
||||
kind: 'about', slug: 'about', title: 'About us', position: 2, description: 'Our story, what we believe and what we value.', sections: [
|
||||
{ type: 'text', data: { heading: 'Our story', body: 'Acacia Hill began in 1998 as a Bible study in a lounge in Westridge. Today we are a church of all ages that meets in the old school hall on Acacia Avenue.' } },
|
||||
{ type: 'quote', data: { quote: 'Love one another. As I have loved you, so you must love one another.', by: 'John 13:34' } },
|
||||
kind: 'about', slug: 'about', title: 'About us', position: 2, description: d('about', 'Our story, what we believe and what we value.'), sections: [
|
||||
{ type: 'text', data: { heading: 'Our story', body: t(seed.about.story) } },
|
||||
{ type: 'quote', data: { quote: seed.about.quote, by: seed.about.by } },
|
||||
],
|
||||
},
|
||||
{ kind: 'ministries', slug: 'ministries', title: 'Ministries', position: 3, description: 'Kids, youth, worship, care and prayer at Acacia Hill.', sections: [] },
|
||||
{ kind: 'leadership', slug: 'leadership', title: 'Leadership', position: 4, description: 'The team who lead Acacia Hill Church.', sections: [] },
|
||||
{ kind: 'events', slug: 'events', title: 'Events', position: 5, description: 'What is coming up at Acacia Hill Church.', sections: [] },
|
||||
{ kind: 'messages', slug: 'messages', title: 'Messages', position: 6, description: 'Sunday messages from Acacia Hill Church.', sections: [] },
|
||||
{ kind: 'ministries', slug: 'ministries', title: 'Ministries', position: 3, description: d('ministries', `${ministryNames.join(', ')} at {short}.`), sections: [] },
|
||||
{ kind: 'leadership', slug: 'leadership', title: 'Leadership', position: 4, description: d('leadership', 'The team who lead {name}.'), sections: [] },
|
||||
{ kind: 'events', slug: 'events', title: 'Events', position: 5, description: d('events', 'What is coming up at {name}.'), sections: [] },
|
||||
{ kind: 'messages', slug: 'messages', title: 'Messages', position: 6, description: d('messages', 'Sunday messages from {name}.'), sections: [] },
|
||||
{
|
||||
kind: 'give', slug: 'give', title: 'Give', position: 7, description: 'How to give to Acacia Hill Church.', sections: [
|
||||
{ type: 'text', data: { heading: 'Giving', body: 'Thank you for giving. You can give by EFT to Acacia Hill Church (demo details only: this is not a real account).' } },
|
||||
kind: 'give', slug: 'give', title: 'Give', position: 7, description: d('give', 'How to give to {name}.'), sections: [
|
||||
{ type: 'text', data: { heading: 'Giving', body: t(seed.give) } },
|
||||
],
|
||||
},
|
||||
{ kind: 'contact', slug: 'contact', title: 'Contact', position: 8, description: 'Find Acacia Hill Church in Westridge, Pretoria.', sections: [] },
|
||||
{ kind: 'contact', slug: 'contact', title: 'Contact', position: 8, description: d('contact', 'Find {name} in {city}.'), sections: [] },
|
||||
];
|
||||
for (const p of pages) {
|
||||
const page = await db.page.create({ data: { kind: p.kind as never, slug: p.slug, title: p.title, position: p.position, description: p.description } });
|
||||
@@ -149,38 +250,21 @@ export async function loadDemo(ctx: Ctx, template: WebsiteTemplate, opts: { uplo
|
||||
for (const s of p.sections) await db.section.create({ data: { pageId: page.id, type: s.type, variant: s.variant ?? null, position: i++, data: s.data as never } });
|
||||
}
|
||||
|
||||
const ministries: [string, string, string, string][] = [
|
||||
['kids', 'Kids church', 'Ages 3 to 12, every Sunday at 10:00.', img.kids!],
|
||||
['youth', 'Youth', 'High schoolers, Friday nights at 18:30.', img.youth!],
|
||||
['worship', 'Worship', 'Musicians and sound, rehearsing on Thursdays.', img.music!],
|
||||
['care', 'Care and prayer', 'Meals, visits and prayer for anyone who needs it.', img.care!],
|
||||
];
|
||||
const pictures = [img.kids!, img.youth!, img.music!, img.care!];
|
||||
let n = 0;
|
||||
for (const [slug, name, summary, imageId] of ministries) await db.ministry.create({ data: { slug, name, summary, imageId, position: n++ } });
|
||||
const leaders: [string, string, string | null][] = [
|
||||
['Thandi Mokoena', 'Lead pastor', img.pastor!],
|
||||
['Pieter van Wyk', 'Associate pastor', null],
|
||||
['Lerato Dlamini', 'Kids and families', null],
|
||||
['Johan Botha', 'Worship', null],
|
||||
];
|
||||
for (const [slug, , summary] of seed.ministries) await db.ministry.create({ data: { slug, name: ministryNames[n]!, summary: t(summary), imageId: pictures[n]!, position: n++ } });
|
||||
n = 0;
|
||||
for (const [name, role, photoId] of leaders) await db.leader.create({ data: { name, role, photoId, position: n++ } });
|
||||
for (const [leader, role] of seed.leaders) await db.leader.create({ data: { name: leader, role, photoId: n === 0 ? img.pastor! : null, position: n++ } });
|
||||
|
||||
const now = ctx.now();
|
||||
const day = 864e5;
|
||||
const series = await db.messageSeries.create({ data: { slug: 'hope-for-today', title: 'Hope for today' } });
|
||||
const messages: [string, string, number][] = [['hope-that-holds', 'A hope that holds', 3], ['bread-for-the-road', 'Bread for the road', 10], ['the-good-shepherd', 'The good shepherd', 17]];
|
||||
for (const [slug, title, ago] of messages) {
|
||||
await db.message.create({ data: { slug, title, date: new Date(now.getTime() - ago * day), source: 'youtube', mediaUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ', speaker: 'Pastor Thandi Mokoena', passage: 'Psalm 23', seriesId: series.id, publishedAt: now } });
|
||||
const series = await db.messageSeries.create({ data: { slug: seed.series[0], title: seed.series[1] } });
|
||||
for (const [slug, title, ago, passage] of seed.messages) {
|
||||
await db.message.create({ data: { slug, title, date: new Date(now.getTime() - ago * day), source: 'youtube', mediaUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ', speaker, passage, seriesId: series.id, publishedAt: now } });
|
||||
}
|
||||
const events: [string, string, number, string][] = [
|
||||
['family-picnic', 'Family picnic', 6, 'Bring a blanket and something to share. Games for the kids.'],
|
||||
['carols-by-candlelight', 'Carols by candlelight', 20, 'Our Christmas carol service on the lawn.'],
|
||||
['new-here-lunch', 'New here lunch', 34, 'Meet the pastors over lunch after the 10:00 service.'],
|
||||
];
|
||||
for (const [slug, title, inDays, description] of events) {
|
||||
for (const [slug, title, inDays, description] of seed.events) {
|
||||
const startsAt = new Date(Math.floor((now.getTime() + inDays * day) / day) * day + 8 * 3600e3);
|
||||
await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: 'Acacia Hill Church', description, publishedAt: now } });
|
||||
await db.simpleEvent.create({ data: { slug, title, startsAt, endsAt: new Date(startsAt.getTime() + 3 * 3600e3), location: t(seed.venue), description: t(description), publishedAt: now } });
|
||||
}
|
||||
return publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, `Demo church on ${template}`);
|
||||
return publish(ctx, { id: opts.publishedBy ?? 'demo', role: 'system' }, classic ? `Demo church on ${seed.template}` : `Demo: ${seed.label}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user