Add a featured video mode to the front page hero
A fourth hero mode beside brand, photos and livestream: a recorded video next to the words, under a "Featured video · <title>" badge. Unlike the livestream it never autoplays: an embed waits for play, and a file shows the browser's own player with preload="metadata". video_url takes a YouTube, Vimeo or Facebook link (turned into an embed, as the livestream's is) or a video file: a filename in public/front-page/, a /path, or an https URL ending in .mp4, .webm, .m4v, .mov or .ogv. Anything else that can't be framed still gets a "Watch the video" button. Files follow the embeds' https-only rule. Its own video_url and video_title columns rather than the livestream's, so both can be set up ahead of time and the mode switches between them. Migration 024 rebuilds front_page for the wider hero_mode CHECK; its children, keys and touch trigger survive. embeds.ts gains an autoplay switch shared by both modes, and videoSource() to tell a file from an embed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b10a263a90
commit
8c26ec4906
8 changed files with 243 additions and 22 deletions
|
|
@ -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"),
|
||||
],
|
||||
|
||||
|
|
|
|||
79
server/src/migrations/024_front_page_video.sql
Normal file
79
server/src/migrations/024_front_page_video.sql
Normal file
|
|
@ -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;
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue