diff --git a/server/src/admin-schema.js b/server/src/admin-schema.js index 5e4a465..f292863 100644 --- a/server/src/admin-schema.js +++ b/server/src/admin-schema.js @@ -676,7 +676,7 @@ const frontPage = { }, columns: [ - enumeration("hero_mode", ["brand", "photos", "livestream"]), + enumeration("hero_mode", ["brand", "photos", "livestream", "video"]), text("eyebrow"), text("headline"), text("subhead"), @@ -687,6 +687,8 @@ const frontPage = { int("slide_seconds"), text("livestream_url"), text("livestream_title"), + text("video_url"), + text("video_title"), text("countdown_event_id"), ], diff --git a/server/src/migrations/024_front_page_video.sql b/server/src/migrations/024_front_page_video.sql new file mode 100644 index 0000000..9fe43fa --- /dev/null +++ b/server/src/migrations/024_front_page_video.sql @@ -0,0 +1,79 @@ +-- ═══════════════════════════════════════════════════════════════ +-- 024 FRONT PAGE: FEATURED VIDEO +-- +-- A fourth hero mode, 'video': a recorded video beside the words, +-- the way 'livestream' puts a stream there, but without the LIVE +-- badge and without autoplay — a visitor presses play. +-- +-- Its own two columns rather than reusing the livestream's, so a +-- featured video and a stream can both be set up ahead of time and +-- the mode switches between them, as photos and livestream already +-- can. +-- +-- video_url a YouTube, Vimeo or Facebook link (turned into an +-- embed), or a video file: a filename in +-- public/front-page/, a /path, or an https URL ending +-- in .mp4, .webm, .m4v, .mov or .ogv, which plays in +-- the browser's own player +-- video_title shown after "Featured video" above the headline +-- +-- hero_mode's CHECK can't be altered in place, so front_page is +-- rebuilt. Its children (slides, sections, stats, paths) reference +-- it by name; the runner has foreign keys off, so the DROP leaves +-- them alone and the rename puts front_page back underneath them. +-- No view or other table's trigger names front_page, so the rename +-- needs no legacy_alter_table. front_page_touch goes with the old +-- table and is recreated last. +-- +-- PRAGMA user_version; -- reads 23 before this file +-- ═══════════════════════════════════════════════════════════════ + +CREATE TABLE front_page_new ( + id TEXT PRIMARY KEY CHECK (id = 'home'), + + hero_mode TEXT NOT NULL DEFAULT 'brand' + CHECK (hero_mode IN ('brand', 'photos', 'livestream', 'video')), + eyebrow TEXT, + headline TEXT NOT NULL DEFAULT 'Next Generation of Unity', + subhead TEXT, + primary_label TEXT, + primary_url TEXT, + secondary_label TEXT, + secondary_url TEXT, + + slide_seconds INTEGER NOT NULL DEFAULT 7 + CHECK (slide_seconds BETWEEN 3 AND 60), + + livestream_url TEXT, + livestream_title TEXT, + + video_url TEXT, + video_title TEXT, + + countdown_event_id TEXT REFERENCES events (id) ON DELETE SET NULL, + + updated_at TEXT NOT NULL DEFAULT (datetime('now')) +) STRICT; + +INSERT INTO front_page_new + (id, hero_mode, eyebrow, headline, subhead, + primary_label, primary_url, secondary_label, secondary_url, + slide_seconds, livestream_url, livestream_title, + countdown_event_id, updated_at) +SELECT + id, hero_mode, eyebrow, headline, subhead, + primary_label, primary_url, secondary_label, secondary_url, + slide_seconds, livestream_url, livestream_title, + countdown_event_id, updated_at + FROM front_page; + +DROP TABLE front_page; + +ALTER TABLE front_page_new RENAME TO front_page; + +CREATE TRIGGER front_page_touch +AFTER UPDATE ON front_page +FOR EACH ROW WHEN new.updated_at = old.updated_at +BEGIN + UPDATE front_page SET updated_at = datetime('now') WHERE id = new.id; +END; diff --git a/server/src/routes/home.js b/server/src/routes/home.js index 312d087..2f5da60 100644 --- a/server/src/routes/home.js +++ b/server/src/routes/home.js @@ -174,6 +174,9 @@ home.get("/front-page", (c) => { livestream: page.livestream_url ? { url: page.livestream_url, title: page.livestream_title } : null, + video: page.video_url + ? { url: page.video_url, title: page.video_title } + : null, }, sections, stats, diff --git a/src/lib/adminSchema.ts b/src/lib/adminSchema.ts index 3760483..10f685c 100644 --- a/src/lib/adminSchema.ts +++ b/src/lib/adminSchema.ts @@ -950,8 +950,9 @@ const timeline = { One record (see the singleton note in server/src/admin-schema.js). The groups are the hero; the collections below are the rest of - the page. Photos and the livestream are editable whatever the - mode, so either can be ready before the switch is flipped. + the page. Photos, the livestream and the featured video are + editable whatever the mode, so each can be ready before the + switch is flipped. Section keys and stat sources are the CHECK lists on front_page_sections and front_page_stats. The labels here are what the admin reads; the values are @@ -1000,6 +1001,7 @@ const frontPage = { ["brand", "Brand — animated colour, no media"], ["photos", "Photos — cycles through the photos below"], ["livestream", "Livestream — embeds the stream with a LIVE badge"], + ["video", "Featured video — shows the video below, click to play"], ], blankLabel: "— brand —", help: "Switch to Livestream when you go live, and back when you're done", @@ -1014,7 +1016,7 @@ const frontPage = { ], }, { - legend: "Photos and livestream", + legend: "Photos, livestream and video", fields: [ { path: "slide_seconds", @@ -1029,6 +1031,15 @@ const frontPage = { help: "A YouTube, Facebook or Vimeo link, or any embed URL", }, { path: "livestream_title", label: "Livestream title", full: true }, + { + path: "video_url", + label: "Featured video", + full: true, + help: + "A YouTube, Vimeo or Facebook link, or a video file: a filename in " + + "public/front-page/ or a link ending in .mp4 or .webm", + }, + { path: "video_title", label: "Video title", full: true, help: "Shown after \"Featured video\" above the headline" }, ], }, { diff --git a/src/lib/embeds.ts b/src/lib/embeds.ts index 4f0f52e..306e658 100644 --- a/src/lib/embeds.ts +++ b/src/lib/embeds.ts @@ -9,10 +9,21 @@ through; anything that isn't https is refused, so the hero never frames a plain-http or javascript: URL. - Streams start muted: browsers only autoplay muted video, and a - hero that starts shouting is worse than one that asks. + Streams start playing, muted: browsers only autoplay muted + video, and a hero that starts shouting is worse than one that + asks. A featured video doesn't start at all — it's a recording, + so the visitor presses play. + + A featured video can also be a file rather than a link: a + filename in public/front-page/, a /path, or an https URL ending + in a video extension. videoSource() says which, so the hero can + hand a file to