Spaces:
Sleeping
feat: images-input UI — standalone /images upload page
Browse filesAdds a self-contained upload page for the images-input mode, kept
separate from the video form so the working video flow is untouched.
/images page:
* Multi-image file input + transcript input + title + optional API key.
* AI toggles: section titles, scene description, alt-text, on-screen
text, math equations. Topic segmentation is intentionally excluded —
re-bucketing hand-picked slides into topics fights the point of
curating exact slides (the endpoint's topic flags are always sent
false from this page).
* Output format picker (editor / single HTML / ZIP).
* Submit posts to /jobs/from-images, subscribes to the same SSE
progress stream, and on completion navigates to the editor (review)
or downloads (single/zip) — reuses the existing job/events/result
infrastructure end to end.
* Accessible: skip link, labelled fields, aria-live progress panel,
visible focus, theme-consistent styling. Clears the API key from the
DOM after capture.
Also: a cross-link on the main video page ("No video, just slide
exports? Build from slide images…") so the mode is discoverable, and a
back-link from /images to the video uploader.
https://claude.ai/code/session_01EM8jiYxdVFy1w3LeJ9GBJg
Files changed (3)
186 unmodified lines187188189190191192186 unmodified linesreturn templates.TemplateResponse(request, "index.html", {})def _safe_filename(title: str) -> str:safe = "".join(c if c.isalnum() or c in "-_ " else "-" for c in title).strip()safe = safe.replace(" ", "-")186 unmodified lines187188189190191192193194195196197186 unmodified linesreturn templates.TemplateResponse(request, "index.html", {})@app.get("/images", response_class=HTMLResponse)async def images_page(request: Request) -> HTMLResponse:return templates.TemplateResponse(request, "images.html", {})def _safe_filename(title: str) -> str:safe = "".join(c if c.isalnum() or c in "-_ " else "-" for c in title).strip()safe = safe.replace(" ", "-")
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Video Guide Maker — from slide images</title> <style> :root { --banner: #750014; --banner-text: #fff; --bg: #fff; --text: #1a1a1a; --muted: #555; --border: #d0d0d0; --surface: #f5f5f5; --radius: 6px; --font: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif; } * { box-sizing: border-box; } body { margin: 0; font-family: var(--font); color: var(--text); background: var(--bg); line-height: 1.6; } a { color: var(--banner); } .skip-link { position: absolute; left: -999px; top: 0; background: #1a1a1a; color: #fff; padding: .5rem 1rem; z-index: 10; } .skip-link:focus { left: 1rem; top: 1rem; } header.page { background: var(--banner); color: var(--banner-text); padding: 2rem 1.25rem; text-align: center; } header.page h1 { margin: 0 0 .25rem; font-size: 1.6rem; } header.page p { margin: 0; opacity: .9; font-size: .98rem; } header.page .switch { margin-top: .75rem; font-size: .9rem; } header.page .switch a { color: #f5d5db; } main { max-width: 44rem; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; } .card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; } .card h2 { margin: 0 0 .75rem; font-size: 1.1rem; } .field { margin-bottom: 1rem; } .field > label { display: block; font-weight: 600; margin-bottom: .3rem; } .field small { color: var(--muted); font-weight: 400; } input[type="text"], input[type="password"], input[type="file"], select { width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; background: var(--bg); color: var(--text); } input[type="file"] { padding: .4rem; } .hint { font-size: .88rem; color: var(--muted); margin: .3rem 0 0; } fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0 0 1rem; } legend { font-weight: 700; padding: 0 .4rem; } .toggle { display: flex; gap: .5rem; align-items: flex-start; padding: .35rem 0; } .toggle input { margin-top: .3rem; flex: 0 0 auto; } .toggle .t-body strong { display: block; } .toggle .t-body small { color: var(--muted); } .formats { display: flex; gap: 1rem; flex-wrap: wrap; } .formats label { display: inline-flex; gap: .4rem; align-items: center; font-weight: 500; } button.submit { background: var(--banner); color: var(--banner-text); border: 0; padding: .7rem 1.4rem; font: inherit; font-weight: 600; border-radius: var(--radius); cursor: pointer; } button.submit:hover { filter: brightness(1.1); } :focus-visible { outline: 2px solid #1a1a1a; outline-offset: 2px; } .panel { display: none; border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; background: var(--surface); } .panel[data-state="running"], .panel[data-state="error"] { display: block; } .bar { height: 10px; background: #e5e5e5; border-radius: 5px; overflow: hidden; margin: .5rem 0; } .bar > span { display: block; height: 100%; background: var(--banner); width: 0; transition: width .2s; } .panel[data-state="error"] { border-color: var(--banner); } .panel pre { white-space: pre-wrap; font-size: .85rem; color: var(--muted); margin: .5rem 0 0; } .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); } </style></head><body> <a href="#main" class="skip-link">Skip to main content</a> <header class="page" role="banner"> <h1>Video Guide Maker</h1> <p>Build an accessible study guide from slide images and a transcript — no video needed.</p> <p class="switch">Have the source video instead? <a href="/">Use the video uploader</a>.</p> </header>
<main id="main"> <form id="img-form" enctype="multipart/form-data"> <div class="card"> <h2>1. Upload</h2>
<div class="field"> <label for="title">Study guide title</label> <input type="text" id="title" name="title" value="Lecture Study Guide" required> </div>
<div class="field"> <label for="images">Slide images</label> <input type="file" id="images" name="images" accept=".png,.jpg,.jpeg,.webp,image/png,image/jpeg,image/webp" multiple required> <p class="hint"> PNG or JPG exports, one per slide. <strong>Name each file with its time</strong> in <code>HH-MM-SS</code> form — e.g. <code>00-05-30.png</code> for the slide at 5:30. Extra text in the name is fine; the time is read from it. </p> </div>
<div class="field"> <label for="transcript">Transcript</label> <input type="file" id="transcript" name="transcript" accept=".vtt,.srt,text/vtt,application/x-subrip" required> <p class="hint">A VTT or SRT covering the whole session. Its timestamps decide which narration goes with which slide; its end sets the last slide's span.</p> </div>
<div class="field"> <label for="anthropic_api_key">Anthropic API key <small>— enables the AI features below</small></label> <input type="password" id="anthropic_api_key" name="anthropic_api_key" autocomplete="off" placeholder="sk-ant-…"> <p class="hint">Optional. Used only for this run, never stored. Without it the guide is built from the images + transcript alone.</p> </div> </div>
<div class="card"> <h2>2. AI features <small style="font-weight:400;color:var(--muted)">— optional, need an API key</small></h2> <fieldset> <legend class="sr-only">Per-slide AI enrichments</legend> <label class="toggle"> <input type="checkbox" name="llm_section_title" value="true"> <span class="t-body"><strong>Section titles</strong><small>A descriptive heading per slide instead of "Segment 3 — 5:30".</small></span> </label> <label class="toggle"> <input type="checkbox" name="llm_description" value="true"> <span class="t-body"><strong>Scene description</strong><small>An open paragraph under each slide describing what's shown. Doubles as the long-form image description for screen readers.</small></span> </label> <label class="toggle"> <input type="checkbox" name="llm_alt_text" value="true"> <span class="t-body"><strong>Alt-text drafts</strong><small>WCAG-purpose image descriptions. Skip if scene description is on.</small></span> </label> <label class="toggle"> <input type="checkbox" name="llm_ocr_text" value="true"> <span class="t-body"><strong>On-screen text (Claude)</strong><small>Reads slide text directly; better than Tesseract on coloured callouts.</small></span> </label> <label class="toggle"> <input type="checkbox" name="llm_math_equations" value="true"> <span class="t-body"><strong>Math equations</strong><small>LaTeX from on-screen formulas, with screen-reader labels.</small></span> </label> </fieldset> </div>
<div class="card"> <h2>3. Output</h2> <div class="formats" role="radiogroup" aria-label="Output format"> <label><input type="radio" name="format" value="review" checked> Editor (review & edit first)</label> <label><input type="radio" name="format" value="single"> Single HTML file</label> <label><input type="radio" name="format" value="zip"> ZIP bundle</label> </div> </div>
<button type="submit" class="submit">Build study guide</button> </form>
<div class="panel" id="panel" data-state="idle" tabindex="-1" role="status" aria-live="polite"> <strong id="panel-msg">Working…</strong> <div class="bar"><span id="bar-fill"></span></div> <pre id="panel-detail"></pre> </div> </main>
<script> (function () { const form = document.getElementById('img-form'); const panel = document.getElementById('panel'); const panelMsg = document.getElementById('panel-msg'); const barFill = document.getElementById('bar-fill'); const detail = document.getElementById('panel-detail'); const apiKeyEl = document.getElementById('anthropic_api_key');
// Toggles that don't apply to this mode but the endpoint accepts — // always send them false so nothing enables by surprise. const OFF_KEYS = ['llm_topic_segmentation', 'llm_topic_segmentation_with_images']; const CHECKBOXES = ['llm_section_title', 'llm_description', 'llm_alt_text', 'llm_ocr_text', 'llm_math_equations'];
function setProgress(state, pct, msg) { panel.setAttribute('data-state', state); if (typeof pct === 'number') barFill.style.width = Math.max(0, Math.min(100, pct)) + '%'; if (msg) panelMsg.textContent = msg; } function showError(msg, extra) { setProgress('error', 100, msg); barFill.style.width = '100%'; detail.textContent = extra || ''; form.style.display = ''; }
form.addEventListener('submit', async (e) => { e.preventDefault(); const fd = new FormData(form); // Drop an empty API key so the server doesn't see a blank string. if (typeof fd.get('anthropic_api_key') === 'string' && !fd.get('anthropic_api_key').trim()) { fd.delete('anthropic_api_key'); } // Unchecked checkboxes are absent from FormData; the endpoint // defaults them false, but send explicit false for clarity + parity. CHECKBOXES.forEach(k => { if (!fd.has(k)) fd.set(k, 'false'); }); OFF_KEYS.forEach(k => fd.set(k, 'false'));
const fmtEl = form.querySelector('input[name="format"]:checked'); const format = fmtEl ? fmtEl.value : 'review'; const title = (document.getElementById('title').value || 'Study Guide');
form.style.display = 'none'; panel.focus(); setProgress('running', 3, 'Uploading images…'); detail.textContent = ''; if (apiKeyEl) apiKeyEl.value = ''; // clear the key from the DOM after capture
let resp; try { resp = await fetch('/jobs/from-images', { method: 'POST', body: fd }); } catch (err) { showError('Upload failed', err.message); return; } if (!resp.ok) { let msg = 'HTTP ' + resp.status; try { const j = await resp.json(); msg = j.detail || j.message || msg; } catch (_) {} showError('Server rejected the upload', msg); return; } let job; try { job = await resp.json(); } catch (err) { showError('Bad response from server', ''); return; }
let lastMsg = 'Working…'; const es = new EventSource(job.events_url); es.onmessage = (event) => { let data; try { data = JSON.parse(event.data); } catch (_) { return; } if (data.type === 'progress') { lastMsg = data.message || lastMsg; setProgress('running', data.percent, data.message); } else if (data.type === 'done') { es.close(); setProgress('running', 100, 'Ready — loading…'); if (format === 'review') { window.location = job.result_url; // /result returns the editor page } else { const a = document.createElement('a'); a.href = job.result_url; document.body.appendChild(a); a.click(); a.remove(); setProgress('running', 100, 'Downloaded. Reload to build another.'); } } else if (data.type === 'error') { es.close(); showError(data.message || 'Pipeline error.', 'Last stage: ' + lastMsg); } }; es.onerror = () => { if (es.readyState === EventSource.CLOSED) { showError('Lost connection to server.', 'Last progress: ' + lastMsg); } }; }); })(); </script></body></html>922 unmodified lines923924925926927928922 unmodified lines</div><div class="vgm-drop__meta" data-meta-for="video"></div></label></div><div class="vgm-field">922 unmodified lines923924925926927928929922 unmodified lines</div><div class="vgm-drop__meta" data-meta-for="video"></div></label><p class="vgm-hint">No video, just slide exports? <a href="/images">Build from slide images + a transcript</a> instead.</p></div><div class="vgm-field">