From 6c1a7efb0d66cc63d7fe8b1c7bcdea1ed0471188 Mon Sep 17 00:00:00 2001 From: Denis Defolie Date: Fri, 30 Oct 2026 16:57:29 +0100 Subject: [PATCH] Media tab: sort by name, date or size, and thumbnails for videos and sounds The listing now returns the date (v) and size of every file, not just of images. A selector next to the type filters sorts files by name (natural order, default), date (newest first) or size (largest first), client side; folders stay first and the choice is remembered on the tablet. Video and sound tiles now request /thumb like images (the server already made them). The existing icon fallback covers a sound without a cover. Audio and video tiles with a thumbnail get a border in their type colour. Tests: listing date and size, a Chromium sort test with three files whose name, date and size orders all differ (kept after reload), and a thumbnail test with real ffmpeg. Both UI tests were checked to fail when the feature is reverted. Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 11 ++-- README-EN.md | 13 +++-- README.md | 12 +++- mediadeck/media.py | 29 ++++++---- mediadeck/web/index.html | 1 + mediadeck/web/static/app.js | 34 ++++++++++- mediadeck/web/static/style.css | 11 ++++ tests/stack.py | 14 ++++- tests/test_media.py | 15 +++-- tests/test_ui_flows.py | 103 ++++++++++++++++++++++++++++++++- 10 files changed, 206 insertions(+), 37 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 2d0ea30..16d2448 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -120,9 +120,9 @@ Chaque modification déclenche `notify()` : les tablettes reçoivent la nouvelle ### API REST des médias ``` -GET /api/media?root=&path= {root, path, parent (null au sommet d'une racine), entries:[{name, kind: dir|audio|image|video, v?}], truncated} +GET /api/media?root=&path= {root, path, parent (null au sommet d'une racine), entries:[{name, kind: dir|audio|image|video, v?, size?}] (v = date du fichier en secondes, size = octets : tous les fichiers, jamais les dossiers), truncated} 400 chemin invalide / hors racine / pas un dossier ; 404 racine ou dossier inconnu ; route absente si aucun dossier -GET /api/media/search?q=&root=&path= {query, root, entries:[{name, kind, root, folder, v?}], truncated} ; root absent = toutes les racines ; 400 requête < 2 caractères, > 100, > 8 mots +GET /api/media/search?q=&root=&path= {query, root, entries:[{name, kind, root, folder, v?, size?}], truncated} ; root absent = toutes les racines ; 400 requête < 2 caractères, > 100, > 8 mots GET /thumb?root=&path=&size=160|320|640&token= image/jpeg (carré recadré), Cache-Control private 1 jour ; 401 sans jeton (dans l'URL comme /art), 400 taille/chemin invalide, 404 aucune miniature ; route montée seulement si ffmpeg est présent GET /api/media/openers {openers:[{type, kind, spec}] (audio, image, video), kinds:[default,app,command], allow_command} (admin.enabled) PUT /api/media/openers/{type} {kind, spec} → 200 ; 404 type inconnu ; 403 commande brute sans allow_custom_command (admin.enabled) @@ -152,13 +152,14 @@ La pochette locale (`file://`) n'est jamais transmise : elle est remplacée par - Les proxies dbus-next sont typés `Any`, car leurs méthodes `call_*` / `on_*` sont générées dynamiquement. - **Page des QR codes = fichier local, jamais une route du serveur** (`make qr`, `--qr`, module `qrpage.py`) : les QR codes contiennent le jeton, une route `/qr` le donnerait à tout le LAN (même limitée à la boucle locale, elle serait fragile derrière un proxy). Page autonome écrite en 600 dans `$XDG_RUNTIME_DIR/mediadeck/access.html` (tmpfs) et ouverte en `file://` : pas de CSP à contourner (`