Add the Media tab: browse sound, image and video files and open them on the PC

Media tab (needs at least one folder, hidden otherwise):
- Folders from [media] roots in config.toml, default = the user's Music, Videos
  and Pictures (XDG, never $HOME); [] disables the tab
- Icons per type, subfolders, breadcrumb, back, refresh, All/Sounds/Images/
  Videos filter; a tap opens the file on the PC (WebSocket system/open_media)
- Three special launchers (audio, image, video), editable on /admin: system
  default (gio open), installed application (gio launch) or a raw command
  (allow_custom_command); the file path is appended as the last argument
- The client never sends an absolute path: (root, relative path) is resolved
  server side; refuses "..", hidden entries, symlinks leaving the root, and
  anything but known media extensions (a script renamed .mp3 is refused)
- GET /api/media (Bearer token), listing runs in a thread, 1000 entries max

Interface cache: pages are revalidated (Cache-Control: no-cache) and static
files are served under /static/<version>/ (immutable cache), so a tablet can
no longer keep an old interface after an update. Reproduced and verified:
opening the same link serves the cached page, one refresh fixes it for good.

Refactors: restapi.py (shared REST helpers), AppPicker (shared by the launcher
and opener forms on /admin).

Tests: 159 (library escapes, openers, admin API, config, cache headers). Also
checked end to end with a real server (fake gio recording its arguments) and
headless Chromium. Not tried on the real tablet.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Denis
2026-10-26 13:32:37 +01:00
parent 353f36c888
commit 5921b7c414
22 changed files with 1876 additions and 82 deletions
+7
View File
@@ -41,6 +41,13 @@ enabled = true
# droits : tant que c'est false, /admin ne propose que des sites web et des applications installées.
allow_custom_command = false
[media]
# Dossiers parcourus par l'onglet Médias (fichiers son, image, vidéo ; chaque icône ouvre le fichier sur le PC).
# Absent : dossiers Musique, Vidéos et Images de l'utilisateur (~/.config/user-dirs.dirs). [] : onglet désactivé.
# Le jeton donne accès aux noms des fichiers de ces dossiers : n'y mettre que ce qui peut être vu depuis la tablette.
# Le lecteur de chaque type (son, image, vidéo) se choisit sur la page /admin.
# roots = ["~/Musique", "~/Vidéos", "~/Images"]
# Lanceurs : IMPORTÉS UNE SEULE FOIS dans la base (~/.local/share/mediadeck/launchers.db) au premier
# démarrage, puis gérés sur /admin ; cette section est ensuite ignorée et peut être supprimée.
# Commande en liste argv, jamais interprétée par un shell.