2
1
Fork
You've already forked hacks
5

File-Attachment-Preview (PDF / Image / Audio / Video / DOCX / XLSX) #14

Closed
px_drutschmann wants to merge 1 commit from px_drutschmann/hacks:main into main
pull from: px_drutschmann/hacks:main
merge into: bookstack:main
bookstack:main
First-time contributor
Copy link

The custom head loads the bundled JSZip, docx-preview, and SheetJS scripts inline, injects preview-specific styles, and runs a script that scans .page-content for links to /attachments/{id}. It looks up attachment names in #page-attachments, then replaces each inline link with a structured preview card (.attachment-preview) containing a header (file icon, filename link, extension badge, download action) and a body that renders the appropriate preview: PDF in a resizable <object>, DOCX via docx.renderAsync, XLSX via XLSX.utils.sheet_to_html, images/video/audio via native elements, or a fallback message if unsupported.

This change adds a self-contained install flow that builds a theme-like dist/ folder, copies required frontend assets into dist/public, and installs the custom head template into dist/layouts/parts. It also cleans up the temporary node_modules after copying and aligns the docs and metadata with the new output structure.

The custom head loads the bundled JSZip, docx-preview, and SheetJS scripts inline, injects preview-specific styles, and runs a script that scans `.page-content` for links to `/attachments/{id}`. It looks up attachment names in `#page-attachments`, then replaces each inline link with a structured preview card (`.attachment-preview`) containing a header (file icon, filename link, extension badge, download action) and a body that renders the appropriate preview: PDF in a resizable `<object>`, DOCX via `docx.renderAsync`, XLSX via `XLSX.utils.sheet_to_html`, images/video/audio via native elements, or a fallback message if unsupported. This change adds a self-contained install flow that builds a theme-like `dist/` folder, copies required frontend assets into `dist/public`, and installs the custom head template into `dist/layouts/parts`. It also cleans up the temporary `node_modules` after copying and aligns the docs and metadata with the new output structure.
Owner
Copy link

Thanks for offering this @px_drutschmann, but the surface area of the hack is a bit too large for what I'd want to maintain as part of the official hacks. As per the repo readme I keep a fairly narrow scope for new hacks.

If you're able to host this elsewhere, we could maybe list in the readme and/or create a page on the hacks site for additional hacks created externally.

Thanks for offering this @px_drutschmann, but the surface area of the hack is a bit too large for what I'd want to maintain as part of the official hacks. As per the repo readme I keep a fairly narrow scope for new hacks. If you're able to host this elsewhere, we could maybe list in the readme and/or create a page on the hacks site for additional hacks created externally.
Author
First-time contributor
Copy link

Hey @danb

Thanks a lot for the quick reply and the detailed explanation.

We completely understand your desire to keep the scope of the official hacks fairly narrow, and that this one may be a bit too extensive for that.

We’re happy BookStack users and definitely plan to keep using it, which is why we’re interested in making our extension available for others as well. If it works for you, we’d be glad if you’d like to list it as an external hack or include it on a separate page for externally maintained hacks.

You can find the repository here:
https://github.com/pronomix-gmbh/bookstack_file_attachment_preview

Thanks again for the open and constructive exchange.

Best regards
Dirk

Hey @danb Thanks a lot for the quick reply and the detailed explanation. We completely understand your desire to keep the scope of the official hacks fairly narrow, and that this one may be a bit too extensive for that. We’re happy BookStack users and definitely plan to keep using it, which is why we’re interested in making our extension available for others as well. If it works for you, we’d be glad if you’d like to list it as an external hack or include it on a separate page for externally maintained hacks. You can find the repository here: https://github.com/pronomix-gmbh/bookstack_file_attachment_preview Thanks again for the open and constructive exchange. Best regards Dirk

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bookstack/hacks!14
Reference in a new issue
bookstack/hacks
No description provided.
Delete branch "px_drutschmann/hacks:main"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?