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 <noreply@anthropic.com>
This commit is contained in:
Denis Defolie
2026-10-30 16:57:29 +01:00
parent df2c9b8933
commit 6c1a7efb0d
10 changed files with 206 additions and 37 deletions
+10 -5
View File
@@ -73,14 +73,19 @@ class ListingTest(LibraryCase):
["CD 2", "CD 10", "Piste 1.mp3", "piste 2.mp3", "piste 10.mp3"],
)
def test_images_carry_their_modification_date_for_thumbnail_caching(self) -> None:
def test_files_carry_their_date_and_size_but_folders_do_not(self) -> None:
# La date versionne l'adresse de la miniature ; date et taille servent au tri côté client
touch(self.root / "a.jpg")
touch(self.root / "b.mp3")
touch(self.root / "c.mkv")
(self.root / "b.mp3").write_bytes(b"x" * 1234)
(self.root / "Dossier").mkdir()
os.utime(self.root / "a.jpg", (1_700_000_000, 1_700_000_000))
os.utime(self.root / "b.mp3", (1_700_000_500, 1_700_000_500))
entries = {entry["name"]: entry for entry in self.library.list("musique", "")["entries"]}
self.assertEqual(entries["a.jpg"], {"name": "a.jpg", "kind": "image", "v": 1_700_000_000})
self.assertEqual(entries["b.mp3"], {"name": "b.mp3", "kind": "audio"})
self.assertEqual(entries["a.jpg"]["v"], 1_700_000_000)
self.assertEqual(entries["b.mp3"], {"name": "b.mp3", "kind": "audio", "v": 1_700_000_500, "size": 1234})
self.assertEqual(set(entries["c.mkv"]), {"name", "kind", "v", "size"}) # vidéo aussi
self.assertEqual(entries["Dossier"], {"name": "Dossier", "kind": "dir"})
def test_subfolder_and_parent(self) -> None:
@@ -360,11 +365,11 @@ class SearchTest(LibraryCase):
self.assertEqual({entry["root"] for entry in result["entries"]}, {"musique", "videos"})
self.assertIsNone(result["root"])
def test_image_results_carry_their_version(self) -> None:
def test_results_carry_their_version_and_size(self) -> None:
os.utime(self.root / "Photos" / "ete-2020.JPG", (1_700_000_000, 1_700_000_000))
result = self.library.search("2020", "musique")
self.assertEqual(result["entries"], [
{"name": "ete-2020.JPG", "kind": "image", "v": 1_700_000_000, "root": "musique", "folder": "Photos"}])
{"name": "ete-2020.JPG", "kind": "image", "v": 1_700_000_000, "size": 1, "root": "musique", "folder": "Photos"}])
def test_link_loops_do_not_hang_or_duplicate_results(self) -> None:
os.symlink(self.root, self.root / "Rock" / "boucle") # boucle vers la racine