${esc(title)}
${sub ? `${sub}
` : ''} ${buttons ? `${fine}
` : ''}One Discord check unlocks the radio for ${MEMBERSHIP_DAYS} days.`, ) } const privacyFine = `We ask Discord once, keep only "member: yes/no" and your Discord name, and throw the token away.
A check is good for ${MEMBERSHIP_DAYS} days.` /** Step 2: confirm Discord membership (first time, lapsed, not a member, or after an error). */ function discordCard(base: string, s: Extract
${privacyFine}`, ) } if (s.expired) return stepCard('discord-title', 'Check your Discord again', `Your last check is more than ${MEMBERSHIP_DAYS} days old.`, [{ label: 'Check with Discord', href: start }], privacyFine) return stepCard('discord-title', 'Confirm your Discord', `We'll check you're in the ${esc(GUILD_NAME)} Discord.`, [{ label: 'Check with Discord', href: start }], privacyFine) } const MONTHS = ['Jan.', 'Feb.', 'Mar.', 'Apr.', 'May', 'Jun.', 'Jul.', 'Aug.', 'Sep.', 'Oct.', 'Nov.', 'Dec.'] /** * Format a date as "Nov. 27" in America/New_York ("May" has no period); the year is added only when it * differs from the current year there ("Jan. 3, 2027"). * * @param iso - an ISO timestamp * @param now - the current time (for the year comparison) * @returns the short date */ export function shortDate(iso: string, now = new Date()): string { const parts = (d: Date) => { const p = Object.fromEntries(new Intl.DateTimeFormat('en-US', { timeZone: 'America/New_York', year: 'numeric', month: 'numeric', day: 'numeric' }).formatToParts(d).map((x) => [x.type, x.value])) return { y: Number(p.year), m: Number(p.month), d: Number(p.day) } } const t = parts(new Date(iso)) const base = `${MONTHS[t.m - 1]} ${t.d}` return t.y === parts(now).y ? base : `${base}, ${t.y}` } /** Track list with players (members only). */ function trackList(base: string, radio: View, art: Record
${esc(radio.album)}
MEGA Radio · ${radio.tracks.filter((t) => t.released).length} of ${radio.tracks.length} tracks open
- ${items}
The WAKE album from the ${esc(GUILD_NAME)} course, for members of the ${esc(GUILD_NAME)} Discord.
` if (s.kind === 'signed-out') { return shell(base, `${intro}${signInCard(s.loginHref)}`) } const right = `${esc(s.username)}Sign Out` if (s.kind === 'member') { const memberIntro = `The WAKE album from the ${esc(GUILD_NAME)} course, for members of the ${esc(GUILD_NAME)} Discord, which now includes you! You’re validated through ${esc(shortDate(s.expiresAt, now))}.
` return shell(base, `${memberIntro}${trackList(base, s.radio ?? seedView(), s.art, s.plays)}${forgetCard(base)}`, right) } return shell(base, `${intro}${discordCard(base, s)}`, right) } /** Plain error page. */ export const errorPage = (base: string, message: string) => shell(base, stepCard('error-title', 'Something went wrong', esc(message), [{ label: 'Start again', href: `${base}/` }])) /** * Put the old/new origin pair on for the move script (src/move.ts). * * @param html - a page from renderPage, errorPage or movePage * @param o - the origin pair (src/origins.ts) * @returns the page with data-old-origin, data-new-origin and data-old-base */ export function withOrigins(html: string, o: Origins): string { return html.replace(/Bring your MEGA Radio data
If you used MEGA Radio at the old address (noah.kody.run/mega-radio), your repeat setting can come with you. Use Move my data on the old address, or import the file it downloaded.
`, ) }