Website 1.6.0: real photos for the demo church, photos sized to their frames

The demo church (and the eight demo profiles) used one generated "hills and
sun" SVG for every picture. Now 104 Unsplash stock photos (models; free under
the Unsplash License, credited in backend/demo-photos/CREDITS.md): a set per
profile, a portrait for every leader (before: only the pastor), a picture for
each event, and a photo for each message instead of the stand-in video's
thumbnail. Demo photos go through processImage like an upload, made once per
machine and copied; without demo-photos/ the illustration still stands in.

A message's thumbnailUrl that is one of the site's own uploads now comes
before the YouTube thumbnail; admins and the YouTube feed store YouTube's
address there, so a church's own messages are unchanged.

Faster on phones: the Community collage hero, the collage row, the team's
portraits and the ministry cards give the browser their real width (sizes),
so a phone no longer fetches the full-width photo for a small frame.

Checked: backend tests (131), Website e2e (130, baselines retaken;
Lighthouse mobile 90-98 performance, 100 accessibility and SEO), typecheck,
lint and both builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 14:31:57 +02:00
co-authored by Claude Opus 5.5
parent 28085d92ba
commit 2d4d9ea871
120 changed files with 1401 additions and 60 deletions
+35 -9
View File
@@ -7,7 +7,7 @@ import request from 'supertest';
import { WEBSITE_TEMPLATES, agent } from '@crosscode/contracts';
import { demoProfile, loadDemo, seedDesign } from '../src/demo/demoChurch.js';
import { DEMO_SEEDS, demoSeeds } from '../src/demo/seeds.js';
import { siteContent, spotifyEmbed, youtubeId } from '../src/site/content.js';
import { messageThumbnail, siteContent, spotifyEmbed, youtubeId } from '../src/site/content.js';
import { buildPalette, contrast, hexToRgb } from '../src/site/palette.js';
import { parseSectionData } from '../src/site/sections.js';
import { buildSnapshot, cleanDesign, publish } from '../src/site/snapshot.js';
@@ -118,8 +118,9 @@ describe('the public site\'s content', () => {
const hero = c.snapshot.pages[0]!.sections[0]!;
assert.equal(hero.type, 'hero');
const firstImage = (hero.data.images as string[])[0]!;
assert.match(c.snapshot.media[firstImage]!.url, /^\/api\/uploads\/demo\/hero\.svg$/);
assert.ok(fs.existsSync(path.join(dir, 'demo', 'hero.svg')));
assert.match(c.snapshot.media[firstImage]!.url, /^\/api\/uploads\/demo\/acacia-sunrise\.webp$/, 'a photo, not an illustration');
assert.ok(fs.existsSync(path.join(dir, 'demo', 'acacia-sunrise.webp')));
assert.ok(fs.existsSync(path.join(dir, 'demo', 'acacia-sunrise-960.webp')), 'in the responsive sizes an upload gets');
});
}
@@ -144,7 +145,18 @@ describe('the public site\'s content', () => {
assert.doesNotMatch(all, /\{(name|short|city)\}/, 'every placeholder is filled in');
assert.doesNotMatch(all, /Acacia/, 'nothing of the development church');
assert.equal(c.snapshot.design.variants.hero, seedDesign(seed.template, seed.alternate).variants.hero);
assert.match(fs.readFileSync(path.join(dir, 'demo', 'hero.svg'), 'utf8'), /#8a1538/, 'pictures in the church\'s colours');
assert.ok(fs.existsSync(path.join(dir, 'demo', `${seed.photos.hero}.webp`)), 'the profile\'s own hero photo');
const welcome = c.snapshot.pages[0]!.sections.find((s) => s.type === 'welcome')!.data as { pastor: { photoId: string } };
assert.equal(c.snapshot.media[welcome.pastor.photoId]!.alt, seed.leaders[0]![0], 'the pastor\'s photo is named for them');
for (const [i, l] of c.snapshot.leaders.entries()) {
assert.ok(l.photo, `${l.name} has a photo`);
assert.equal(l.photo!.alt, seed.leaders[i]![0], 'named for them');
}
for (const e of c.events) assert.ok(e.image, `${e.title} has a picture`);
for (const m of c.messages) {
assert.match(m.thumbnail ?? '', /^\/api\/uploads\/demo\/[a-z-]+-960\.webp$/, `${m.title}: a demo photo, not the stand-in video's`);
assert.ok(fs.existsSync(path.join(dir, m.thumbnail!.replace('/api/uploads/', ''))));
}
});
}
@@ -171,7 +183,7 @@ describe('the public site\'s content', () => {
assert.ok(await h.db.mediaAsset.findUnique({ where: { id: icon.id } }), 'the site icon stays');
assert.equal(await h.ctx.settings.get('favicon_media_id'), icon.id);
assert.equal(await h.ctx.settings.get('coming_soon_text'), 'Soon!');
assert.equal(await h.db.mediaAsset.count(), 11, 'the ten pictures and the icon');
assert.equal(await h.db.mediaAsset.count(), 19, 'eighteen pictures (ten on the pages, three of the team, three messages\', two more for the events: the harvest festival\'s is the collage\'s hay bales) and the icon');
assert.equal(await h.db.slugHistory.count(), 0);
assert.equal((await siteContent(h.ctx)).church?.name, 'Acacia Hill Church', 'the profile saved by the first demo stays');
});
@@ -188,9 +200,9 @@ describe('the public site\'s content', () => {
const dir = tmp();
const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } });
await loadDemo(h.ctx, 'community', { uploadDir: dir });
const svg = await request(h.app).get('/api/uploads/demo/hero.svg');
assert.equal(svg.status, 200);
assert.match(String(svg.headers['content-security-policy']), /sandbox/);
const photo = await request(h.app).get('/api/uploads/demo/acacia-sunrise.webp');
assert.equal(photo.status, 200);
assert.match(String(photo.headers['content-security-policy']), /sandbox/);
assert.equal((await request(h.app).get('/api/uploads/demo/')).status, 404);
assert.ok([403, 404].includes((await request(h.app).get('/api/uploads/..%2f..%2fpackage.json')).status));
assert.equal((await request(h.app).get('/api/uploads/missing.png')).status, 404);
@@ -214,7 +226,21 @@ describe("the messages' thumbnails, served from the site (§7)", () => {
await loadDemo(h.ctx, 'heritage', { uploadDir: dir });
const content = await siteContent(h.ctx);
assert.ok(content.mode === 'published' && content.messages.length > 0);
for (const m of content.messages) assert.equal(m.thumbnail, '/api/thumbnails/aqz-KE-bpKQ.jpg');
for (const m of content.messages) assert.match(m.thumbnail ?? '', /^\/api\/uploads\/demo\//, 'the demo\'s photos');
// A message as an admin or the YouTube feed saves it: YouTube's address is kept, never shown.
await h.db.message.updateMany({ data: { thumbnailUrl: 'https://i.ytimg.com/vi/aqz-KE-bpKQ/hqdefault.jpg' } });
const again = await siteContent(h.ctx);
assert.ok(again.mode === 'published');
for (const m of again.messages) assert.equal(m.thumbnail, '/api/thumbnails/aqz-KE-bpKQ.jpg');
});
it('a thumbnail of its own is only ever one of the site\'s uploads', () => {
const yt = { source: 'youtube', mediaUrl: 'https://www.youtube.com/watch?v=aqz-KE-bpKQ' };
assert.equal(messageThumbnail({ ...yt, thumbnailUrl: '/api/uploads/demo/pulpit-960.webp' }), '/api/uploads/demo/pulpit-960.webp');
for (const other of ['https://evil.example/x.jpg', '/api/uploads/../../etc/passwd', '//evil.example/x.jpg', '/api/thumbnails/x.jpg', null, '']) {
assert.equal(messageThumbnail({ ...yt, thumbnailUrl: other }), '/api/thumbnails/aqz-KE-bpKQ.jpg', String(other));
}
assert.equal(messageThumbnail({ source: 'spotify', mediaUrl: 'https://open.spotify.com/episode/x', thumbnailUrl: null }), null);
});
it("fetches a message's thumbnail once and keeps it; nothing for a video that isn't the site's", async () => {