Skip to content

feat(calendar): serve the advent calendar at /calendrier with an admin - #50

Merged
maxitect merged 12 commits into
mainfrom
feat/29-advent-calendar-live-at-calendrier-by-1-december
Nov 13, 2026
Merged

maxitect merged 12 commits into
mainfrom
feat/29-advent-calendar-live-at-calendrier-by-1-december

Conversation

@maxitect

@maxitect maxitect commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

What

Loïc's advent calendar now lives at /calendrier, with its doors, demos and look editable from the Payload admin. Built on Payload from #33 (the ticket still names #32).

Changes

  • Page. Loïc's HTML, CSS and script are split into src/app/(calendar)/calendrier/_page/ and rendered by a React page with its own root layout. Design is unchanged: at default settings the page is pixel-identical to the original (0 differing pixels, 1280 and 390 wide, closed and opened doors).
  • Admin. New calendar-doors collection (day 1 to 24, localised title and note, MP3, optional colour and image) and calendar-settings global (behaviour, localised texts, five named colours with a picker, door colours, three font lists, background and share images). Two migrations: generated tables, then CHECK constraints on the day and the opening hour (registered in database.md).
  • Colours. Every colour on the page that was hard-coded is now an exact OKLCH shift of paper, ink or orange (defaults reproduce the original hex values), so one setting moves them all.
  • Fonts. 16 fonts through next/font with no preload; only the three selected are requested. font-synthesis: none stops faked bold or italic.
  • Endpoints. /api/calendar (open doors, Paris time), /api/calendar/preview (members, all 24), /api/calendar/audio/[day] (date check on every request, streams from the private demos bucket through Payload's own range-aware handler, no signed URL, nothing public). Demo files are not readable through /api/calendar-doors: that collection is members-only.
  • Hidden / ended. visible off, or afterEnd = holding after 24 December, gives visitors a holding page and 404 on both endpoints; members keep the preview.
  • Language. Same rule as the site: ?isFrench=true|false, else the browser language. Every string of the page exists in French and English; the editable ones are localised in the admin.
  • No DATABASE_URL. /calendrier is rewritten to 404 like /admin and /api/*; the build passes without it.
  • CSP (Security hardening: headers, CMS URLs, email and account settings #34). calendrier entry added to routePolicies.
  • Guide. docs/admin-guide.md has a calendar section for Loïc.

Acceptance criteria

AC Result Method Evidence
Colour, title, font, background image change on the page within a minute, no deploy PASS api, browser AC1
Defaults look the same as the ChatGPT version PASS browser AC2
orange setting changes every orange PASS browser AC3
A colour field rejects a non-colour PASS api AC4
Every font renders the French accents; no faked italic PASS with one gap browser AC5
Only the selected fonts are downloaded PASS browser AC6
Site language switches the calendar's texts PASS browser AC7
"Visible" off: holding page, no endpoint answers, members keep the preview PASS browser, api AC8
clarksbowlingclub.com/calendrier matches on mobile and desktop After merge deploy Post-merge steps; preview in AC9
Loïc signs in, uploads a demo, hears it in the preview PASS browser, deploy AC10
Day N: doors 1 to N play, door N+1 is 403 or 404 PASS api AC11
No demo reachable at a guessable URL or without the date check PASS api AC12
An opened door stays opened on return PASS browser AC13
A replaced demo is the one visitors hear PASS api AC14
Main site pages load and the contact form works PASS browser, mail AC15
CSP: /calendrier, endpoints and preview show no violations (#34) PASS browser AC16

Closes

Closes #29

Notes

Deviations and decisions

  • New dependency: @payloadcms/ui 3.93.0 (already in the lockfile through @payloadcms/next). The colour picker needs useField, and pnpm does not expose a transitive package. Same version as Payload.
  • Blanch Caps lacks œ and ’ (the site's own font file). The stack falls back to Bebas Neue for those two characters, so Bebas is only requested if one appears. A replacement font file would fix it properly.
  • Visible starts off. Visitors get the holding page until the band turns the calendar on; AC2's "defaults" means every look setting at its default with Visible on.
  • Door 4's default brown is derived from ink, not orange, so it does not follow the orange setting.
  • Preview-mode texts no longer say "album Prises"; they now say "private preview for the band". The /api/calendar response adds open, member and ?v= on the audio URL (cache-busting for replaced demos); the download link uses &download=1 accordingly.
  • Freshness. Admin saves expire the calendar-settings tag and the cache lifetime is capped at 50 seconds. In dev the first request after a save can still serve the old page for a few seconds.
  • Not done / open questions from the ticket. No navigation link (proposed for 1 December). After 24 December the default is "stay up with all doors open"; switch it under Behaviour.
  • MP3 upload size. Netlify rejected an 8 MB upload through the function with 413, so the demos plugin uses Payload clientUploads: the browser PUTs the file straight to the bucket with a presigned URL. That needs a CORS rule on the bucket (post-merge step 2). Playing a demo goes through the function with range support: an 8 MB demo streamed in full and by range on the deploy preview.
  • Security hardening: headers, CMS URLs, email and account settings #34 CSP. Base policy already covers the page, so the calendrier entry has empty extras. What /calendrier needs: inline <style> and <script> ('unsafe-inline'), fonts from 'self' (next/font, no Google at runtime), audio from 'self' (/api/calendar/audio/*; the opening sound is a data: MP3 decoded in memory, no fetch), door and background images from the storage origin (img-src). connect-src 'self' covers its fetch. The page sets document.cookie (Path=/calendrier).

Post-merge steps (production)

Production already has DATABASE_URL, PAYLOAD_SECRET, the S3_* variables and the band admin account. The production build runs payload migrate, which applies the two new migrations on top of 20261112_223859_initial.

  1. Create the private bucket on Neon main before anyone uploads a demo: NEON_PROFILE=tandem neon buckets create demos --branch main (private is the default). No new environment variable: the bucket name defaults to demos (S3_DEMOS_BUCKET overrides it).
  2. Allow browser uploads to the demos bucket on main: a CORS rule with AllowedMethods: ["PUT"], AllowedHeaders: ["*"], ExposeHeaders: ["ETag"] and AllowedOrigins set to https://clarksbowlingclub.com (add https://www.clarksbowlingclub.com if it serves the site). For example, with the main branch's storage credentials in AWS_*: aws s3api put-bucket-cors --bucket demos --endpoint-url "$S3_ENDPOINT" --cors-configuration '{"CORSRules":[{"AllowedMethods":["PUT"],"AllowedOrigins":["https://clarksbowlingclub.com"],"AllowedHeaders":["*"],"ExposeHeaders":["ETag"],"MaxAgeSeconds":3600}]}'. Without it, uploads from the admin fail in the browser.
  3. Sign in at /admin, create the 24 doors, check Calendar settings, then open /calendrier signed in and use Mode test. Visible is off by default, so visitors get the holding page until the band ticks it and saves.
  4. Check /calendrier on the live site on mobile and desktop.
  5. Decide on the navigation link and on what happens after 24 December.

Review

Verdict: ALL CLEAR
Rounds: 2

Finding Severity Resolution
20261112_232319_calendar down fails: the locked-documents FK is dropped after DROP TABLE … CASCADE already removed it warning fixed in c09e234
"Visible" defaulted on: right after merge /calendrier would be public before the band is ready warning fixed in 6b95bf2
Blanch Caps has no œ or ’; those two glyphs render in Bebas Neue suggestion open: accepted, the characters render correctly in a matching condensed face; a full fix needs a new font file

Re-verified: migrations (db, Neon preview reset to production's state: initial + imported content, no dev row) up PASS, down PASS, up again PASS · AC8 (api, browser) PASS: unsaved settings give visible:false, visitor /calendrier holding page with noindex, /api/calendar 404, /api/calendar/audio/1 404, /api/calendar/preview 403, member preview 200 · AC11 (code run of getCalendarDay) PASS at 30 Nov 23:00Z, opening hours 0/8/23 and 24–25 Dec · AC12 (api) PASS: /api/calendar-doors and /file/01.mp3 403, direct demos bucket URL 403 with the object present, signed-URL endpoint 403 signed out · missing demos bucket: member audio 404, no 500 · AC16 (browser) PASS: no console violations on /calendrier (visitor, member, Mode test) or the admin colour picker · check.sh PASS

Evidence

Local runs use the Neon dev branch; the clock-dependent checks run with the server's Date shifted to 10 December 2026, 12:00 Paris.

AC1

PUT /api/globals/calendar-settings  {"texts":{"title":"Le Grand Calendrier","accentLine":"de la bande"}} (fr)
fr h1: Le Grand Calendrier <em>de la bande</em>
fonts title/accent/body = monoton / lobster / outfit -> computed Monoton, Lobster (font-style normal), Outfit
colors.orange = #0000ff -> --orange:#0000ff in the served page
background css: url("https://…storage…/media/bg.png") center/cover
og:image: https://…storage…/media/share.png

Saving fires revalidateTag("calendar-settings"); cache lifetime is capped at 50 s.

AC2

node compare.mjs   (original page and this page, same mocked doors, Chromium, reduced motion)
desktop-closed 1280x1593 differing pixels: 0
desktop-open   1280x1907 differing pixels: 0
mobile-closed  390x1817  differing pixels: 0
mobile-open    390x2261  differing pixels: 0

AC3

computed colour scan of every element and ::before/::after, orange = default:
  #b95635:2 #e7a45d:2 #a74628:2 #f1b158:3 #a23c20:54 #a54425:3 #f1ca8e:9 #ecaa53:3 #e8a98d:10 #763a31:2 #dcb497:10 #573123:2 #efbd8c:8 #ffce85:1 #e79a58:1
orange = #0000ff:
  old shades still present: {"#573123":2}      (door 4 brown, derived from ink)
code: grep -En '#[0-9a-fA-F]{3,8}\b' "src/app/(calendar)/calendrier/_page/styles.ts"  -> no match

AC4

colors.orange="red"            -> 400 "Must be a colour such as #a23c20 (3, 4, 6 or 8 hex digits)"
colors.orange="#12345"         -> 400 same
doorColors[0].door="nope"      -> 400 same
colors.orange="#0000ff"        -> 200

AC5

glyph test (é è ç œ ’ É È Ç Œ, normal and italic faces, canvas width against two fallbacks; detector control OK)
Fraunces ok | DM Serif Display ok | Playfair Display ok | Caprasimo ok | Abril Fatface ok | Shrikhand ok
Alfa Slab One ok | Righteous ok | Monoton ok | Bebas Neue ok | Damion ok | Yellowtail ok | Lobster ok
Jost ok | DM Sans ok | Outfit ok | Goudy Heavyface ok
Blanch Caps  missing: œ ’   (font file; Bebas Neue fallback, see Notes)
accent = lobster -> computed font-style: normal (no italic faked); accent = fraunces -> italic, real italic face loaded
font-synthesis on h1, h1 em, .number, .gift h2: none

AC6

defaults (Georgia, system):          font file requests: 0
fraunces x3:   loaded: Fraunces italic, Fraunces normal      requests: 2
monoton / lobster / outfit:  loaded: Monoton, Lobster, Outfit   requests: 3
(74 font faces declared in the CSS, only the used ones are fetched)

AC7

/calendrier?isFrench=false  h1: The Big Calendar <em>by the band</em>   LANG="en"   <title>Advent calendar by Clark's
/calendrier?isFrench=true   h1: Le Grand Calendrier <em>de la bande</em>
status line: "The first door opens on 1 December." / "La première case s’ouvrira le 1ᵉʳ décembre."

AC8

visible=false
visitor /api/calendar: 404   /api/calendar/audio/1: 404   /api/calendar/preview: 403
visitor page: "Clark’s Bowling Club Calendrier de Clark's Le calendrier de l’Avent revient bientôt. …"  #calendar grid: false
member: 24 enabled doors in preview, "Mode test actif. Les 24 cases sont disponibles…", audio/24: 200
afterEnd=holding with the year in the past: /api/calendar 404, audio/24 404; afterEnd=open: 24 doors, audio/24 200

AC9

Production is not reachable from a branch; checked on the deploy preview https://deploy-preview-50--clarksbowlingclub.netlify.app instead (390 px, English, screenshot taken; the layout matches the local one):

GET /calendrier?isFrench=true -> 200, Content-Security-Policy present
GET /api/calendar -> {"year":2026,"today":0,"open":true,"member":false,"doors":[]}
visitor mobile en h1: Advent calendar by Clark's | status: The first door opens on 1 December.

AC10

visitor: 10 enabled doors of 24, preview tools hidden: true
member (signed-in): preview tools visible, Mode test -> 24 enabled doors
member door 24: {"src":"/api/calendar/audio/24?v=…","duration":3.6,"paused":false,"err":null}

AC11

clock = 10 Dec 2026 12:00 Paris
GET /api/calendar            -> today 10, doors 10, max day 10
GET /api/calendar/audio/1    -> 200 audio/mpeg   audio/10 -> 200
GET /api/calendar/audio/11   -> 403             audio/24 -> 403
Range: bytes=0-99 on audio/10 -> 206, content-range: bytes 0-99/216000
getCalendarDay boundary table (Paris time, opensAtHour 0 and 8):
  2026-11-30T23:59+01 -> today 0 | 2026-12-01T00:00+01 -> 1 | hour 8: 07:59 -> 0, 08:00 -> 1
  2026-12-24T23:59+01 -> 24, ended false | 2026-12-25T00:00+01 -> 24, ended true
  2026-12-14T23:30Z (= 15 Dec 00:30 Paris) -> 15

AC12

bucket demos: access level private (neon buckets list)
GET /api/calendar-doors              -> 403
GET /api/calendar-doors/file/01.mp3  -> 403
GET /api/calendar/audio/11 (day 10) -> 403; audio/25 -> 404

AC13

click door 3 -> cookie clarks_advent_2026=4 path=/calendrier
reload -> door 3 aria-expanded=true, door 4 aria-expanded=false

AC14

door 2 audio bytes before/after replacing the file in the admin API: 288000 -> 144000 (replacement is 144000 bytes)
audio URL version (?v=updatedAt) changed: true, no redeploy

AC15

local SMTP sink, prod build:  POST /api/send-emails -> 200 {"message":"Thanks Test, we will be in touch shortly."}
captured: Subject: Test wants to get in touch  /  Subject: Hi Test, thanks for getting in touch
/ /about /tour /music /lyrics /contact /merch -> 200
no DATABASE_URL (prod build and start): /calendrier 404, /api/calendar 404, /admin 404, /contact 200, /about 200

AC16

prod build, base CSP enforced, images, fonts and audio in use, securitypolicyviolation listener installed:
visitor        violations: []  console errors: []
member-preview violations: []  console errors: []

Deploy preview

The preview build runs payload migrate on a freshly reset Neon preview branch, so the two new migrations apply on top of 20261112_223859_initial exactly as they will on main.

settings change -> visible on the Netlify preview:
  orange=#0000ff: visible after 1.6 s | fonts monoton/lobster/outfit: 1.3 s | fr title: 0.5 s | reset: 0.7 s

member, signed in on the preview: preview tools visible, Mode test -> 24 enabled doors, door 24 plays
  {"duration":3.6,"paused":false,"err":null}    CSP violations: none from the page
  (the only one is Netlify's own deploy-preview toolbar framing app.netlify.com)

8 MB MP3 PATCH through the function (REST)              -> 413
8 MB MP3 uploaded in the admin UI (clientUploads):
  POST /api/storage-s3-generate-signed-url -> 200
  PUT  <storage origin>/demos/<uuid>/big.mp3 straight to the bucket
  POST /api/calendar-doors -> 201
member GET /api/calendar/audio/22 -> 200 audio/mpeg, 8064000 bytes (the uploaded file is 8064000)
member GET /api/calendar/audio/23 (8 MB object) -> 200, 8064000 bytes in 2185 ms
Range: bytes=7000000-7000099 -> 206 content-range: bytes 7000000-7000099/8064000

DB (migration on Neon preview)

INSERT calendar_doors day 24                  -> INSERT 0 1
INSERT calendar_doors day 25                  -> violates check constraint "calendar_doors_day_range_check"
INSERT calendar_doors day 0                   -> violates check constraint "calendar_doors_day_range_check"
INSERT calendar_doors day 24 (duplicate)      -> duplicate key value violates unique constraint "calendar_doors_day_idx"
INSERT calendar_settings opens_at_hour 24     -> violates check constraint "calendar_settings_opens_at_hour_range_check"
INSERT calendar_settings opens_at_hour 23     -> INSERT 0 1

@netlify

netlify Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for clarksbowlingclub ready!

Name Link
🔨 Latest commit 6b95bf2
🔍 Latest deploy log https://app.netlify.com/projects/clarksbowlingclub/deploys/6af65540b517f62d0d1d2535
😎 Deploy Preview https://deploy-preview-50--clarksbowlingclub.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@maxitect
maxitect marked this pull request as ready for review November 13, 2026 00:09
@maxitect
maxitect merged commit 869427b into main Nov 13, 2026
5 checks passed
@maxitect
maxitect deleted the feat/29-advent-calendar-live-at-calendrier-by-1-december branch November 13, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Advent calendar live at /calendrier by 1 December

1 participant