Document Library & Indexing
Relevant source files
The following files were used as context for generating this wiki page:
The Document Library & Indexing system serves as a centralized management hub for PDF and PNG files within the Duplicator application. It provides users with the ability to upload, search, and preview documents, while also offering advanced features such as full-text search and external directory indexing. This module integrates closely with other document processing tools, allowing files stored in the library to be sent directly to imposition, color separation, or image processing workflows.
Sources: README.md:27-32, app/view/bibliotheque.html.php:1-40
System Architecture and Components
The system is built using a client-server architecture where the frontend handles user interactions like drag-and-drop uploads and search queries, while the backend manages file storage, metadata indexing, and directory scanning. The library supports two primary modes of file addition: direct upload to internal storage and indexing of external folders where files remain in their original location.
Core Components
| Component | Description | Source |
|---|---|---|
| Storage Resolver | Logic to determine the physical path for the library based on environment (AppImage, Windows, or Dev). | app/controler/functions/bibliotheque.php:7-39 |
| Directory Scanner | Utility to recursively scan folders for compatible file types (PDF, PNG). | app/controler/functions/bibliotheque.php:54-87 |
| File Grid UI | A responsive interface for displaying file cards with thumbnails and action menus. | app/view/bibliotheque.html.php:43-200 |
| PDF.js Viewer | Integrated document viewer for high-fidelity PDF and PNG previews. | app/view/bibliotheque.html.php:204-580 |
| API Endpoints | Routing for search, indexing, upload, and thumbnail retrieval. | app/public/index.php:170-215 |
Data Flow and Interaction
The following sequence diagram illustrates the process of searching for and previewing a document within the library.
Directory Indexing and Path Resolution
The library relies on a robust path resolution strategy to maintain compatibility across different deployment environments (Electron, Caddy, or standalone PHP).
Path Resolution Logic
The system resolves the library directory (bibliotheque) by checking the following priorities:
- Environment Variable:
DUPLI_BIBLIOTHEQUE_DIR. - Database Configuration: Proximity to the configured database path.
- AppImage Detection: Use of
.config/Duplicator/bibliothequein the user's home directory. - Local Development: Relative path
../../bibliotheque.
Sources: app/controler/functions/bibliotheque.php:7-38
External Folder Indexing
The indexing feature allows the system to reference files without moving them. This is handled via the preview_directory and index_file API endpoints. Users can toggle recursive scanning to include subdirectories.
Integrated Document Processing
A key feature of the Document Library is its "Action Menu," which bridges the gap between storage and utility. When a file is selected in the library, it can be passed as a source to various processing modules.
| Action | Target Module | Supported Types |
|---|---|---|
| Imposition | imposition_brochure, imposition_livre, imposition_tracts | |
| Conversion | pdf_to_png or png_to_pdf | PDF, PNG |
| Color Separation | riso_separator | PNG |
| Image Adjustments | image_processor (Bitmap/Brightness) | PDF, PNG |
Sources: app/view/bibliotheque.html.php:485-550, README.md:27-46
UI Components and Previewing
The interface utilizes a sophisticated preview system based on PDF.js. For PDF files, it renders pages to a <canvas>, whereas PNG files are displayed using standard <img> elements within a modal.
Viewer Configuration
The viewer provides:
- Page Navigation: Previous/Next buttons and direct page input.
- Action Integration: Ability to trigger imposition or printing directly from the preview modal.
- Thumbnail Generation: Automatic generation of thumbnails for both local and indexed files via the
get_bibliotheque_thumbnailendpoint.
Sources: app/view/bibliotheque.html.php:55-100, app/js/web/viewer.html:270-350, app/public/index.php:190-205
Conclusion
The Document Library & Indexing module is a critical infrastructure component that transitions the application from a simple utility to a document management system. By centralizing storage and providing deep integration with processing tools, it streamlines the workflow for reproduction collectives managing complex print runs.
Sources: README.md:1-10, app/translations/en.json:65-75