diff --git a/launch_viewer.py b/launch_viewer.py
index 175831f..cae99a5 100644
--- a/launch_viewer.py
+++ b/launch_viewer.py
@@ -12,6 +12,7 @@ import socket
import os
import sys
import json
+revfrom urllib.parse import urlparse, parse_qs
PORT = 5044
ROOT = os.path.dirname(os.path.abspath(__file__))
@@ -32,7 +33,17 @@ class QuietHandler(http.server.SimpleHTTPRequestHandler):
super().end_headers()
def do_POST(self):
- """Handle POST /save-flags and POST /save-corrections."""
+ """Handle POST /save-flags, /save-pass2-flags, /save-corrections, /clear-all-data.
+ All endpoints accept an optional ?diary=ID query param to use per-diary files.
+ """
+ parsed = urlparse(self.path)
+ qs = parse_qs(parsed.query)
+ diary = qs.get('diary', ['unknown'])[0]
+ # Sanitize: only allow alphanumeric, hyphens, underscores
+ diary = ''.join(c for c in diary if c.isalnum() or c in '-_')
+ if not diary:
+ diary = 'unknown'
+
length = int(self.headers.get('Content-Length', 0))
body = self.rfile.read(length)
try:
@@ -41,8 +52,8 @@ class QuietHandler(http.server.SimpleHTTPRequestHandler):
self.send_response(400); self.end_headers()
return
- if self.path == '/save-flags':
- dest = os.path.join(ROOT, 'flags.json')
+ if parsed.path == '/save-flags':
+ dest = os.path.join(ROOT, 'flags-' + diary + '.json')
with open(dest, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=2)
self.send_response(200)
@@ -50,9 +61,8 @@ class QuietHandler(http.server.SimpleHTTPRequestHandler):
self.end_headers()
self.wfile.write(b'{"ok":true}')
- elif self.path == '/save-corrections':
- dest = os.path.join(ROOT, 'corrections.json')
- # Load existing, update single page entry, write back
+ elif parsed.path == '/save-corrections':
+ dest = os.path.join(ROOT, 'corrections-' + diary + '.json')
existing = {}
if os.path.exists(dest):
try:
@@ -60,10 +70,10 @@ class QuietHandler(http.server.SimpleHTTPRequestHandler):
existing = json.load(f)
except Exception:
pass
- page = str(data.get('page', ''))
- text = data.get('text', '')
- if text.strip():
- existing[page] = text
+ page = str(data.get('page', ''))
+ correction = data.get('correction')
+ if correction:
+ existing[page] = correction
else:
existing.pop(page, None)
with open(dest, 'w', encoding='utf-8') as f:
@@ -73,6 +83,32 @@ class QuietHandler(http.server.SimpleHTTPRequestHandler):
self.end_headers()
self.wfile.write(b'{"ok":true}')
+ elif parsed.path == '/save-pass2-flags':
+ dest = os.path.join(ROOT, 'pass2_flags-' + diary + '.json')
+ try:
+ with open(dest, 'w', encoding='utf-8') as f:
+ json.dump(data, f, indent=2)
+ except Exception:
+ self.send_response(500); self.end_headers()
+ return
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+ self.wfile.write(b'{"ok":true}')
+
+ elif parsed.path == '/clear-all-data':
+ for prefix in ['flags-', 'corrections-', 'pass2_flags-']:
+ fpath = os.path.join(ROOT, prefix + diary + '.json')
+ if os.path.exists(fpath):
+ try:
+ os.remove(fpath)
+ except Exception:
+ pass
+ self.send_response(200)
+ self.send_header('Content-Type', 'application/json')
+ self.end_headers()
+ self.wfile.write(b'{"ok":true}')
+
else:
self.send_response(404); self.end_headers()
@@ -88,7 +124,7 @@ def start_server():
if __name__ == '__main__':
- url = 'http://localhost:{}/p44-ocr-viewer.html'.format(PORT)
+ url = 'http://localhost:{}/p44-landing.html'.format(PORT)
if port_in_use(PORT):
print('\n P44 OCR Viewer (server already running)')
diff --git a/p44-landing.html b/p44-landing.html
new file mode 100644
index 0000000..d98aa0b
--- /dev/null
+++ b/p44-landing.html
@@ -0,0 +1,337 @@
+
+
+
+
+
+P44 OCR — War Diary Transcription
+
+
+
+
+
+
⚜ P44 War Diary Transcription
+ Pass 1 — Volunteer
+
+
+
+
War diaries available for transcription
+
+
+
+
+
+
+
+
+
+
+
diff --git a/p44-ocr-viewer.css b/p44-ocr-viewer.css
new file mode 100644
index 0000000..302fc4d
--- /dev/null
+++ b/p44-ocr-viewer.css
@@ -0,0 +1,513 @@
+/* ── Reset & base ─────────────────────────────────────────────── */
+*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
+
+:root {
+ --bg: #1a1a2e;
+ --surface: #16213e;
+ --surface2: #0f3460;
+ --gold: #c8a84b;
+ --gold-dim: #8a6f2e;
+ --text: #ddd4bb;
+ --text-dim: #7a7260;
+ --highlight: #ffe066;
+ --border: #2e2e4e;
+ --toolbar-h: 52px;
+ --footer-h: 34px;
+}
+
+html, body {
+ height: 100%;
+ background: var(--bg);
+ color: var(--text);
+ font-family: 'Georgia', 'Times New Roman', serif;
+ font-size: 14px;
+ overflow: hidden;
+}
+
+/* ── App shell ────────────────────────────────────────────────── */
+#app {
+ display: grid;
+ grid-template-rows: var(--toolbar-h) auto 1fr var(--footer-h);
+ height: 100vh;
+}
+
+/* ── Override dropdown ────────────────────────────────────────── */
+#override-wrap {
+ position: relative;
+ flex-shrink: 0;
+}
+
+#override-menu {
+ display: none;
+ position: absolute;
+ top: calc(100% + 4px);
+ left: 0;
+ z-index: 500;
+ background: var(--surface);
+ border: 1px solid var(--gold-dim);
+ border-radius: 4px;
+ min-width: 160px;
+ padding: 4px 0;
+ box-shadow: 0 4px 14px rgba(0,0,0,0.45);
+}
+
+#override-menu.open { display: block; }
+
+.override-item {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 7px 14px;
+ font-family: 'Georgia', serif;
+ font-size: 11px;
+ color: var(--text-dim);
+ cursor: pointer;
+ white-space: nowrap;
+ letter-spacing: 0.03em;
+ transition: background 0.1s, color 0.1s;
+}
+.override-item:hover { background: var(--surface2); color: var(--gold); }
+.override-item input[type="file"] { display: none; }
+
+/* ── Toolbar ──────────────────────────────────────────────────── */
+#toolbar {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ padding: 0 12px;
+ background: var(--surface);
+ border-bottom: 2px solid var(--gold-dim);
+ overflow: visible; /* must be visible so the Override dropdown can escape the toolbar */
+ flex-wrap: nowrap;
+ position: relative;
+ z-index: 100; /* sit above pass2-banner and panel headers */
+}
+
+#toolbar h1 {
+ font-size: 13px;
+ font-weight: normal;
+ letter-spacing: 0.1em;
+ color: var(--gold);
+ white-space: nowrap;
+ flex-shrink: 0;
+}
+
+.divider { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; margin: 0 2px; }
+
+.toolbar-group {
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ flex-shrink: 0;
+}
+.toolbar-group .lbl {
+ font-size: 9px;
+ color: var(--text-dim);
+ letter-spacing: 0.06em;
+ white-space: nowrap;
+}
+
+.file-btn {
+ display: inline-block;
+ padding: 3px 8px;
+ background: var(--surface2);
+ border: 1px solid var(--gold-dim);
+ border-radius: 3px;
+ color: var(--text);
+ font-size: 10px;
+ cursor: pointer;
+ letter-spacing: 0.03em;
+ transition: border-color 0.15s, background 0.15s;
+ white-space: nowrap;
+}
+.file-btn:hover { border-color: var(--gold); background: #1a2a50; }
+.file-btn input[type="file"] { display: none; }
+
+.tb-btn {
+ padding: 3px 9px;
+ background: transparent;
+ border: 1px solid var(--gold-dim);
+ border-radius: 3px;
+ color: var(--text-dim);
+ font-size: 10px;
+ font-family: inherit;
+ letter-spacing: 0.05em;
+ cursor: pointer;
+ transition: border-color 0.15s, color 0.15s, background 0.15s;
+ white-space: nowrap;
+ flex-shrink: 0;
+}
+.tb-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(200,168,75,0.08); }
+a.tb-btn { text-decoration: none; display: inline-flex; align-items: center; }
+
+#scale-select {
+ background: var(--surface2);
+ border: 1px solid var(--gold-dim);
+ border-radius: 3px;
+ color: var(--text);
+ font-size: 10px;
+ font-family: inherit;
+ padding: 2px 4px;
+ cursor: pointer;
+}
+
+/* ── Main panels ──────────────────────────────────────────────── */
+#panels {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ overflow: hidden;
+}
+
+.panel {
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ border-right: 1px solid var(--border);
+}
+.panel:last-child { border-right: none; }
+
+.panel-header {
+ padding: 5px 10px;
+ font-size: 9px;
+ letter-spacing: 0.12em;
+ color: var(--gold-dim);
+ text-transform: uppercase;
+ background: var(--surface);
+ border-bottom: 1px solid var(--border);
+ flex-shrink: 0;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+.panel-header .ph-title { flex: 1; }
+
+/* page navigation */
+.page-nav { display: flex; align-items: center; gap: 4px; }
+.page-nav button {
+ background: var(--surface2); border: 1px solid var(--gold-dim);
+ border-radius: 2px; color: var(--text); font-size: 10px;
+ padding: 1px 6px; cursor: pointer; line-height: 1.5;
+}
+.page-nav button:hover { border-color: var(--gold); color: var(--gold); }
+.page-nav button:disabled { opacity: 0.3; cursor: default; }
+.page-nav input[type="number"] {
+ width: 42px; text-align: center;
+ background: var(--surface2); border: 1px solid var(--gold-dim);
+ border-radius: 2px; color: var(--text); font-size: 9px; padding: 2px 3px;
+}
+#page-label { font-size: 9px; color: var(--text-dim); white-space: nowrap; }
+
+.panel-body {
+ flex: 1;
+ overflow: auto;
+ position: relative;
+}
+
+/* ── Left panel: PDF canvas + overlay ────────────────────────── */
+#image-panel-body {
+ position: relative;
+ scrollbar-gutter: stable; /* reserve scrollbar space always — prevents layout shift on zoom */
+}
+
+#pdf-container {
+ position: relative;
+ display: block; /* block instead of inline-block — fills full panel width cleanly */
+ width: 100%;
+ min-height: 100%; /* always occupies the full panel height so nothing else renders below */
+}
+
+#pdf-canvas {
+ display: block;
+ user-select: none;
+ background: #e8e0cc;
+}
+
+#overlay {
+ position: absolute;
+ top: 0; left: 0;
+ pointer-events: none;
+}
+
+/* noinspection CssUnusedSymbol */
+.word-box {
+ position: absolute;
+ border: 1px solid transparent;
+ border-radius: 1px;
+ cursor: crosshair;
+ pointer-events: all;
+ transition: background 0.07s, border-color 0.07s;
+}
+/* noinspection CssUnusedSymbol */
+.word-box:hover,
+/* noinspection CssUnusedSymbol */
+.word-box.highlight {
+ background: rgba(255, 224, 102, 0.38);
+ border-color: var(--highlight);
+}
+
+.panel-placeholder {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ height: 100%;
+ gap: 12px;
+ color: var(--text-dim);
+ font-size: 13px;
+ font-style: italic;
+ padding: 40px;
+ text-align: center;
+}
+.panel-placeholder em {
+ color: var(--gold-dim);
+ font-size: 11px;
+ font-style: normal;
+ letter-spacing: 0.04em;
+}
+
+.spinner {
+ width: 22px; height: 22px;
+ border: 2px solid var(--surface2);
+ border-top-color: var(--gold);
+ border-radius: 50%;
+ animation: spin 0.7s linear infinite;
+}
+@keyframes spin { to { transform: rotate(360deg); } }
+
+/* ── Footer ───────────────────────────────────────────────────── */
+#footer {
+ display: flex;
+ align-items: center;
+ padding: 0 12px;
+ gap: 10px;
+ background: var(--surface);
+ border-top: 1px solid var(--border);
+ font-size: 10px;
+ color: var(--text-dim);
+}
+#status-msg { flex: 1; font-style: italic; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
+
+/* ── Scrollbars ───────────────────────────────────────────────── */
+::-webkit-scrollbar { width: 7px; height: 7px; }
+::-webkit-scrollbar-track { background: var(--bg); }
+::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 4px; }
+::-webkit-scrollbar-thumb:hover { background: var(--gold-dim); }
+
+/* ── Active toggle button state (sync-scroll, edit mode) ─────── */
+.tb-btn.active { border-color: var(--gold); color: var(--gold); }
+
+/* ── Flag buttons ─────────────────────────────────────────────── */
+.flag-btn { font-size: 9px; padding: 2px 7px; }
+.flag-btn.active { border-color: var(--gold); color: var(--gold); }
+/* ── Footer extras ────────────────────────────────────────────── */
+#flags-summary { color: var(--gold-dim); letter-spacing: 0.04em; white-space: nowrap; font-size: 10px; }
+#kbd-hint { color: var(--text-dim); font-size: 9px; white-space: nowrap; opacity: 0.7; }
+
+
+/* ── Zoom indicator in left panel header ─────────────────────────── */
+#zoom-label {
+ font-size: 9px; color: var(--gold-dim); letter-spacing: 0.06em;
+ white-space: nowrap; min-width: 34px; text-align: right;
+}
+#btn-zoom-reset {
+ padding: 1px 6px; font-size: 9px; font-family: inherit;
+ background: transparent; border: 1px solid var(--gold-dim);
+ border-radius: 2px; color: var(--text-dim); cursor: pointer;
+ letter-spacing: 0.04em; white-space: nowrap;
+ transition: border-color 0.12s, color 0.12s;
+}
+#btn-zoom-reset:hover { border-color: var(--gold); color: var(--gold); }
+
+/* ── Role switcher ────────────────────────────────────────────────── */
+#role-select {
+ background: var(--surface2);
+ border: 1px solid var(--gold-dim);
+ border-radius: 3px;
+ color: var(--text);
+ font-size: 10px;
+ font-family: inherit;
+ padding: 2px 4px;
+ cursor: pointer;
+}
+
+/* ── Pass 2 review banner ─────────────────────────────────────────── */
+#pass2-banner {
+ display: none;
+ align-items: center;
+ padding: 0 14px;
+ background: #2e2010;
+ border-bottom: 1px solid #c08020;
+ font-size: 11px;
+ color: #e8b848;
+ letter-spacing: 0.04em;
+ height: 26px;
+ overflow: hidden;
+ white-space: nowrap;
+ flex-shrink: 0;
+}
+
+/* ── Pass 2 revert bar ────────────────────────────────────────── */
+#pass2-revert-bar {
+ display: none;
+ align-items: center;
+ gap: 8px;
+ padding: 6px 16px;
+ background: var(--surface);
+ border-bottom: 1px solid var(--border);
+ flex-shrink: 0;
+}
+#pass2-revert-bar .rv-label {
+ font-size: 10px;
+ color: var(--text-dim);
+ letter-spacing: 0.04em;
+ flex: 1;
+}
+#pass2-revert-bar .rv-btn {
+ font-size: 10px;
+ font-family: 'Georgia', serif;
+ padding: 3px 10px;
+ border-radius: 3px;
+ border: 1px solid var(--border);
+ background: transparent;
+ color: var(--text-dim);
+ cursor: pointer;
+ letter-spacing: 0.04em;
+ transition: border-color 0.15s, color 0.15s;
+}
+#pass2-revert-bar .rv-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
+#pass2-revert-bar .rv-btn.danger { border-color: var(--red, #d05050); color: var(--red, #d05050); }
+#pass2-revert-bar .rv-btn.danger:hover { border-color: var(--red, #d05050); color: var(--text); }
+
+/* ── Pass 2 change summary panel ─────────────────────────────── */
+#pass2-change-summary {
+ display: none;
+ padding: 10px 20px;
+ background: var(--surface2);
+ border-bottom: 1px solid var(--gold-dim);
+ flex-shrink: 0;
+ font-size: 11px;
+}
+#pass2-change-summary .cs-title {
+ font-size: 10px;
+ color: var(--gold-dim);
+ letter-spacing: 0.08em;
+ text-transform: uppercase;
+ margin-bottom: 6px;
+}
+#pass2-change-summary .cs-list {
+ color: var(--text-dim);
+ line-height: 1.8;
+ max-height: 100px;
+ overflow-y: auto;
+ margin-bottom: 8px;
+ font-family: Georgia, serif;
+}
+#pass2-change-summary .cs-changed { color: #e8a838; }
+#pass2-change-summary .cs-added { color: #4caf70; }
+#pass2-change-summary .cs-deleted { color: #d05050; }
+#pass2-change-summary .cs-actions { display: flex; gap: 8px; }
+.cs-revert-btn {
+ font-size: 10px;
+ font-family: Georgia, serif;
+ padding: 3px 10px;
+ border-radius: 3px;
+ border: 1px solid var(--border);
+ background: transparent;
+ color: var(--text-dim);
+ cursor: pointer;
+ letter-spacing: 0.04em;
+}
+.cs-revert-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
+.cs-revert-btn.danger { border-color: #d05050; color: #d05050; }
+.cs-revert-btn.danger:hover { border-color: #e07070; color: #e07070; }
+
+/* ── Plain-text edit surface ──────────────────────────────────── */
+#text-panel-body {
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ min-height: 0;
+ overflow: hidden;
+}
+
+#editor-wrap {
+ display: flex;
+ flex-direction: row;
+ flex: 1;
+ min-height: 0;
+ overflow: hidden;
+}
+
+#line-numbers {
+ width: 48px;
+ flex-shrink: 0;
+ background: transparent;
+ border-right: 1px solid var(--border);
+ color: var(--gold-dim);
+ font-family: 'Courier New', monospace;
+ font-size: 11px;
+ line-height: 1.75;
+ padding: 0 8px 0 12px;
+ text-align: right;
+ overflow: hidden;
+ user-select: none;
+ white-space: pre;
+ box-sizing: border-box;
+ margin-right: 12px;
+}
+
+#text-editor {
+ display: block; /* always block — visibility via #editor-wrap */
+ flex: 1;
+ min-width: 0;
+ min-height: 0;
+ width: 100%;
+ height: 100%;
+ background: var(--surface2);
+ color: var(--text);
+ font-family: 'Georgia', 'Times New Roman', serif;
+ font-size: 12.5px;
+ line-height: 1.75;
+ padding: 0 16px 0 0;
+ border: none;
+ border-radius: 0;
+ resize: none;
+ outline: none;
+ box-sizing: border-box;
+ overflow-y: auto;
+ overflow-x: hidden;
+}
+
+/* ── Done-page read-only banner (Pass 1) ─────────────────────── */
+#done-banner {
+ display: none;
+ align-items: center;
+ gap: 8px;
+ padding: 7px 16px;
+ background: #0f2a0f;
+ border-bottom: 1px solid #2e6e2e;
+ font-size: 10px;
+ color: #5cb85c;
+ letter-spacing: 0.05em;
+ flex-shrink: 0;
+}
+
+/* ── Problem flag indicator on page nav input ─────────────────── */
+#page-input.problem { border-color: #c08020; }
+
+/* ── OCR overlay panel (replaces raster in left panel) ───────── */
+#ocr-overlay-panel {
+ display: none;
+ position: absolute;
+ inset: 0;
+ overflow-y: auto;
+ background: var(--surface);
+ padding: 20px 24px;
+ font-size: 13px;
+ line-height: 1.8;
+ color: var(--text);
+ font-family: 'Georgia', 'Times New Roman', serif;
+ white-space: pre-wrap;
+ word-break: break-word;
+ z-index: 10;
+}
diff --git a/p44-ocr-viewer.html b/p44-ocr-viewer.html
index ac7d1e9..2c3ad2e 100644
--- a/p44-ocr-viewer.html
+++ b/p44-ocr-viewer.html
@@ -3,400 +3,56 @@
-P44 OCR Viewer — Calgary Highlanders Sep 44
+P44 OCR Viewer
-
+
@@ -461,954 +117,16 @@ html, body {
-
+