From 723bb15a5eb68356032eb0ceb4dea58dd1dceb05 Mon Sep 17 00:00:00 2001 From: Joshua Oosthuizen Date: Thu, 26 Nov 2026 14:36:34 +0200 Subject: [PATCH] website 1.0.1: thumbnails from the site, Calendar dates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The messages' YouTube thumbnails are served from the site (/api/thumbnails/.jpg): the backend fetches a message's thumbnail once and keeps it in uploads/.thumbnails (only the site's own videos, only a JPEG), so visitors ask nothing of YouTube before pressing play. The messages page preloads the first one (its LCP: Heritage 89 -> 95). - Calendar events' dates read "Sun · November", not "Sun (month: November)". - e2e: no request to YouTube or Spotify before play; the variant screenshots round section heights to whole pixels (a one-pixel flake); the e2e thumbnail is one of the demo's illustrations. - crosscode script: a Website's export leaves out uploads/.thumbnails. - docs: release checks on 1.0.1, VERSIONS, handover. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 9 +++ apps/website/CHANGELOG.md | 16 +++++ apps/website/WHATS-NEW.md | 7 ++ apps/website/backend/package.json | 2 +- apps/website/backend/src/admin/happenings.ts | 4 +- apps/website/backend/src/app.ts | 19 +++++ apps/website/backend/src/context.ts | 5 +- apps/website/backend/src/demo/demoChurch.ts | 2 +- apps/website/backend/src/site/content.ts | 11 ++- apps/website/backend/src/site/thumbnails.ts | 70 +++++++++++++++++++ apps/website/backend/tests/site.test.ts | 55 +++++++++++++++ apps/website/e2e/server.ts | 11 ++- apps/website/e2e/templates.spec.ts | 13 ++++ apps/website/e2e/variants.spec.ts | 22 +++++- apps/website/frontend/package.json | 2 +- .../frontend/src/site/MessagePlayer.tsx | 3 +- apps/website/frontend/src/site/PageView.tsx | 8 +-- apps/website/frontend/src/site/meta.ts | 2 +- .../frontend/src/site/sections/index.tsx | 3 +- docs/HANDOVER.md | 28 +++----- docs/VERSIONS.md | 15 +++- docs/WEBSITE-1.0-PLAN.md | 9 +++ package-lock.json | 4 +- scripts/products/website.sh | 3 +- 24 files changed, 282 insertions(+), 41 deletions(-) create mode 100644 apps/website/backend/src/site/thumbnails.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed9eb0..1ec106f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ Each package and app has its own section and its own tags (`contracts@1.0.0`, `accounts@1.0.0`, …). +## website@1.0.1 + crosscode script - 2026-11-26 + +Details in `apps/website/CHANGELOG.md`. + +- **Website 1.0.1:** the messages' YouTube thumbnails are served from the site + (`/api/thumbnails/.jpg`), so visitors ask nothing of YouTube until they press play; the + Calendar events' dates read "Sun · November", not "Sun (month: November)". No migration. +- **crosscode script:** a Website's export leaves out `uploads/.thumbnails` (the kept thumbnails). + ## contracts@1.18.0 - 2026-11-25 "Get more storage" for the Church Website (WEBSITE-1.0-PLAN §10, decision 12), with Hub 2.22.0. diff --git a/apps/website/CHANGELOG.md b/apps/website/CHANGELOG.md index 79e9010..bec7693 100644 --- a/apps/website/CHANGELOG.md +++ b/apps/website/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog — Church Website +## [1.0.1] — 2026-11-26 + +### Fixed + +- **The messages' thumbnails come from the site** (WEBSITE-1.0-PLAN §7): they loaded from YouTube + (`i.ytimg.com`) with the page, so every visitor was in touch with YouTube before pressing play. + The backend now fetches a message's thumbnail once and keeps it (`/api/thumbnails/.jpg`, + kept in `uploads/.thumbnails/`, not counted as storage and left out of the export); only the + site's own messages' videos are fetched, and only a JPEG is kept. The messages page asks for the + first one from the `` (it's the largest thing on screen), and the e2e checks that nothing + is asked of YouTube or Spotify until play is clicked. +- **Calendar events' dates** read "Sun (month: November)": a weekday and month without a day is + printed that way by `Intl`. Now "Sun · November". +- **The variant screenshots no longer flake** (e2e only): a section starting at a fractional + position came out a pixel taller or shorter from run to run. The header's and each section's + height is rounded up before the screenshot; the baselines were taken again with it. ## [1.0.0] — 2026-11-26 ### Added diff --git a/apps/website/WHATS-NEW.md b/apps/website/WHATS-NEW.md index 97e29ad..80bb914 100644 --- a/apps/website/WHATS-NEW.md +++ b/apps/website/WHATS-NEW.md @@ -3,6 +3,13 @@ What each version changes for the church, in plain language (read by the Hub like Cross Events' WHATS-NEW.md; a section shows once its version is tagged). +## 1.0.1 + +- **Your visitors' privacy:** the pictures on your messages now come from your own website, so + nothing is loaded from YouTube until someone presses play. The Messages page also shows a little + sooner. +- **Event dates in the Calendar layout** read properly ("Sun · November"). + ## 1.0.0 — requires accounts 1.7.0 - **Your church's own website**, managed by you. Choose one of four templates (Heritage, Bold, diff --git a/apps/website/backend/package.json b/apps/website/backend/package.json index d82cb3e..7c0cba7 100644 --- a/apps/website/backend/package.json +++ b/apps/website/backend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/website-backend", - "version": "1.0.0", + "version": "1.0.1", "description": "Church Website: the public site's content API, the admin API, publishing and uploads", "private": true, "type": "module", diff --git a/apps/website/backend/src/admin/happenings.ts b/apps/website/backend/src/admin/happenings.ts index 50dd277..055930e 100644 --- a/apps/website/backend/src/admin/happenings.ts +++ b/apps/website/backend/src/admin/happenings.ts @@ -8,7 +8,7 @@ import { z } from 'zod'; import type { Ctx } from '../context.js'; import { ApiError } from '../http.js'; import { audit } from '../lib/audit.js'; -import { youtubeId, spotifyEmbed } from '../site/content.js'; +import { youtubeId, spotifyEmbed, messageThumbnail } from '../site/content.js'; import { mediaUrl } from '../site/snapshot.js'; import { getSource, setSource, syncYoutube, uniqueSlug } from '../site/youtube.js'; import { markRemoved, notifyLinks } from '../feed/feed.js'; @@ -58,7 +58,7 @@ export async function listMessages(ctx: Ctx) { youtube: { source, lastSync, lastError }, items: rows.map((m) => ({ id: m.id, title: m.title, date: m.date.toISOString(), mediaUrl: m.mediaUrl, source: m.source, speaker: m.speaker, passage: m.passage, notes: m.notes, - series: m.series?.title ?? null, hidden: m.hidden, published: m.publishedAt !== null, thumbnail: m.thumbnailUrl, + series: m.series?.title ?? null, hidden: m.hidden, published: m.publishedAt !== null, thumbnail: messageThumbnail(m), })), }; } diff --git a/apps/website/backend/src/app.ts b/apps/website/backend/src/app.ts index 012d740..ba9c51d 100644 --- a/apps/website/backend/src/app.ts +++ b/apps/website/backend/src/app.ts @@ -5,6 +5,7 @@ * /api/health version and database, for monitoring, `crosscode deploy` and the Hub * /api/v1/site/… the public site (what visitors see: the latest published version) * /api/uploads/… the church's uploaded images + * /api/thumbnails/.jpg its messages' YouTube thumbnails, kept here (visitors never ask YouTube) * /api/auth/… signing in to the admin through the church's Accounts * /api/accounts/v1/events Accounts' signed calls (user.updated / export / deleted) * /api/links/v1/… Connect and Disconnect with the church's other products @@ -27,6 +28,7 @@ import { linksRouter } from './links/routes.js'; import { defaultUploadDir } from './demo/demoChurch.js'; import { previewContent, siteContent } from './site/content.js'; import { siteStatus } from './site/status.js'; +import { thumbnail } from './site/thumbnails.js'; export function createApp(ctx: Ctx) { const app = express(); @@ -75,6 +77,23 @@ export function createApp(ctx: Ctx) { }, })); + // A message's YouTube thumbnail, fetched once by the backend and kept (site/thumbnails.ts). + app.get('/api/thumbnails/:file', async (req, res, next) => { + try { + const id = /^([A-Za-z0-9_-]+)\.jpg$/.exec(req.params.file)?.[1]; + const body = id ? await thumbnail(ctx, id) : null; + if (!body) { + res.set('Cache-Control', 'no-store'); + return sendError(res, new ApiError(404, 'NOT_FOUND', 'There is no such file.')); + } + res.set('Content-Type', 'image/jpeg'); + res.set('Cache-Control', 'public, max-age=604800'); + res.send(body); + } catch (err) { + next(err); + } + }); + app.use('/api', authRouter(ctx)); app.use('/api', linksRouter(ctx)); diff --git a/apps/website/backend/src/context.ts b/apps/website/backend/src/context.ts index c1e60f5..8fcb8bb 100644 --- a/apps/website/backend/src/context.ts +++ b/apps/website/backend/src/context.ts @@ -18,13 +18,16 @@ export type Ctx = { /** `@crosscode/auth-client` (tests give a stand-in). */ authClient: () => Promise; now: () => Date; + /** Fetches what visitors are shown from outside (YouTube's thumbnails); tests give a stand-in. */ + fetch?: (url: string) => Promise; }; -export function createCtx(config: Config, db: Db, opts: { now?: () => Date; authClient?: () => Promise } = {}): Ctx { +export function createCtx(config: Config, db: Db, opts: { now?: () => Date; authClient?: () => Promise; fetch?: (url: string) => Promise } = {}): Ctx { const secrets = new Secrets(config.secret); const partial = { config, db, secrets } as Ctx; partial.settings = new Settings(partial); partial.authClient = opts.authClient ?? loadAuthClient; partial.now = opts.now ?? (() => new Date()); + if (opts.fetch) partial.fetch = opts.fetch; return partial; } diff --git a/apps/website/backend/src/demo/demoChurch.ts b/apps/website/backend/src/demo/demoChurch.ts index 26d59d9..dfec98b 100644 --- a/apps/website/backend/src/demo/demoChurch.ts +++ b/apps/website/backend/src/demo/demoChurch.ts @@ -48,7 +48,7 @@ export function demoProfile(publicUrl: string): Church { } /** An illustrated "photo": hills, a sun and a path in the church's colours (SVG, no people). */ -function illustration(seed: number, w = 1600, h = 1000): string { +export function illustration(seed: number, w = 1600, h = 1000): string { const hues = [DEMO_COLOURS.primary, DEMO_COLOURS.accent, '#7fb7be', '#f3e3c3', '#284b52']; const c = (i: number) => hues[(seed + i) % hues.length]; const y = (f: number) => Math.round(h * f); diff --git a/apps/website/backend/src/site/content.ts b/apps/website/backend/src/site/content.ts index dad4f49..78e2550 100644 --- a/apps/website/backend/src/site/content.ts +++ b/apps/website/backend/src/site/content.ts @@ -77,6 +77,15 @@ function brandFor(church: Church | null, template: WebsiteTemplate) { }; } +/** Where the site serves a YouTube video's thumbnail from (site/thumbnails.ts): visitors never ask YouTube. */ +export const thumbnailPath = (videoId: string) => `/api/thumbnails/${videoId}.jpg`; + +/** A message's thumbnail on the site: its YouTube video's, served from here; none for Spotify. */ +export function messageThumbnail(m: { source: string; mediaUrl: string }) { + const yt = m.source === 'spotify' ? null : youtubeId(m.mediaUrl); + return yt ? thumbnailPath(yt) : null; +} + /** `https://www.youtube.com/watch?v=abc` → its id; null for anything else. */ export function youtubeId(url: string): string | null { try { @@ -104,7 +113,7 @@ async function liveMessages(ctx: Ctx): Promise { source: m.source === 'spotify' ? 'spotify' : 'youtube', embedUrl: yt ? `https://www.youtube-nocookie.com/embed/${yt}?autoplay=1` : spotifyEmbed(m.mediaUrl), url: m.mediaUrl, - thumbnail: m.thumbnailUrl ?? (yt ? `https://i.ytimg.com/vi/${yt}/hqdefault.jpg` : null), + thumbnail: messageThumbnail(m), }; }); } diff --git a/apps/website/backend/src/site/thumbnails.ts b/apps/website/backend/src/site/thumbnails.ts new file mode 100644 index 0000000..25cd52e --- /dev/null +++ b/apps/website/backend/src/site/thumbnails.ts @@ -0,0 +1,70 @@ +/** + * A message's YouTube thumbnail, served from the site (WEBSITE-1.0-PLAN §7: nothing loads from + * YouTube until a visitor clicks play). The backend fetches `i.ytimg.com/vi//hqdefault.jpg` + * once and keeps it in `/.thumbnails/` (not served from /api/uploads, which denies dot + * folders, and not counted as the church's storage). Only the ids of the site's own messages are + * fetched, so the route is never a proxy for anything else. + */ +import fs from 'node:fs/promises'; +import path from 'node:path'; +import type { Ctx } from '../context.js'; +import { defaultUploadDir } from '../demo/demoChurch.js'; +import { youtubeId } from './content.js'; + +export { thumbnailPath } from './content.js'; +export type Fetcher = (url: string) => Promise; + +const ID = /^[A-Za-z0-9_-]{6,20}$/; +const MAX_BYTES = 1024 * 1024; + +const cacheDir = (ctx: Ctx) => path.join(path.resolve(ctx.config.uploadDir ?? defaultUploadDir()), '.thumbnails'); + +const defaultFetcher: Fetcher = (url) => fetch(url, { signal: AbortSignal.timeout(10_000) }); + +/** One fetch per video at a time, however many visitors ask at once. */ +const inFlight = new Map>(); + +async function isOurVideo(ctx: Ctx, videoId: string) { + const rows = await ctx.db.message.findMany({ where: { mediaUrl: { contains: videoId } }, select: { mediaUrl: true, source: true }, take: 5 }); + return rows.some((m) => m.source !== 'spotify' && youtubeId(m.mediaUrl) === videoId); +} + +async function download(fetcher: Fetcher, videoId: string): Promise { + try { + const res = await fetcher(`https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`); + if (!res.ok || !/^image\/jpe?g/.test(res.headers.get('content-type') ?? '')) return null; + const body = Buffer.from(await res.arrayBuffer()); + // A JPEG by its bytes, and a sensible size. + if (body.length > MAX_BYTES || body.length < 3 || body[0] !== 0xff || body[1] !== 0xd8 || body[2] !== 0xff) return null; + return body; + } catch { + return null; + } +} + +/** The thumbnail's bytes, from the cache or YouTube; null when it isn't one of the site's videos or YouTube has none. */ +export async function thumbnail(ctx: Ctx, videoId: string, fetcher: Fetcher = ctx.fetch ?? defaultFetcher): Promise { + if (!ID.test(videoId)) return null; + const file = path.join(cacheDir(ctx), `${videoId}.jpg`); + try { + return await fs.readFile(file); + } catch { + // Not cached yet. + } + if (!(await isOurVideo(ctx, videoId))) return null; + let pending = inFlight.get(videoId); + if (!pending) { + pending = (async () => { + const body = await download(fetcher, videoId); + if (body) { + await fs.mkdir(path.dirname(file), { recursive: true }); + const tmp = `${file}.${process.pid}.tmp`; + await fs.writeFile(tmp, body); + await fs.rename(tmp, file); + } + return body; + })().finally(() => inFlight.delete(videoId)); + inFlight.set(videoId, pending); + } + return pending; +} diff --git a/apps/website/backend/tests/site.test.ts b/apps/website/backend/tests/site.test.ts index e0d8d9c..c658f6d 100644 --- a/apps/website/backend/tests/site.test.ts +++ b/apps/website/backend/tests/site.test.ts @@ -10,6 +10,7 @@ import { 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'; +import { thumbnail } from '../src/site/thumbnails.js'; import { defaultDesign } from '../src/site/variants.js'; import { harness } from './support/harness.js'; @@ -137,6 +138,60 @@ describe('the public site\'s content', () => { }); }); +describe("the messages' thumbnails, served from the site (§7)", () => { + const jpeg = Buffer.from([0xff, 0xd8, 0xff, 0xe0, 1, 2, 3]); + const youtube = (body: Buffer | string, type = 'image/jpeg', status = 200) => { + const asked: string[] = []; + const fetcher = async (url: string) => { asked.push(url); return new Response(typeof body === 'string' ? body : new Uint8Array(body), { status, headers: { 'content-type': type } }); }; + return { asked, fetcher }; + }; + + it("gives visitors the site's own address, never YouTube's", async () => { + const dir = tmp(); + const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } }); + 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'); + }); + + it("fetches a message's thumbnail once and keeps it; nothing for a video that isn't the site's", async () => { + const dir = tmp(); + const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } }); + await loadDemo(h.ctx, 'heritage', { uploadDir: dir }); + const yt = youtube(jpeg); + assert.deepEqual(await thumbnail(h.ctx, 'aqz-KE-bpKQ', yt.fetcher), jpeg); + assert.deepEqual(await thumbnail(h.ctx, 'aqz-KE-bpKQ', yt.fetcher), jpeg); + assert.deepEqual(yt.asked, ['https://i.ytimg.com/vi/aqz-KE-bpKQ/hqdefault.jpg']); + assert.ok(fs.existsSync(path.join(dir, '.thumbnails', 'aqz-KE-bpKQ.jpg'))); + // Kept out of /api/uploads (a dot folder). + assert.ok([403, 404].includes((await request(h.app).get('/api/uploads/.thumbnails/aqz-KE-bpKQ.jpg')).status)); + // Not one of the site's messages, or not an id: YouTube isn't asked. + assert.equal(await thumbnail(h.ctx, 'someoneElse1', yt.fetcher), null); + assert.equal(await thumbnail(h.ctx, '../../etc/x', yt.fetcher), null); + assert.equal(yt.asked.length, 1); + }); + + it("keeps nothing that isn't a JPEG, and says 404 when YouTube has none", async () => { + const dir = tmp(); + const h = await harness({ linked: false, env: { UPLOAD_DIR: dir } }); + await loadDemo(h.ctx, 'heritage', { uploadDir: dir }); + assert.equal(await thumbnail(h.ctx, 'aqz-KE-bpKQ', youtube('', 'text/html').fetcher), null); + assert.equal(await thumbnail(h.ctx, 'aqz-KE-bpKQ', youtube(Buffer.from('GIF89a'), 'image/jpeg').fetcher), null); + assert.equal(await thumbnail(h.ctx, 'aqz-KE-bpKQ', youtube('', 'image/jpeg', 404).fetcher), null); + assert.ok(!fs.existsSync(path.join(dir, '.thumbnails', 'aqz-KE-bpKQ.jpg'))); + h.ctx.fetch = youtube('', 'image/jpeg', 404).fetcher; + const missing = await request(h.app).get('/api/thumbnails/aqz-KE-bpKQ.jpg'); + assert.equal(missing.status, 404); + assert.equal(missing.headers['cache-control'], 'no-store'); + h.ctx.fetch = youtube(jpeg).fetcher; + const ok = await request(h.app).get('/api/thumbnails/aqz-KE-bpKQ.jpg'); + assert.equal(ok.status, 200); + assert.equal(ok.headers['content-type'], 'image/jpeg'); + assert.equal((await request(h.app).get('/api/thumbnails/aqz-KE-bpKQ.png')).status, 404); + }); +}); + describe('message links', () => { it('finds YouTube ids and Spotify embeds', () => { assert.equal(youtubeId('https://www.youtube.com/watch?v=aqz-KE-bpKQ'), 'aqz-KE-bpKQ'); diff --git a/apps/website/e2e/server.ts b/apps/website/e2e/server.ts index b406130..d9d5e7e 100644 --- a/apps/website/e2e/server.ts +++ b/apps/website/e2e/server.ts @@ -13,12 +13,13 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import express from 'express'; import pg from 'pg'; +import sharp from 'sharp'; import { PrismaPg } from '@prisma/adapter-pg'; import { websiteTemplateSchema } from '@crosscode/contracts'; import { PrismaClient } from '../backend/src/generated/prisma/client.js'; import { createApp } from '../backend/src/app.js'; import { createCtx } from '../backend/src/context.js'; -import { loadDemo } from '../backend/src/demo/demoChurch.js'; +import { illustration, loadDemo } from '../backend/src/demo/demoChurch.js'; import { loadConfig } from '../backend/src/lib/config.js'; import { hashToken } from '../backend/src/lib/crypto.js'; import { publish } from '../backend/src/site/snapshot.js'; @@ -55,7 +56,13 @@ async function freshPostgres(url: string) { // A frozen clock (a Monday morning), so the demo's dates, and so the screenshots, are the same every // run (variants.spec.ts). E2E_NOW changes it. const frozen = new Date(process.env.E2E_NOW ?? '2026-11-23T06:00:00Z'); -const ctx = createCtx(loadConfig({ WEBSITE_URL: 'http://localhost:3310', NODE_ENV: 'test', JOBS_ENABLED: 'false', HUB_URL: 'http://127.0.0.1:1', UPLOAD_DIR: uploads, TRUST_PROXY: 'true' }), db as never, { now: () => new Date(frozen) }); +// YouTube's thumbnails (site/thumbnails.ts) without the network: one of the demo's illustrations, +// as a JPEG the size of YouTube's, for every video. +const thumb = await sharp(Buffer.from(illustration(4, 480, 360))).jpeg().toBuffer(); +const fakeYoutube = async (url: string) => url.startsWith('https://i.ytimg.com/') + ? new Response(new Uint8Array(thumb), { headers: { 'content-type': 'image/jpeg' } }) + : new Response('not here', { status: 404 }); +const ctx = createCtx(loadConfig({ WEBSITE_URL: 'http://localhost:3310', NODE_ENV: 'test', JOBS_ENABLED: 'false', HUB_URL: 'http://127.0.0.1:1', UPLOAD_DIR: uploads, TRUST_PROXY: 'true' }), db as never, { now: () => new Date(frozen), fetch: fakeYoutube }); await loadDemo(ctx, websiteTemplateSchema.parse(process.env.DEMO_TEMPLATE ?? 'heritage'), { uploadDir: uploads }); const app = express(); diff --git a/apps/website/e2e/templates.spec.ts b/apps/website/e2e/templates.spec.ts index 9966341..2d68fa6 100644 --- a/apps/website/e2e/templates.spec.ts +++ b/apps/website/e2e/templates.spec.ts @@ -64,6 +64,19 @@ test("the home page has the church's JSON-LD; unknown pages are a real 404", asy expect((await page.goto("/no-such-page"))?.status()).toBe(404); }); +test("the messages ask nothing of YouTube until play is clicked; their thumbnails come from the site", async ({ page }) => { + await useTemplate(page, "heritage"); + const outside: string[] = []; + page.on("request", (r) => { if (/youtube|ytimg|spotify/.test(new URL(r.url()).hostname)) outside.push(r.url()); }); + await page.goto("/messages"); + const thumb = page.locator("main img").first(); + await expect(thumb).toHaveAttribute("src", /^\/api\/thumbnails\/[\w-]+\.jpg$/); + await expect.poll(() => thumb.evaluate((i: HTMLImageElement) => i.naturalWidth)).toBeGreaterThan(0); + await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight)); + await page.waitForLoadState("networkidle"); + expect(outside).toEqual([]); +}); + test("robots.txt keeps the admin out; the sitemap lists the pages", async ({ page }) => { const robots = await (await page.request.get("/robots.txt")).text(); expect(robots).toContain("Disallow: /admin"); diff --git a/apps/website/e2e/variants.spec.ts b/apps/website/e2e/variants.spec.ts index 683a033..3d71e79 100644 --- a/apps/website/e2e/variants.spec.ts +++ b/apps/website/e2e/variants.spec.ts @@ -10,7 +10,7 @@ * (`npx playwright test variants --update-snapshots`, then look through them), and the next * release's run shows every section that changed. The e2e server freezes the clock (E2E_NOW), so * the demo's dates never change between runs. What comes from outside is masked: the video, the - * map (OpenStreetMap) and YouTube's thumbnails. + * map (OpenStreetMap) and the messages' thumbnails. */ import AxeBuilder from "@axe-core/playwright"; import { expect, test, type Page } from "@playwright/test"; @@ -43,6 +43,23 @@ async function loadImages(page: Page) { expect(broken, "images that didn't load").toEqual([]); } +/** + * A section's screenshot is as big as its box, rounded where it starts and ends on the page. With + * fractional heights above it (text, aspect ratios), the same section came out a pixel taller or + * shorter from run to run, which fails `toHaveScreenshot` however small the difference. So the + * header and every section get their own height rounded up first: each section then starts on a + * whole pixel and is the same size every run. + */ +async function wholePixels(page: Page) { + await page.evaluate(() => { + // The header and the sections, not what holds them (main grows to fit). + const blocks = Array.from(document.querySelectorAll("header:not(main header), main > section")); + for (const b of blocks) b.style.height = ""; + const heights = blocks.map((b) => b.getBoundingClientRect().height); + blocks.forEach((b, n) => { if (getComputedStyle(b).position !== "fixed") b.style.height = `${Math.ceil(heights[n]!)}px`; }); + }); +} + for (const template of TEMPLATES) { test.describe(`${template} variants`, () => { test.beforeAll(async ({ request }) => { @@ -67,8 +84,9 @@ for (const template of TEMPLATES) { for (const [name, size] of WIDTHS) { await page.setViewportSize(size); await loadImages(page); + await wholePixels(page); await expect(section).toHaveScreenshot(`${template}-${type}-${variant}-${name}.png`, { - mask: [page.locator("main video"), page.locator("main [data-map]"), page.locator('main img[src*="ytimg.com"]')], + mask: [page.locator("main video"), page.locator("main [data-map]"), page.locator('main img[src*="/api/thumbnails/"]')], animations: "disabled", maxDiffPixelRatio: 0.01, }); diff --git a/apps/website/frontend/package.json b/apps/website/frontend/package.json index ddc6763..486f583 100644 --- a/apps/website/frontend/package.json +++ b/apps/website/frontend/package.json @@ -1,6 +1,6 @@ { "name": "@crosscode/website-frontend", - "version": "1.0.0", + "version": "1.0.1", "private": true, "description": "Church Website: the church's public site in its template, and the admin", "scripts": { diff --git a/apps/website/frontend/src/site/MessagePlayer.tsx b/apps/website/frontend/src/site/MessagePlayer.tsx index b5c5a6a..64e394a 100644 --- a/apps/website/frontend/src/site/MessagePlayer.tsx +++ b/apps/website/frontend/src/site/MessagePlayer.tsx @@ -4,7 +4,8 @@ import { useState } from "react"; /** * A message's video or audio, loaded only when clicked (WEBSITE-1.0-PLAN §7): a thumbnail first, - * then youtube-nocookie or Spotify's player. Nothing loads from YouTube or Spotify until then. + * then youtube-nocookie or Spotify's player. Nothing loads from YouTube or Spotify until then: the + * thumbnail is served by the site (`/api/thumbnails/.jpg`, backend site/thumbnails.ts). */ /** `priority`: the first thing on screen (the messages page's first message), so its thumbnail isn't lazy (it's the LCP image). */ export function MessagePlayer({ title, embedUrl, thumbnail, url, source, className, priority }: { title: string; embedUrl: string | null; thumbnail: string | null; url: string; source: "youtube" | "spotify"; className?: string; priority?: boolean }) { diff --git a/apps/website/frontend/src/site/PageView.tsx b/apps/website/frontend/src/site/PageView.tsx index 5698920..914b934 100644 --- a/apps/website/frontend/src/site/PageView.tsx +++ b/apps/website/frontend/src/site/PageView.tsx @@ -2,7 +2,7 @@ * A page other than home (WEBSITE-1.0-PLAN §6): its title, what its kind lists (ministries, * leaders, events, messages, contact details), then its blocks. */ -import { preconnect } from "react-dom"; +import { preload } from "react-dom"; import { MessagePlayer } from "./MessagePlayer"; import { t } from "./load"; import { cx, DateBadge, dayName, fmtDate, Img, Paragraphs } from "./parts"; @@ -70,10 +70,10 @@ function Listing({ page, site }: { page: Page; site: Published }) { ); case "messages": { - // The first thumbnail is the largest thing on screen (Lighthouse's LCP): connect to its host - // straight away rather than once the HTML has been read. + // The first thumbnail is the largest thing on screen (Lighthouse's LCP): ask for it from the + // , rather than once the HTML has been read. Thumbnails come from the site itself. const thumb = site.messages[0]?.thumbnail; - if (thumb?.startsWith("https://")) preconnect(new URL(thumb).origin); + if (thumb) preload(thumb, { as: "image", fetchPriority: "high" }); return (
diff --git a/apps/website/frontend/src/site/meta.ts b/apps/website/frontend/src/site/meta.ts index d4e9d71..4cba03a 100644 --- a/apps/website/frontend/src/site/meta.ts +++ b/apps/website/frontend/src/site/meta.ts @@ -90,7 +90,7 @@ export function messagesLd(site: Published, messages: SiteMessage[]): string | n const description = [m.speaker, m.passage, m.series].filter(Boolean).join(" · ") || m.title; return m.source === "spotify" ? { "@type": "PodcastEpisode", name: m.title, datePublished: m.date.slice(0, 10), description, url: m.url } - : { "@type": "VideoObject", name: m.title, uploadDate: m.date, description, ...(m.thumbnail ? { thumbnailUrl: [m.thumbnail] } : {}), ...(m.embedUrl ? { embedUrl: m.embedUrl.replace("?autoplay=1", "") } : {}), contentUrl: m.url }; + : { "@type": "VideoObject", name: m.title, uploadDate: m.date, description, ...(m.thumbnail ? { thumbnailUrl: [abs(site, m.thumbnail)] } : {}), ...(m.embedUrl ? { embedUrl: m.embedUrl.replace("?autoplay=1", "") } : {}), contentUrl: m.url }; }), }); } diff --git a/apps/website/frontend/src/site/sections/index.tsx b/apps/website/frontend/src/site/sections/index.tsx index 6e471fb..9884aad 100644 --- a/apps/website/frontend/src/site/sections/index.tsx +++ b/apps/website/frontend/src/site/sections/index.tsx @@ -301,7 +301,8 @@ function Events(p: SectionProps) { {list.map((e) => (
  • {fmtDate(e.startsAt, zone, { day: "numeric" })}

    -

    {fmtDate(e.startsAt, zone, { month: "long", weekday: "short" })}

    + {/* A weekday and month without a day is "Sun (month: November)" to Intl: two parts. */} +

    {fmtDate(e.startsAt, zone, { weekday: "short" })} · {fmtDate(e.startsAt, zone, { month: "long" })}

    {e.title}

    {!e.allDay &&

    {fmtTime(e.startsAt, zone)}

    }
  • diff --git a/docs/HANDOVER.md b/docs/HANDOVER.md index 4c8e76f..90ed1c3 100644 --- a/docs/HANDOVER.md +++ b/docs/HANDOVER.md @@ -105,24 +105,18 @@ out"). and deployed 2026-11-25; the plan said 2.13.0) → ~~`website@1.0.0`~~ (released 2026-11-26, with `contracts@1.18.0` and Hub `v2.22.0`, deployed 2026-11-26; the release checks are in WEBSITE-1.0-PLAN §13, "Where they are"; the VM test was skipped, so watch the first install - closely) → **Hope Family Church**: roll out Accounts 1.7.0 and Events 3.7.0 first (neither is - rolled out yet), then New install → Website → a second church on a different template → - crosscode-site 1.7.0 (the Website on sale; prices in the site and the Hub together, below). - The variants and Lighthouse suites were run again on the release build on 2026-11-26 (WEBSITE-1.0-PLAN - §13, "Where they are"): every variant passes axe and all 104 have screenshot baselines now (the 37 there - were matched; 67 taken), and Lighthouse passed 11 of 12 pages (Heritage's messages 89). - Loose ends: - - **Look through the 67 new baselines** (Bold from Ministries on, Community, Clean) before they - count as right: they were taken, not compared. - - **Calendar events show "SUN (MONTH: NOVEMBER)"** on every template: `{ month: "long", - weekday: "short" }` without a day is what `Intl` prints that way (`sections/index.tsx`, the - Calendar variant). A fix for `website@1.0.1`; the four Calendar baselines change with it. - - **The message thumbnails load from YouTube** (`i.ytimg.com`) with the page, though plan §7 and - MessagePlayer's comment say nothing loads from YouTube before a click. Heritage's messages page - missed Lighthouse by its LCP, which is that thumbnail (3.0 s). Serving thumbnails from the site - would answer both. + closely) → ~~`website@1.0.1`~~ (released 2026-11-26: the messages' thumbnails served from the + site, the Calendar dates; VERSIONS.md) → **Hope Family Church**: roll out Accounts 1.7.0 and + Events 3.7.0 first (neither is rolled out yet), then New install → Website (1.0.1) → a second + church on a different template → crosscode-site 1.7.0 (the Website on sale; the Hub already + has its prices, 2.21.0). + The release checks are all run on 1.0.1's build (WEBSITE-1.0-PLAN §13, "Where they are"): every + variant passes axe, the 312 screenshots have baselines (taken again with whole-pixel section + heights), Lighthouse passes 12 of 12. Still to do: + - **Look through the variant baselines** once (the contact sheet: Bold, Community and Clean were + taken, not compared, the first time). A section drawn wrong there is the reference until then. - **The VM test was skipped**: before Hope Family Church, a throwaway install from the Hub (New - install → Website, update it, uninstall with its export) in its place. + install → Website 1.0.0, update it to 1.0.1, uninstall with its export) in its place. Done (confirmed by Joshua 2026-11-25): `hope-events` is archived, and every FastPanel site set up before Hub 2.10.0, and the Hub's own site, has `location ^~ /api/`. diff --git a/docs/VERSIONS.md b/docs/VERSIONS.md index 6bfcb9f..a7f21b1 100644 --- a/docs/VERSIONS.md +++ b/docs/VERSIONS.md @@ -1,6 +1,6 @@ # Versions — the latest release of everything -Last updated: 2026-11-25. Taken from the git tags, which is what a release is here (branch → merge → +Last updated: 2026-11-26. Taken from the git tags, which is what a release is here (branch → merge → tag → push, see [HANDOVER.md](./HANDOVER.md) "Releasing"). **Update this file with every release.** "Released" means tagged and pushed. Whether a release is **deployed** or rolled out is recorded @@ -11,7 +11,7 @@ separately below; the two often differ. | What | Repo | Latest | Tag | Released | |------|------|--------|-----|----------| | Cross Events | `crosscode-platform` (`apps/events`) | **3.7.0** | `events@3.7.0` | 2026-11-24 | -| Church Website | `crosscode-platform` (`apps/website`) | **1.0.0** | `website@1.0.0` | 2026-11-26 | +| Church Website | `crosscode-platform` (`apps/website`) | **1.0.1** | `website@1.0.1` | 2026-11-26 | | Accounts | `crosscode-platform` (`apps/accounts`) | **1.7.0** | `accounts@1.7.0` | 2026-11-24 | | Server agent | `crosscode-platform` (`apps/agent`) | **1.5.0** | `agent@1.5.0` | 2026-11-23 | | Contracts | `crosscode-platform` (`packages/contracts`) | **1.18.0** | `contracts@1.18.0` | 2026-11-25 | @@ -30,7 +30,7 @@ on each run, so merging to `main` and pushing releases it. Its changes are liste | `@crosscode/auth-client` | `packages/auth-client` | 1.1.0 (released with Events 3.0.0 and Accounts 1.1.0) | | `@crosscode/seo` | `packages/seo` | 1.0.0 (released with Events 2.4.0) | | `@crosscode/ui` | `packages/ui` | 0.3.0 (fonts, `ChurchFooter`; 0.2.0 with Accounts 1.7.0, 0.3.0 with Events 3.7.0) | -| Website | `apps/website` | 1.0.0 (released 2026-11-26; not installed for a church yet: Hope Family Church first, after Accounts 1.7.0 and Events 3.7.0 are rolled out) | +| Website | `apps/website` | 1.0.1 (1.0.0 and 1.0.1 released 2026-11-26; not installed for a church yet: Hope Family Church first, after Accounts 1.7.0 and Events 3.7.0 are rolled out) | | App | `apps/app` | 0.0.0 (not started, phase 6) | These shared packages ship inside the apps that use them, from the same checkout, so they don't @@ -38,6 +38,15 @@ need their own tags until something outside this repo depends on them. ## What each latest release was for +- **Church Website 1.0.1 (2026-11-26):** the messages' YouTube thumbnails are served from the site + (`/api/thumbnails/.jpg`, fetched once by the backend and kept in `uploads/.thumbnails/`), so a + visitor asks nothing of YouTube until pressing play (plan §7); the Calendar events' dates read + "Sun · November", not "Sun (month: November)". No migration. Checked: the backend tests (97), + the whole e2e suite on the release build (Lighthouse 12 of 12, performance 90–100: Heritage's + messages from 89 to 95), the 312 variant screenshots (taken again with whole-pixel section heights, + which ended a one-pixel flake), and an e2e check that the messages page makes no request to + YouTube or Spotify before a click. The `crosscode` script's Website export leaves out + `uploads/.thumbnails`. **Not installed for a church yet.** - **Church Website 1.0.0 (2026-11-26):** the first release (WEBSITE-1.0-PLAN): four templates with section variants and style settings, drafts, preview and one Publish, people and roles, messages from YouTube, simple events and the event feed, church details through Accounts, SEO, Get more diff --git a/docs/WEBSITE-1.0-PLAN.md b/docs/WEBSITE-1.0-PLAN.md index f81fdba..f252603 100644 --- a/docs/WEBSITE-1.0-PLAN.md +++ b/docs/WEBSITE-1.0-PLAN.md @@ -545,6 +545,15 @@ between 1169 and 2542 in one run, so a score within a few points of 90 is worth it counts as a regression. Found in the screenshots: the Calendar events variant prints the date as "Sun (month: November)" (for `website@1.0.1`). +**On 1.0.1 (2026-11-26):** the whole suite, `npx playwright test` (129 tests, 34.6 minutes): the admin +flows, every template's pages, Lighthouse 12 of 12 (performance 90–100; Heritage's messages 95, the +thumbnail now from the site), and a new check that the messages page asks nothing of YouTube or +Spotify before play. Seven variant screenshots failed by a pixel of height in that run and passed +when run again: a section starting at a fractional position came out 534 or 535 pixels tall. +`variants.spec.ts` now rounds the header's and each section's height up before the screenshot +(`wholePixels`), and the 312 baselines were taken again with it (113 came out the same), then +compared in a second full run of the variants. + ## 14. Releasing and rolling it out 1. `contracts@1.17.0`, then `accounts@1.7.0` (the profile's brand style), then `events@3.7.0`. diff --git a/package-lock.json b/package-lock.json index fd2a08f..851339c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -360,7 +360,7 @@ }, "apps/website/backend": { "name": "@crosscode/website-backend", - "version": "1.0.0", + "version": "1.0.1", "hasInstallScript": true, "dependencies": { "@crosscode/auth-client": "*", @@ -387,7 +387,7 @@ }, "apps/website/frontend": { "name": "@crosscode/website-frontend", - "version": "1.0.0", + "version": "1.0.1", "dependencies": { "@crosscode/contracts": "*", "@crosscode/seo": "*", diff --git a/scripts/products/website.sh b/scripts/products/website.sh index 42e214b..07f78f7 100644 --- a/scripts/products/website.sh +++ b/scripts/products/website.sh @@ -98,7 +98,8 @@ website_copy_uploads() { local uploads uploads="$(website_app "$1")/backend/uploads" mkdir -p "$2" - [ ! -d "$uploads" ] || rsync -a "$uploads/" "$2/" + # .thumbnails is the messages' YouTube thumbnails kept by the site (fetched again), not the church's. + [ ! -d "$uploads" ] || rsync -a --exclude .thumbnails "$uploads/" "$2/" } # What uninstall keeps for 30 days: the backups and the .env (its WEBSITE_SECRET decrypts what's stored).