diff --git a/site/index.html b/site/index.html index bc5fc61..5434934 100644 --- a/site/index.html +++ b/site/index.html @@ -30,7 +30,7 @@

Some votes are more equal than others

What if we used the same votes to divide the 435 House seats in three different ways: using each party's share of the vote, neutral maps drawn by a computer, or the maps the states drew for 2026? Would the outcome change?

-

By Govert Schoof, Methodology

+

By Govert Schoof, MethodologyVideos

@@ -262,6 +262,88 @@

+
+
+

Videos

+
+
+
+

Teaser

+

+
+ + +
+ Text in the video +

Democrats need 50% for a House majority?

+

Democrats need 52.4% for a House majority.

+

Nine states changed their map since the 2024 election.

+

Compared with neutral maps
Democrats +12
Republicans +22
Net effect: +10 Republican

+

The votes didn't move. The lines did.

+

Some votes are more equal than others.

+

somevotes.org
Geodienst
University of Groningen

+
+
+
+
+

How House elections work

+

+
+ + +
+ Text in the video +

November 3. All 435 House seats are up for election.

+

Seats are divided among the states by population.

+

Most states are split into districts. One district, one seat.

+

Win the district, win the seat. Second place gets nothing.

+

218 seats is a majority.

+

Every federal law and every budget must pass the House.

+

A law: fill every pothole. A budget: $12 billion.

+

The winner decides which bills get a vote and chairs every committee.

+

Who draws the districts? In most states, the state legislature. After every census. Several states redrew in 2025 and 2026.

+

Why is this important?

+

Same voters. Different lines. Different winners.

+

See what the lines do in your state.
somevotes.org

+
+
+
+
+

How to rig a map

+

+
+ + +
+ Text in the video +

Two ways to rig a map.

+

Ten of 25 voters are blue. Most live in the city.

+

Compact districts: blue wins 2 of 5.

+

Packing. Squeeze them into one district. They win it big, and waste votes.

+

Cracking. Slice them up. They lose everywhere, by a little.

+

Tennessee: Nashville and Memphis cut into slices. 37% of the votes. 0 of 9 seats.

+

Illinois: Republicans packed into three districts. 41% of the votes. 3 of 17 seats.

+

Both parties do it.

+

See what the lines do in your state.
somevotes.org

+
+
+
+

You may reuse the videos, also commercially, under CC BY 4.0. Credit: Govert Schoof, Geodienst, University of Groningen, somevotes.org.

+
+
+

Graphics to reuse

