Skip to content

feat: add document support, previews, and media type filters - #780

Open
Lolle2000la wants to merge 4 commits into
masterfrom
feat/document-support
Open

Lolle2000la wants to merge 4 commits into
masterfrom
feat/document-support

Conversation

@Lolle2000la

Copy link
Copy Markdown
Owner

Summary

Adds document format management (MediaType::Document, DocumentKind), bounded thumbnails/previews/metadata extraction, active-session media type filter chips, and related settings/translations/docs across media-sort-core, media-sort-backend, media-sort-gui, resources/locale/{en,de,ja}, and website/.

Core Built-in Document Support (Pure Rust)

  • PDF (.pdf): hayro 0.9 page-0 white-paper thumbnail, high-res multi-page RGBA preview (Prev/Next, PageUp/PageDown), PDF metadata (Pages, Title, Author, Subject, Creator, Producer, Created). Encrypted PDFs return Ok(None) thumbnail (no media_errors noise) and an Encrypted preview card with [Open Externally].
  • Comic Archives (.cbz, .cb7, .cbt, .cbr): Natural page sorting (page2 < page10), bounded decompression via zip / sevenz-rust2 / tar / rarchive (with optional host unrar/7z fallback outside Flatpak/Snap), optional ComicInfo.xml metadata, shared multi-page image preview.
  • EPUB (.epub): container.xml + OPF cover image thumbnail, metadata (Chapters, Title, Author, Publisher, Language, Date, Identifier), spine chapter XHTML-to-Markdown preview via iced::widget::markdown, chapter Prev/Next navigation, and path-traversal sanitization (sanitize_archive_rel_path).
  • Plain Text & Delimited Tables (.txt, .md, .markdown, .csv, .tsv): Bounded UTF-8 read (<=256 KiB with NUL-byte binary rejection), iced::widget::markdown rendering with http:///https://-only link handling, CSV/TSV spreadsheet table grid, monospace plain-text viewer.

Hybrid Office & OS Integration

  • Grid Thumbnails: Embedded archive thumbnails (Thumbnails/thumbnail.png, docProps/thumbnail.*) -> OS native thumbnailer (QLThumbnailGenerator on macOS, IShellItemImageFactory SIIGBF_THUMBNAILONLY on Windows) -> Ok(None) cleanly (ThumbnailCancelled -> Lucide subtype fallback icon, never recorded in media_errors, never spawns soffice in grid scans).
  • Spreadsheets (.xlsx, .xlsm, .xlsb, .xls, .ods): Multi-sheet interactive viewer via calamine.
  • Office Previews (.docx, .odt, .pptx, .odp, .doc, .ppt, .rtf): Uses headless LibreOffice (soffice --headless --convert-to pdf) + hayro multi-page rendering when advanced.enable_libreoffice_preview is enabled and host soffice is detected outside Flatpak/Snap sandboxes; falls back to pure-Rust DOCX/ODT Markdown extraction, PPTX/ODP Slides card view, RTF stripped text, or OS preview / NoPreviewBackend card for legacy .doc/.ppt.

Filtering, Settings & Localization

  • Added active-session filter chips (Images, Video, Audio, Documents with per-type counts) above the media grid so loose mixed folders can be filtered on the fly without touching config.
  • Added general.show_documents_by_default (bool, default true) and advanced.enable_libreoffice_preview (bool, default true), persisted in config.toml and exposed in the Settings dialog + localized docs (en/de/ja).
  • Updated pre-existing filesystem_tests::test_scan_filtered_by_extension from .txt to .bin since .txt is now a scanned document type.

Verification

Run on Linux (x86_64) in /home/luca/development/Media-Sort-documents:

  • cargo fmt --all -- — passed
  • cargo clippy --workspace --all-targets -- -D warnings — passed (only pre-existing manifest unused-dep warnings on webp in benchmarks and tracing in media-sort-core)
  • cargo test --workspace — all workspace suites passed (0 failures; iced-mpv has 1 pre-existing ignored doctest), including:
    • media-sort-core: 137 unit + 5 detect_locale_tests + 3 locale_tests
    • media-sort-backend: 41 unit + 2 audio_tests + 14 document_tests + 12 filesystem_tests + 51 + 10 integration tests
    • media-sort-gui: 230 unit + 23 integration tests
    • benchmarks: 21 + 11 + 23 tests
  • cargo check -p media-sort-gui --features demo, --features velopack, and media-sort-backend --features pulse — all passed
  • npm --prefix website ci && npm --prefix website run format && npm --prefix website run lint && npm --prefix website run build — passed (59 pages built cleanly)

Known Caveats & Untested Paths

  • macOS & Windows OS thumbnailers (os_preview.rs): Implemented against objc2-quick-look-thumbnailing/objc2-core-graphics and windows 0.62 crate APIs, but compiled/verified on Linux only so far; Apple/Windows CI runners in this PR will verify cross-OS compilation and tests.
  • rarchive (zstd-sys) & .cbr tests: rarchive compiles C zstd-sys cleanly on Linux; corrupt/empty .cbr handling is tested, while creating a real .cbr archive in tests was skipped because no proprietary rar encoder CLI is installed on the test host.
  • PDF rendering (hayro 0.9): Upstream hayro does not decrypt encrypted PDFs (handled gracefully with an Encrypted UI card) and lacks some advanced blend/knockout groups.
  • Sandboxes (Flatpak / Snap): External host CLIs (soffice, unrar, 7z) are deliberately disabled when is_sandboxed() detects Flatpak or Snap, relying on pure-Rust fallbacks and [Open Externally].

@github-actions

Copy link
Copy Markdown
Contributor

flatpak/cargo-sources.json was out of date with Cargo.lock; I regenerated it and pushed it to this branch.

@Lolle2000la

Copy link
Copy Markdown
Owner Author

Added pure-Rust .svg and .svgz image support via resvg 0.50 (classified under MediaType::Image), blocking local/external <image> references and enforcing bounded flate2 SVGZ decompression. Also updated credits, AGENTS.md, and media-capabilities.mdx across en/de/ja.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant