/** Server-rendered pages. The event list and forms are drawn by public/app.js from the boot JSON; home and create by public/home.js. */
import { HERO_SVG } from './art.ts'
import { THEMES } from './pies.ts'
const DESCRIPTION_FALLBACK = "Let us know what pie you're bringing and see what everyone else is bringing."
function escapeHtml(value: string) {
return value.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''')
}
function bootJson(value: unknown) {
return JSON.stringify(value).replace(/ }
type PublicEvent = { slug: string; code: string; title: string; date: string; time: string; place: string; blurb: string; theme: string; version: number; when: { day: string; time: string; short: string; medium: string } }
function head(input: Shared & { title: string; desc: string; ogTitle?: string; ogUrl: string; ogImage: string; ogAlt: string; manifest: string }) {
const assets = escapeHtml(input.assetBase)
const v = encodeURIComponent(input.assetVersion)
return `
${escapeHtml(input.title)}
`
}
/** Update banner, install button and toast shared by every page (driven by the scripts). */
function chrome() {
return `
Gather your people for pie. Everyone says what they are bringing, sees what is coming, and nobody needs an account.
Got a pie night code?
Hosting?
Start a pie night in a minute. You sign in with Kody so you can change the details later; your guests never need to.
Start a pie night 🥧
${mine}`
return simplePage({ ...input, title: 'Pie Night', desc: 'Plan a pie night: guests say what pie they are bringing and see everyone else’s.', body, ogUrl: `${input.site}/`, boot: { appBase: input.appBase, page: 'home' } })
}
export function newEventPageHtml(input: Shared & { visitor: { username: string } | null; loginUrl: string }) {
const themes = Object.entries(THEMES)
.map(([k, t], i) => ``)
.join('')
const body = input.visitor
? `
Start a pie night 🥧
`
: `
Hosts sign in first 🔑
Sign in with Kody to start a pie night. You need it to change the details later. Guests never sign in.
Sign in with Kody`
return simplePage({ ...input, title: 'Start a pie night', desc: 'Plan a pie night: guests say what pie they are bringing and see everyone else’s.', body, ogUrl: `${input.site}/new`, boot: { appBase: input.appBase, page: 'new' } })
}
export function notFoundHtml(input: Shared & { code: string }) {
const body = `
No pie night here 🥧
${input.code ? `We could not find a pie night with the code ${escapeHtml(input.code)}.` : 'That page is not on the menu.'} Double-check the link, or try the code again.
`
return simplePage({ ...input, title: 'Pie night not found', desc: 'Pie Night', body, ogUrl: `${input.site}/`, boot: { appBase: input.appBase, page: 'missing' } })
}
export function offlineHtml(input: Shared) {
const body = `
You're offline 🥧
This pie night page has not been saved on this device yet. Connect to the internet and try again. Pages you have opened before still work offline.