Video Figure Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Build a dual-mode video player component with quality switching, timed WebVTT annotations, and SVG overlay shapes.
Architecture: A standalone JS file (video-figure.js) enhances [data-video-figure] elements with a quality picker, metadata track dispatch, and SVG overlay. It also exports meta + setup() for use as an interactive figure module. CSS extends the existing .figure styles.
Tech Stack: Vanilla JS, HTML5 <video> + <track>, WebVTT, SVG, CSS custom properties. Tests via rodney (headless Chrome CLI). Demo via showboat.
Task 1: Scaffold video-figure.js and add to base template
Files:
- Create: web/static/js/video-figure.js
- Modify: src/almnck/templates/base.html:49 (add script tag)
Step 1: Create minimal video-figure.js
/**
* video-figure.js — Almanack video player enhancement.
*
* Dual-mode: standalone (self-initializes on [data-video-figure])
* or figure module (exports meta + setup for runtime.js).
*/
(function () {
'use strict';
function enhance(container) {
const video = container.querySelector('video');
if (!video) return;
// Placeholder — tasks 2+ fill this in
}
function init() {
document.querySelectorAll('[data-video-figure]').forEach(enhance);
}
// Self-initialize in standalone mode
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
// HTMX support: reinitialize after article swap
document.body.addEventListener('htmx:afterSwap', function (event) {
if (event.detail.target.id === 'article-swap') {
init();
}
});
// Expose for figure module mode
window.__videoFigure = { enhance: enhance };
})();
Step 2: Add script tag to base.html
In src/almnck/templates/base.html, after the sidenotes.js line:
<script src="{% cdnstatic 'js/video-figure.js' %}" defer></script>
Step 3: Update Kropotkin article markup
In editorial/articles/kropotkins-funeral/article.md, replace the existing <figure> block (lines 219-224) with:
<figure class="figure" data-video-figure>
<video controls preload="none" poster="assets/poster.jpg">
<source src="assets/kropotkin-funeral-1921-360p.mp4" type="video/mp4" data-label="Original (360p)" default>
<source src="assets/kropotkin-funeral-1921-enhanced-360p.mp4" type="video/mp4" data-label="Enhanced (360p)">
<source src="assets/kropotkin-funeral-1921-enhanced.mp4" type="video/mp4" data-label="Enhanced (Full)" data-size="409MB">
</video>
<figcaption>Похороны Кропоткина (Kropotkin's Funeral), 1921. Soviet archival footage from Gosfilmofond. Public domain.</figcaption>
</figure>
Step 4: Sync and build
Run: make sync && make build
Step 5: Verify with rodney that the page loads
rodney start
rodney open "http://localhost:1969/6021/2/13/the-funeral-of-pyotr-kropotkin/"
rodney waitstable
rodney exists "[data-video-figure]" && echo "ok 1 - video figure found"
rodney exists "video" && echo "ok 2 - video element found"
rodney stop
Step 6: Commit
git add web/static/js/video-figure.js src/almnck/templates/base.html editorial/articles/kropotkins-funeral/article.md
git commit -m "Scaffold video-figure.js with multi-source Kropotkin markup"
Task 2: Quality picker
Files:
- Modify: web/static/js/video-figure.js
- Modify: web/static/css/almanack.css
Step 1: Write rodney test script
Create src/tests/test-video-figure (bash, TAP output):
#!/usr/bin/env bash
#
# Browser test: video figure quality picker
#
# Requires: rodney, make serve running on port 1969
# Outputs TAP format.
#
set -euo pipefail
: "${ALMANACK_ROOT:?ALMANACK_ROOT not set}"
TEST_NUM=0
tap_ok() { TEST_NUM=$((TEST_NUM + 1)); echo "ok $TEST_NUM - $1"; }
tap_fail() { TEST_NUM=$((TEST_NUM + 1)); echo "not ok $TEST_NUM - $1 # $2"; }
cleanup() { rodney stop 2>/dev/null || true; }
trap cleanup EXIT
ARTICLE_URL="http://localhost:1969/6021/2/13/the-funeral-of-pyotr-kropotkin/"
rodney start
sleep 1
echo "TAP version 14"
# Test 1: Video figure exists
rodney open "$ARTICLE_URL"
rodney waitstable
if rodney exists "[data-video-figure]" 2>/dev/null; then
tap_ok "video figure element exists"
else
tap_fail "video figure element exists" "not found"
fi
# Test 2: Quality picker rendered
if rodney exists ".video-figure-toolbar" 2>/dev/null; then
tap_ok "quality picker toolbar rendered"
else
tap_fail "quality picker toolbar rendered" "no .video-figure-toolbar"
fi
# Test 3: Picker has correct number of options
COUNT=$(rodney js "document.querySelectorAll('.video-quality-picker option').length" 2>/dev/null || echo "0")
if [ "$COUNT" = "3" ]; then
tap_ok "quality picker has 3 options"
else
tap_fail "quality picker has 3 options" "found $COUNT"
fi
# Test 4: First option is default
FIRST_LABEL=$(rodney js "document.querySelector('.video-quality-picker option').textContent" 2>/dev/null || echo "")
if echo "$FIRST_LABEL" | grep -q "Original"; then
tap_ok "first option is Original (360p)"
else
tap_fail "first option is Original (360p)" "got: $FIRST_LABEL"
fi
# Test 5: Switching source updates video src
rodney js "document.querySelector('.video-quality-picker').value = 1; document.querySelector('.video-quality-picker').dispatchEvent(new Event('change'))" 2>/dev/null
rodney sleep 1
CURRENT_SRC=$(rodney js "document.querySelector('[data-video-figure] video').src" 2>/dev/null || echo "")
if echo "$CURRENT_SRC" | grep -q "enhanced-360p"; then
tap_ok "switching to option 2 changes video source"
else
tap_fail "switching to option 2 changes video source" "src: $CURRENT_SRC"
fi
echo "1..$TEST_NUM"
Make it executable: chmod +x src/tests/test-video-figure
Step 2: Run the test to verify it fails
Run: src/tests/test-video-figure
Expected: Tests 2-5 fail (no toolbar yet).
Step 3: Implement quality picker in video-figure.js
Replace the enhance function body:
function enhance(container) {
const video = container.querySelector('video');
if (!video) return;
const sources = Array.from(video.querySelectorAll('source[data-label]'));
if (sources.length < 2) return; // No point in a picker with 0-1 sources
// Build toolbar
const toolbar = document.createElement('div');
toolbar.className = 'video-figure-toolbar';
// Quality picker
const picker = document.createElement('select');
picker.className = 'video-quality-picker';
picker.setAttribute('aria-label', 'Video quality');
sources.forEach(function (source, i) {
const opt = document.createElement('option');
opt.value = i;
opt.textContent = source.dataset.label;
if (source.dataset.size) {
opt.textContent += ' \u2014 ' + source.dataset.size;
}
if (source.hasAttribute('default')) {
opt.selected = true;
}
picker.appendChild(opt);
});
picker.addEventListener('change', function () {
var idx = parseInt(picker.value, 10);
var currentTime = video.currentTime;
var wasPaused = video.paused;
video.src = sources[idx].src;
video.load();
video.addEventListener('loadedmetadata', function onMeta() {
video.removeEventListener('loadedmetadata', onMeta);
video.currentTime = currentTime;
if (!wasPaused) video.play();
});
});
toolbar.appendChild(picker);
// Insert toolbar after video, before figcaption
var figcaption = container.querySelector('figcaption');
if (figcaption) {
container.insertBefore(toolbar, figcaption);
} else {
container.appendChild(toolbar);
}
}
Step 4: Add CSS for toolbar
Append to web/static/css/almanack.css, after the lightbox styles (~line 1202):
/* Video figure toolbar */
.video-figure-toolbar {
display: flex;
align-items: center;
gap: 0.5em;
padding: 0.4em 0.5em;
font-size: 0.8em;
font-family: var(--font-body);
}
.video-quality-picker {
font-family: var(--font-body);
font-size: 1em;
padding: 0.2em 0.4em;
border: 1px solid var(--color-light);
background: var(--color-bg);
color: var(--color-text);
cursor: pointer;
}
Step 5: Build and run test
Run: make build && src/tests/test-video-figure
Expected: All 5 tests pass.
Step 6: Commit
git add web/static/js/video-figure.js web/static/css/almanack.css src/tests/test-video-figure
git commit -m "Quality picker for video figures"
Task 3: Metadata track dispatch to margin box
Files:
- Modify: web/static/js/video-figure.js
- Create: editorial/articles/kropotkins-funeral/assets/funeral-annotations.vtt
- Modify: editorial/articles/kropotkins-funeral/article.md (add track + margin box)
Step 1: Create sample annotation VTT
Create editorial/articles/kropotkins-funeral/assets/funeral-annotations.vtt:
WEBVTT
NOTE Annotations for Kropotkin's Funeral, 1921
00:00:05.000 --> 00:00:20.000
{"text": "The funeral procession assembles outside the Hall of Columns, Moscow Labour Temple"}
00:00:25.000 --> 00:00:40.000
{"text": "Anarchist banners of black and scarlet are carried at the head of the procession"}
00:01:00.000 --> 00:01:20.000
{"text": "Thousands of mourners: members of Anarchist organizations, labour unions, scientific and literary societies"}
(Timecodes are approximate — Danny can adjust later to match the footage.)
Step 2: Add track and margin box to article
In article.md, update the figure to add the metadata track:
<figure class="figure" data-video-figure>
<video controls preload="none" poster="assets/poster.jpg">
<source src="assets/kropotkin-funeral-1921-360p.mp4" type="video/mp4" data-label="Original (360p)" default>
<source src="assets/kropotkin-funeral-1921-enhanced-360p.mp4" type="video/mp4" data-label="Enhanced (360p)">
<source src="assets/kropotkin-funeral-1921-enhanced.mp4" type="video/mp4" data-label="Enhanced (Full)" data-size="409MB">
<track kind="metadata" src="assets/funeral-annotations.vtt" data-output="#kropotkin-annotations">
</video>
<figcaption>Похороны Кропоткина (Kropotkin's Funeral), 1921. Soviet archival footage from Gosfilmofond. Public domain.</figcaption>
</figure>
Add a margin box target after the figure (sidenotes.js will position it):
<template id="injected-margin-boxes">
<div class="margin-box-injected" id="kropotkin-annotations" data-margin="right-near">
</div>
</template>
Note: check whether a <template id="injected-margin-boxes"> block already exists in the article — if so, add the div inside the existing one rather than creating a duplicate.
Step 3: Add rodney tests to test-video-figure
Append to the test script:
# Test 6: Metadata track element exists
if rodney exists "track[kind='metadata']" 2>/dev/null; then
tap_ok "metadata track element present"
else
tap_fail "metadata track element present" "no metadata track"
fi
# Test 7: Annotations appear during playback
# Start video, seek to a cue point, check for annotation
rodney js "var v = document.querySelector('[data-video-figure] video'); v.currentTime = 10; v.play()" 2>/dev/null
rodney sleep 3
rodney js "document.querySelector('[data-video-figure] video').pause()" 2>/dev/null
ANNOTATION_TEXT=$(rodney js "
var el = document.getElementById('kropotkin-annotations');
el ? el.textContent.trim() : ''
" 2>/dev/null || echo "")
if [ -n "$ANNOTATION_TEXT" ]; then
tap_ok "annotation appears during playback: ${ANNOTATION_TEXT:0:40}..."
else
tap_fail "annotation appears during playback" "annotation box empty"
fi
Step 4: Run test to verify it fails
Run: make sync && make build && src/tests/test-video-figure
Expected: Tests 6 may pass (element exists), test 7 fails (no dispatch yet).
Step 5: Implement metadata dispatch in video-figure.js
Add to the enhance function, after the toolbar insertion:
// Metadata track dispatch
var metaTracks = video.querySelectorAll('track[kind="metadata"][data-output]');
metaTracks.forEach(function (trackEl) {
var outputSelector = trackEl.dataset.output;
var outputEl = document.getElementById(outputSelector.replace('#', ''));
if (!outputEl) return;
var track = null;
// Find the corresponding TextTrack object
video.addEventListener('loadedmetadata', function () {
for (var i = 0; i < video.textTracks.length; i++) {
if (video.textTracks[i].kind === 'metadata') {
track = video.textTracks[i];
track.mode = 'hidden';
track.addEventListener('cuechange', onCueChange);
break;
}
}
});
function onCueChange() {
if (!track) return;
var activeCues = track.activeCues;
if (!activeCues || activeCues.length === 0) {
outputEl.textContent = '';
outputEl.style.display = 'none';
return;
}
outputEl.innerHTML = '';
outputEl.style.display = '';
for (var i = 0; i < activeCues.length; i++) {
try {
var data = JSON.parse(activeCues[i].text);
var annotation = document.createElement('p');
annotation.className = 'video-annotation';
annotation.textContent = data.text || '';
annotation.dataset.timecode = activeCues[i].startTime;
annotation.addEventListener('click', seekTo(activeCues[i].startTime));
outputEl.appendChild(annotation);
} catch (e) {
// Skip unparseable cues
}
}
}
function seekTo(time) {
return function () {
video.currentTime = time;
video.play();
};
}
});
Step 6: Run test to verify it passes
Run: make sync && make build && src/tests/test-video-figure
Expected: All 7 tests pass.
Step 7: Commit
git add web/static/js/video-figure.js editorial/articles/kropotkins-funeral/article.md editorial/articles/kropotkins-funeral/assets/funeral-annotations.vtt src/tests/test-video-figure
git commit -m "Metadata track dispatch: VTT annotations to margin boxes"
Task 4: SVG overlay shapes
Files:
- Modify: web/static/js/video-figure.js
- Modify: web/static/css/almanack.css
- Modify: editorial/articles/kropotkins-funeral/assets/funeral-annotations.vtt (add shapes)
Step 1: Add shapes to VTT file
Update a cue to include a shape:
00:00:25.000 --> 00:00:40.000
{"text": "Anarchist banners of black and scarlet", "shape": {"type": "rect", "x": 0.3, "y": 0.1, "w": 0.4, "h": 0.6}}
Step 2: Add rodney tests
Append to test-video-figure:
# Test 8: SVG overlay exists
if rodney exists ".video-figure-overlay" 2>/dev/null; then
tap_ok "SVG overlay element created"
else
tap_fail "SVG overlay element created" "no .video-figure-overlay"
fi
# Test 9: Shape renders during cue with shape data
rodney js "var v = document.querySelector('[data-video-figure] video'); v.currentTime = 30; v.play()" 2>/dev/null
rodney sleep 3
rodney js "document.querySelector('[data-video-figure] video').pause()" 2>/dev/null
SHAPE_COUNT=$(rodney js "document.querySelectorAll('.video-figure-overlay rect, .video-figure-overlay circle, .video-figure-overlay ellipse').length" 2>/dev/null || echo "0")
if [ "$SHAPE_COUNT" -gt "0" ] 2>/dev/null; then
tap_ok "SVG shape rendered during cue"
else
tap_fail "SVG shape rendered during cue" "found $SHAPE_COUNT shapes"
fi
Step 3: Run test to verify it fails
Run: make sync && make build && src/tests/test-video-figure
Expected: Tests 8-9 fail.
Step 4: Implement SVG overlay
In the enhance function, after toolbar insertion and before metadata dispatch:
// SVG overlay for shapes
var overlayNS = 'http://www.w3.org/2000/svg';
var overlay = document.createElementNS(overlayNS, 'svg');
overlay.classList.add('video-figure-overlay');
overlay.setAttribute('aria-hidden', 'true');
// Position overlay on top of video
var videoWrapper = document.createElement('div');
videoWrapper.className = 'video-figure-wrapper';
video.parentNode.insertBefore(videoWrapper, video);
videoWrapper.appendChild(video);
videoWrapper.appendChild(overlay);
function syncOverlaySize() {
overlay.setAttribute('width', video.clientWidth);
overlay.setAttribute('height', video.clientHeight);
overlay.setAttribute('viewBox', '0 0 1 1');
overlay.setAttribute('preserveAspectRatio', 'none');
}
syncOverlaySize();
window.addEventListener('resize', syncOverlaySize);
Then in the onCueChange function, add shape rendering:
// Clear previous shapes
while (overlay.firstChild) overlay.removeChild(overlay.firstChild);
// ... existing annotation text rendering ...
// Render shapes
for (var i = 0; i < activeCues.length; i++) {
try {
var data = JSON.parse(activeCues[i].text);
if (data.shape) {
var shape = renderShape(data.shape, data.text);
if (shape) overlay.appendChild(shape);
}
} catch (e) {}
}
Add renderShape helper:
function renderShape(shapeData, labelText) {
var el;
if (shapeData.type === 'rect') {
el = document.createElementNS(overlayNS, 'rect');
el.setAttribute('x', shapeData.x);
el.setAttribute('y', shapeData.y);
el.setAttribute('width', shapeData.w);
el.setAttribute('height', shapeData.h);
} else if (shapeData.type === 'circle') {
el = document.createElementNS(overlayNS, 'circle');
el.setAttribute('cx', shapeData.x);
el.setAttribute('cy', shapeData.y);
el.setAttribute('r', shapeData.r);
} else if (shapeData.type === 'ellipse') {
el = document.createElementNS(overlayNS, 'ellipse');
el.setAttribute('cx', shapeData.x);
el.setAttribute('cy', shapeData.y);
el.setAttribute('rx', shapeData.rx);
el.setAttribute('ry', shapeData.ry);
}
if (el) {
el.classList.add('video-figure-shape');
el.setAttribute('role', 'link');
el.setAttribute('aria-label', labelText || '');
el.style.cursor = 'pointer';
}
return el;
}
Step 5: Add CSS for SVG overlay
/* Video figure SVG overlay */
.video-figure-wrapper {
position: relative;
display: block;
}
.video-figure-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
}
.video-figure-shape {
fill: transparent;
stroke: rgba(255, 200, 50, 0.7);
stroke-width: 0.005;
pointer-events: auto;
cursor: pointer;
transition: stroke 0.2s;
}
.video-figure-shape:hover {
stroke: rgba(255, 200, 50, 1);
fill: rgba(255, 200, 50, 0.1);
}
Step 6: Run test to verify it passes
Run: make sync && make build && src/tests/test-video-figure
Expected: All 9 tests pass.
Step 7: Commit
git add web/static/js/video-figure.js web/static/css/almanack.css editorial/articles/kropotkins-funeral/assets/funeral-annotations.vtt src/tests/test-video-figure
git commit -m "SVG overlay shapes for video figure annotations"
Task 5: Annotation toggle
Files:
- Modify: web/static/js/video-figure.js
- Modify: web/static/css/almanack.css
Step 1: Add rodney tests
Append to test-video-figure:
# Test 10: Annotation toggle button exists
if rodney exists ".video-annotation-toggle" 2>/dev/null; then
tap_ok "annotation toggle button exists"
else
tap_fail "annotation toggle button exists" "not found"
fi
# Test 11: Toggle disables annotations
rodney click ".video-annotation-toggle" 2>/dev/null
rodney sleep 1
PRESSED=$(rodney attr ".video-annotation-toggle" "aria-pressed" 2>/dev/null || echo "")
if [ "$PRESSED" = "false" ]; then
tap_ok "toggle sets aria-pressed=false"
else
tap_fail "toggle sets aria-pressed=false" "aria-pressed=$PRESSED"
fi
Step 2: Run test to verify it fails
Run: make build && src/tests/test-video-figure
Expected: Tests 10-11 fail.
Step 3: Implement toggle
In the toolbar construction, after the quality picker:
// Annotation toggle (only if metadata tracks exist)
if (metaTracks.length > 0) {
var toggle = document.createElement('button');
toggle.className = 'video-annotation-toggle';
toggle.textContent = 'Annotations';
toggle.setAttribute('aria-pressed', 'true');
toggle.setAttribute('type', 'button');
// Restore state from localStorage
var storageKey = 'video-annotations-' + (container.id || 'default');
var stored = localStorage.getItem(storageKey);
if (stored === 'off') {
toggle.setAttribute('aria-pressed', 'false');
disableAnnotations();
}
toggle.addEventListener('click', function () {
var isOn = toggle.getAttribute('aria-pressed') === 'true';
if (isOn) {
toggle.setAttribute('aria-pressed', 'false');
localStorage.setItem(storageKey, 'off');
disableAnnotations();
} else {
toggle.setAttribute('aria-pressed', 'true');
localStorage.setItem(storageKey, 'on');
enableAnnotations();
}
});
toolbar.appendChild(toggle);
}
function disableAnnotations() {
metaTracks.forEach(function (trackEl) {
for (var i = 0; i < video.textTracks.length; i++) {
if (video.textTracks[i].kind === 'metadata') {
video.textTracks[i].mode = 'disabled';
}
}
});
while (overlay.firstChild) overlay.removeChild(overlay.firstChild);
var outputEl = document.getElementById(
metaTracks[0].dataset.output.replace('#', '')
);
if (outputEl) {
outputEl.textContent = '';
outputEl.style.display = 'none';
}
}
function enableAnnotations() {
metaTracks.forEach(function (trackEl) {
for (var i = 0; i < video.textTracks.length; i++) {
if (video.textTracks[i].kind === 'metadata') {
video.textTracks[i].mode = 'hidden';
}
}
});
}
Step 4: Add CSS for toggle
.video-annotation-toggle {
font-family: var(--font-body);
font-size: 1em;
padding: 0.2em 0.6em;
border: 1px solid var(--color-light);
background: var(--color-bg);
color: var(--color-text);
cursor: pointer;
}
.video-annotation-toggle[aria-pressed="true"] {
background: var(--color-text);
color: var(--color-bg);
}
Step 5: Run test to verify it passes
Run: make build && src/tests/test-video-figure
Expected: All 11 tests pass.
Step 6: Commit
git add web/static/js/video-figure.js web/static/css/almanack.css src/tests/test-video-figure
git commit -m "Annotation toggle with localStorage persistence"
Task 6: Mobile overlay fallback
Files:
- Modify: web/static/js/video-figure.js
- Modify: web/static/css/almanack.css
Step 1: Add rodney test for narrow viewport
Append to test-video-figure:
# Test 12: On narrow viewport, annotations overlay on video
rodney js "document.documentElement.style.width = '375px'; window.dispatchEvent(new Event('resize'))" 2>/dev/null
rodney sleep 1
# Seek to a cue
rodney js "var v = document.querySelector('[data-video-figure] video'); v.currentTime = 10; v.play()" 2>/dev/null
rodney sleep 3
rodney js "document.querySelector('[data-video-figure] video').pause()" 2>/dev/null
if rodney exists ".video-annotation-overlay" 2>/dev/null; then
tap_ok "annotations use overlay on narrow viewport"
else
tap_fail "annotations use overlay on narrow viewport" "no overlay element"
fi
# Reset viewport
rodney js "document.documentElement.style.width = ''" 2>/dev/null
Step 2: Run test to verify it fails
Expected: Test 12 fails.
Step 3: Implement mobile overlay fallback
In the annotation dispatch onCueChange function, add a check:
function isMarginVisible(el) {
if (!el) return false;
var parent = el.closest('.margin, .margin-left, .margin-right');
if (!parent) return false;
var style = window.getComputedStyle(parent);
return style.display !== 'none' && parent.offsetWidth > 0;
}
function onCueChange() {
if (!track) return;
var activeCues = track.activeCues;
// Clear shapes
while (overlay.firstChild) overlay.removeChild(overlay.firstChild);
// Remove any existing text overlay
var existingOverlay = videoWrapper.querySelector('.video-annotation-overlay');
if (existingOverlay) existingOverlay.remove();
if (!activeCues || activeCues.length === 0) {
if (outputEl) {
outputEl.textContent = '';
outputEl.style.display = 'none';
}
return;
}
var useOverlay = !isMarginVisible(outputEl);
for (var i = 0; i < activeCues.length; i++) {
try {
var data = JSON.parse(activeCues[i].text);
// Text annotation
if (data.text) {
var displayText = (useOverlay && data.short) ? data.short : data.text;
if (useOverlay) {
// Render as overlay on video
var overlayDiv = videoWrapper.querySelector('.video-annotation-overlay');
if (!overlayDiv) {
overlayDiv = document.createElement('div');
overlayDiv.className = 'video-annotation-overlay';
videoWrapper.appendChild(overlayDiv);
}
var p = document.createElement('p');
p.textContent = displayText;
overlayDiv.appendChild(p);
} else if (outputEl) {
// Render in margin box
outputEl.style.display = '';
var annotation = document.createElement('p');
annotation.className = 'video-annotation';
annotation.textContent = displayText;
annotation.dataset.timecode = activeCues[i].startTime;
annotation.addEventListener('click', seekTo(activeCues[i].startTime));
outputEl.appendChild(annotation);
}
}
// Shape
if (data.shape) {
var shape = renderShape(data.shape, data.text);
if (shape) overlay.appendChild(shape);
}
} catch (e) {}
}
}
Step 4: Add CSS for annotation overlay
.video-annotation-overlay {
position: absolute;
bottom: 3em;
left: 5%;
right: 5%;
background: rgba(0, 0, 0, 0.75);
color: #fff;
padding: 0.4em 0.8em;
font-size: 0.85em;
font-family: var(--font-body);
pointer-events: none;
border-radius: 2px;
}
.video-annotation-overlay p {
margin: 0.2em 0;
}
Step 5: Run test to verify it passes
Run: make sync && make build && src/tests/test-video-figure
Expected: All 12 tests pass.
Step 6: Commit
git add web/static/js/video-figure.js web/static/css/almanack.css src/tests/test-video-figure
git commit -m "Mobile overlay fallback for video annotations"
Task 7: Wire test into test harness
Files:
- Modify: bin/a-test (add video-figure suite)
Step 1: Check how a-test discovers suites
Read bin/a-test to understand the suite registration pattern.
Step 2: Add video-figure as a suite
The test should be callable as bin/a-test --suite video-figure or included in test-all. Add it alongside the existing browser/mobile suites (not in the default fast make test, since it requires rodney + a running server).
Step 3: Verify
Run: bin/a-test --suite video-figure
Expected: TAP output, all tests pass.
Step 4: Commit
git add bin/a-test
git commit -m "Add video-figure browser test suite to a-test"
Task 8: Showboat demo document
Files:
- Create: doc/process/demos/2026-02-14-video-figure-demo.md (via showboat)
Step 1: Initialize showboat document
mkdir -p doc/demos
showboat init doc/process/demos/2026-02-14-video-figure-demo.md "Video Figure Component Demo"
Step 2: Document quality picker
showboat note doc/process/demos/2026-02-14-video-figure-demo.md "The video figure enhances HTML5 video with quality switching. Three sources available: Original (360p), Enhanced (360p), and Enhanced (Full)."
rodney start
rodney open "http://localhost:1969/6021/2/13/the-funeral-of-pyotr-kropotkin/"
rodney waitstable
showboat exec doc/process/demos/2026-02-14-video-figure-demo.md bash 'rodney js "document.querySelectorAll(\".video-quality-picker option\").length + \" quality options available\""'
showboat image doc/process/demos/2026-02-14-video-figure-demo.md 'rodney screenshot /tmp/vf-picker.png && echo /tmp/vf-picker.png'
Step 3: Document annotations
showboat note doc/process/demos/2026-02-14-video-figure-demo.md "Metadata track drives margin annotations during playback. Seeking to 00:10 shows the first annotation."
showboat exec doc/process/demos/2026-02-14-video-figure-demo.md bash 'rodney js "var v = document.querySelector(\"video\"); v.currentTime = 10; v.play(); \"seeked to 10s\""'
rodney sleep 3
rodney js "document.querySelector('video').pause()"
showboat image doc/process/demos/2026-02-14-video-figure-demo.md 'rodney screenshot /tmp/vf-annotations.png && echo /tmp/vf-annotations.png'
Step 4: Document SVG shapes
showboat note doc/process/demos/2026-02-14-video-figure-demo.md "Cues with shape data render SVG overlays on the video canvas. Shapes use normalized coordinates (0-1) for resolution independence."
showboat exec doc/process/demos/2026-02-14-video-figure-demo.md bash 'rodney js "var v = document.querySelector(\"video\"); v.currentTime = 30; v.play(); \"seeked to 30s\""'
rodney sleep 3
rodney js "document.querySelector('video').pause()"
showboat image doc/process/demos/2026-02-14-video-figure-demo.md 'rodney screenshot /tmp/vf-shapes.png && echo /tmp/vf-shapes.png'
Step 5: Document annotation toggle
showboat note doc/process/demos/2026-02-14-video-figure-demo.md "The annotation toggle button hides/shows annotations. State is persisted in localStorage."
showboat exec doc/process/demos/2026-02-14-video-figure-demo.md bash 'rodney click ".video-annotation-toggle" && echo "toggled off"'
showboat image doc/process/demos/2026-02-14-video-figure-demo.md 'rodney screenshot /tmp/vf-toggle-off.png && echo /tmp/vf-toggle-off.png'
Step 6: Verify and clean up
rodney stop
showboat verify doc/process/demos/2026-02-14-video-figure-demo.md
Step 7: Commit
git add doc/process/demos/
git commit -m "Showboat demo: video figure component"
Reference
Design document: doc/process/plans/2026-02-14-video-figure-design.md
Key files:
- web/static/js/video-figure.js — all JS
- web/static/css/almanack.css — styles (append)
- src/almnck/templates/base.html — script tag
- editorial/articles/kropotkins-funeral/article.md — test article
- editorial/articles/kropotkins-funeral/assets/funeral-annotations.vtt — sample annotations
- src/tests/test-video-figure — rodney browser test (TAP)
Commands:
- make serve — dev server on :1969
- make sync && make build — rebuild static site
- src/tests/test-video-figure — run browser tests
- rodney start / rodney stop — headless Chrome lifecycle