diff --git a/site/public/video/1-somevotes-teaser-720.mp4 b/site/public/video/1-somevotes-teaser-720.mp4 new file mode 100644 index 0000000..3c0a1ed Binary files /dev/null and b/site/public/video/1-somevotes-teaser-720.mp4 differ diff --git a/site/public/video/1-somevotes-teaser-poster.webp b/site/public/video/1-somevotes-teaser-poster.webp new file mode 100644 index 0000000..01e8f88 Binary files /dev/null and b/site/public/video/1-somevotes-teaser-poster.webp differ diff --git a/site/public/video/2-somevotes-house-elections-explainer-720.mp4 b/site/public/video/2-somevotes-house-elections-explainer-720.mp4 new file mode 100644 index 0000000..7b4e2c5 Binary files /dev/null and b/site/public/video/2-somevotes-house-elections-explainer-720.mp4 differ diff --git a/site/public/video/2-somevotes-house-elections-explainer-poster.webp b/site/public/video/2-somevotes-house-elections-explainer-poster.webp new file mode 100644 index 0000000..7bfc776 Binary files /dev/null and b/site/public/video/2-somevotes-house-elections-explainer-poster.webp differ diff --git a/site/public/video/3-somevotes-how-to-rig-a-map-720.mp4 b/site/public/video/3-somevotes-how-to-rig-a-map-720.mp4 new file mode 100644 index 0000000..748d299 Binary files /dev/null and b/site/public/video/3-somevotes-how-to-rig-a-map-720.mp4 differ diff --git a/site/public/video/3-somevotes-how-to-rig-a-map-poster.webp b/site/public/video/3-somevotes-how-to-rig-a-map-poster.webp new file mode 100644 index 0000000..f53df73 Binary files /dev/null and b/site/public/video/3-somevotes-how-to-rig-a-map-poster.webp differ diff --git a/site/src/styles/controls.css b/site/src/styles/controls.css index 5d7223c..6204046 100644 --- a/site/src/styles/controls.css +++ b/site/src/styles/controls.css @@ -10,6 +10,7 @@ select { font: inherit; font-size: 0.87rem; padding: 0.3rem 0.4rem; background: .sharebtn { display: inline-flex; align-items: center; gap: 0.45rem; flex: none; font: 500 0.87rem/1 var(--font-body); padding: 0.4rem 0.65rem; border: 1px solid var(--rule); background: var(--sheet); color: var(--fg); cursor: pointer; } .sharebtn:hover { border-color: var(--ink); } +a.sharebtn { text-decoration: none; } /* a download link in the look of the buttons */ .sharebtn svg { width: 0.95rem; height: 0.95rem; } .mapbar, .whead { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; } /* The Share panel of chapter 01: the image as it will be shared, with the ways to share it under it */ diff --git a/site/src/styles/index.css b/site/src/styles/index.css index 5209490..faf1d7c 100644 --- a/site/src/styles/index.css +++ b/site/src/styles/index.css @@ -10,3 +10,4 @@ @import './outcomes.css'; @import './detail.css'; @import './method.css'; +@import './video.css'; diff --git a/site/src/styles/page.css b/site/src/styles/page.css index a2ea32e..d565312 100644 --- a/site/src/styles/page.css +++ b/site/src/styles/page.css @@ -4,7 +4,7 @@ .mast .wrap { display: grid; gap: 0.7rem; } .mast h1 { margin: 0; font: 700 clamp(1.9rem, 1.2rem + 2vw, 2.9rem)/1.1 var(--font-head); letter-spacing: -0.01em; max-width: 36ch; text-wrap: balance; } .mast .sub { margin: 0; font-size: 1.0625rem; line-height: 1.5; max-width: 80ch; } -/* The byline as a news story has it: author, date, and a link to the method. */ +/* The byline as a news story has it: author, date, and links to the method and the videos. */ /* Justitia at the top right of the masthead: a black line drawing on white, turned into light lines on the dark green */ .mast .wrap { position: relative; } @@ -23,11 +23,12 @@ .about { border-top: 1px solid var(--rule); padding-block: 2rem 2.4rem; } .about h2 { font: 700 1.25rem/1.2 var(--font-head); margin: 0 0 0.6rem; } .about p { max-width: 64ch; margin: 0.45rem 0 0; } -/* Graphics to reuse, between the method and About: the two images side by side, each with its caption and buttons */ -.graphics { border-top: 1px solid var(--rule); padding-block: 2rem 2.4rem; } -.graphics h2 { font: 700 1.25rem/1.2 var(--font-head); margin: 0 0 0.6rem; } -.graphics .intro, .graphics .terms { max-width: 64ch; margin: 0.45rem 0 0; } -.graphics .terms { margin-top: 1.4rem; font-size: 0.87rem; } +/* Videos and Graphics to reuse, between the method and About, with one heading and intro style (the videos in + video.css); here the two images side by side, each with its caption and buttons */ +.videos, .graphics { border-top: 1px solid var(--rule); padding-block: 2rem 2.4rem; } +.videos h2, .graphics h2 { font: 700 1.25rem/1.2 var(--font-head); margin: 0 0 0.6rem; } +.graphics .intro, .videos .terms, .graphics .terms { max-width: 64ch; margin: 0.45rem 0 0; } +.videos .terms, .graphics .terms { margin-top: 1.4rem; font-size: 0.87rem; } .gcards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1.6rem; margin-top: 1.2rem; align-items: start; } .gcard { margin: 0; display: grid; gap: 0.7rem; min-width: 0; } .gcard canvas { display: block; width: 100%; height: auto; border: 1px solid var(--rule); } diff --git a/site/src/styles/video.css b/site/src/styles/video.css new file mode 100644 index 0000000..3d804c5 --- /dev/null +++ b/site/src/styles/video.css @@ -0,0 +1,28 @@ +/* Videos, above Graphics to reuse: the three videos, each with its title and length, the player, its downloads and the + text in the video. A player loads only its poster until the reader presses play (preload="none"). */ + +/* Each column is as wide as its player, so the title, the buttons and the text line up with it. A player stays within + 80% of the screen height, so it fits whole, and at most 24rem wide. On a phone the videos stand one under the other. */ +.vcards { display: grid; gap: 2.4rem 1.6rem; margin-top: 1.2rem; align-items: start; + grid-template-columns: minmax(0, min(24rem, 80vh * 9 / 16 + 2px)); + grid-template-columns: minmax(0, min(24rem, 80svh * 9 / 16 + 2px)); } +.vcard { display: grid; gap: 0.7rem; min-width: 0; align-content: start; } +.vcard-head { display: grid; gap: 0.15rem; } +.vcard-head h3 { font: 700 1.0625rem/1.25 var(--font-head); } +.vcard-head time { font-variant-numeric: tabular-nums; } +/* a button may wrap rather than run past a narrow column, as with the phone on its side */ +.vcard .sharebtn { flex: 0 1 auto; } +/* the border sits outside the 9:16 box (content-box), so the poster fills it exactly */ +.vcard video { display: block; aspect-ratio: 9 / 16; height: auto; border: 1px solid var(--rule); background: var(--mid); + width: min(100% - 2px, 80vh * 9 / 16); width: min(100% - 2px, 80svh * 9 / 16); } + +/* From 720px the three side by side. Each video spans four rows of the grid (subgrid), so the titles, the players, the + buttons and the text stand level across the three, also when a title or the two teaser buttons wrap. */ +@media (min-width: 720px) { + .vcards { row-gap: 0.7rem; + grid-template-columns: repeat(3, minmax(0, min(24rem, 80vh * 9 / 16 + 2px))); + grid-template-columns: repeat(3, minmax(0, min(24rem, 80svh * 9 / 16 + 2px))); } + .vcard { grid-row: span 4; grid-template-rows: subgrid; } + /* a single button keeps its height when the two teaser buttons take two lines */ + .vcard .gbar { align-self: start; } +} diff --git a/site/test/page.test.ts b/site/test/page.test.ts index 22a6e37..c6618a1 100644 --- a/site/test/page.test.ts +++ b/site/test/page.test.ts @@ -1,6 +1,6 @@ // The page as files (site design, chapter 7): index.html loads only its own entry module, the modules import each other // and the two bundled libraries, one module fetches the two data files, no em dashes in visible text, and the built -// page stays under 1.5 MB. Run with: pnpm test +// page stays under 1.5 MB without its videos (video.test.ts). Run with: pnpm test import { test } from 'node:test'; import assert from 'node:assert/strict'; import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'; @@ -105,8 +105,10 @@ test('the built page and everything it loads stay under 1.5 MB', (t) => { return; } // the license texts are linked from the footer, the preview image is for shared links and the touch icon for a - // phone's home screen: none is loaded with the page - const apart = (file: string) => file.startsWith('licenses/') || file === 'img/preview.png' || file === 'apple-touch-icon.png'; + // phone's home screen: none is loaded with the page. A video loads only when the reader presses play (video.test.ts), + // so the MP4 files are left out; their posters load with the page and count. + const apart = (file: string) => file.startsWith('licenses/') || file === 'img/preview.png' || file === 'apple-touch-icon.png' + || (file.startsWith('video/') && file.endsWith('.mp4')); const files = filesUnder(DIST, DIST).filter((file) => !apart(file)); const bytes = files.reduce((total, file) => total + statSync(join(DIST, file)).size, 0); assert.ok(bytes < 1_500_000, `${bytes} bytes in dist/`); diff --git a/site/test/video.test.ts b/site/test/video.test.ts new file mode 100644 index 0000000..bdf9f8a --- /dev/null +++ b/site/test/video.test.ts @@ -0,0 +1,165 @@ +// The videos: the section Videos above Graphics to reuse, with three players in the owner's order. The web copies in +// site/public/video play from the site itself, load nothing but their posters before the reader presses play, and +// start before the whole file is in. The full-quality copies are release assets on GitHub. The page budget of +// page.test.ts leaves the MP4 files out; these tests set their limits. Run with: pnpm test +import { test } from 'node:test'; +import assert from 'node:assert/strict'; +import { closeSync, existsSync, fstatSync, openSync, readFileSync, readSync, readdirSync, statSync } from 'node:fs'; +import { fileURLToPath } from 'node:url'; +import { join } from 'node:path'; + +const SITE = fileURLToPath(new URL('../', import.meta.url)); +const VIDEO = join(SITE, 'public', 'video'); +const html = readFileSync(join(SITE, 'index.html'), 'utf8'); +const RELEASE = 'https://github.com/geodienst/Gerry/releases/download/videos-2026-10-27/'; + +const files = readdirSync(VIDEO).sort(); +const webVideos = files.filter((file) => file.endsWith('.mp4')); +const posters = files.filter((file) => file.endsWith('.webp')); + +/** The types of the top-level boxes of an MP4 file, in their order in the file: ftyp, moov, mdat and so on. */ +function boxes(path: string): string[] { + const fd = openSync(path, 'r'); + try { + const end = fstatSync(fd).size; + const head = Buffer.alloc(16); + const types: string[] = []; + for (let at = 0; at + 8 <= end;) { + readSync(fd, head, 0, 16, at); + let size = head.readUInt32BE(0); + if (size === 1) size = Number(head.readBigUInt64BE(8)); // a 64-bit size after the type + else if (size === 0) size = end - at; // the box runs to the end of the file + types.push(head.toString('latin1', 4, 8)); + if (size < 8) break; // not a box: the order so far is all there is + at += size; + } + return types; + } finally { + closeSync(fd); + } +} + +/** Width and height of a WebP image, from its VP8 frame header or, in the extended format, its canvas. */ +function webpSize(path: string): [number, number] { + const data = readFileSync(path); + assert.ok(data.toString('ascii', 0, 4) === 'RIFF' && data.toString('ascii', 8, 12) === 'WEBP', `${path} is not a WebP`); + const chunk = data.toString('ascii', 12, 16); + if (chunk === 'VP8 ') return [data.readUInt16LE(26) & 0x3fff, data.readUInt16LE(28) & 0x3fff]; + if (chunk === 'VP8X') return [data.readUIntLE(24, 3) + 1, data.readUIntLE(27, 3) + 1]; + throw new Error(`${path}: a ${chunk.trim()} WebP, expected a lossy one`); +} + +/** The section Videos, from its opening tag to its end. */ +const section = /
/.exec(html)?.[0] ?? ''; + +/** Each video of the section: its title, length, player, download links and the text in the video. */ +const cards = [...section.matchAll(/
([\s\S]*?)<\/details>\s*<\/div>/g)].map(([, id, body]) => { + const video = /]*)>([\s\S]*?)<\/video>/.exec(body); + const attrs = video?.[1] ?? ''; + const attr = (name: string) => new RegExp(`\\b${name}="([^"]*)"`).exec(attrs)?.[1]; + const label = attr('aria-labelledby'); + return { + id, + title: /

([^<]+)<\/h3>/.exec(body), + time: /