From 907fd90a5e5fb73acff2b96bcf8cd9b1a17acb46 Mon Sep 17 00:00:00 2001 From: jonathan Date: Wed, 10 Jun 2026 11:49:35 +0200 Subject: [PATCH] refactor: extract web UI page into webui.html MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit web.py was 1700 lines, more than half of it a single embedded HTML string. The page now lives in webui.html (loaded once at startup), so the frontend gets real syntax highlighting and web.py is pure Python. Dockerfile copies the new file alongside web.py. Also: ASCII startup banner (the arrow glyph crashed web.py on Windows when stdout was redirected to a cp1252 file), and README fixes — document the ALSA PCM-name device fallback and drop the monitor device row, which the ALSA backend never supported. Co-Authored-By: Claude Fable 5 --- Dockerfile | 2 +- README.md | 4 +- web.py | 975 +---------------------------------------------------- webui.html | 964 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 974 insertions(+), 971 deletions(-) create mode 100644 webui.html diff --git a/Dockerfile b/Dockerfile index 33a9dae..7fcc4de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ WORKDIR /app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt -COPY isr.py web.py ./ +COPY isr.py web.py webui.html ./ RUN mkdir -p /recordings diff --git a/README.md b/README.md index 7c81123..0bb6ec4 100644 --- a/README.md +++ b/README.md @@ -102,9 +102,9 @@ format = wav # wav | flac | Value | Behaviour | |-------|-----------| | `default` | System default input | -| `monitor` | First loopback/monitor source (capture system audio) | | `` | Case-insensitive substring match against device name | | `hw:X,Y` | Exact ALSA hardware ID | +| `` | Any ALSA PCM defined in `asound.conf` (e.g. the `shared_mic` dsnoop device), even if it doesn't appear in `arecord -l` | Run `python isr.py --list-devices` (or `arecord -l`) to see available devices and their IDs. @@ -155,6 +155,8 @@ python web.py --min-gap 15 # grace period in seconds for merging python web.py --analyses-dir /path/to/dir # where to store analysis cache files (default: /analyses) ``` +The browser UI (HTML/CSS/JS) lives in `webui.html`, which `web.py` loads at startup — keep the two files together. + Shows recordings grouped by day with collapsible sections. Features: - **Day groups** — recordings are grouped under a collapsible day heading showing date, file count, total duration, and total size. The most recent day is expanded by default; older days start collapsed. Expanded state is preserved across filter changes. diff --git a/web.py b/web.py index 20f7a33..fad7e06 100644 --- a/web.py +++ b/web.py @@ -627,973 +627,10 @@ class _Handler(BaseHTTPRequestHandler): # --------------------------------------------------------------------------- -# Embedded HTML / CSS / JS +# UI page — single-page HTML/CSS/JS, loaded once at startup # --------------------------------------------------------------------------- -_HTML = r""" - - - - -ISR Archive - - - -
- -
-

ISR Archive

- Loading… - - -
-
- - - RMS amplitude 0–1 (linear; 0.05 ≈ −26 dBFS) · sections above this are marked loud - - - seconds to rewind before section start - - - seconds — merge loud sections closer than this -
- -
-
- -
- - -""" +_HTML = (Path(__file__).resolve().parent / 'webui.html').read_text(encoding='utf-8') # --------------------------------------------------------------------------- @@ -1633,10 +670,10 @@ def main(): server = ThreadingHTTPServer((args.host, args.port), Handler) - print(f"ISR Web running → http://{args.host}:{args.port}/") - print(f"Recordings dir → {rec_dir}") - print(f"Analyses dir → {analyses_dir}") - print(f"Loud threshold → {args.threshold}") + print(f"ISR Web running on http://{args.host}:{args.port}/") + print(f"Recordings dir: {rec_dir}") + print(f"Analyses dir: {analyses_dir}") + print(f"Loud threshold: {args.threshold}") if not NUMPY_AVAILABLE: print("Note: numpy not installed — WAV RMS uses pure Python (slower); FLAC analysis unavailable") elif not SOUNDFILE_AVAILABLE: diff --git a/webui.html b/webui.html new file mode 100644 index 0000000..266bbbf --- /dev/null +++ b/webui.html @@ -0,0 +1,964 @@ + + + + + +ISR Archive + + + +
+ +
+

ISR Archive

+ Loading… + + +
+
+ + + RMS amplitude 0–1 (linear; 0.05 ≈ −26 dBFS) · sections above this are marked loud + + + seconds to rewind before section start + + + seconds — merge loud sections closer than this +
+ +
+
+ +
+ + + \ No newline at end of file