Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Brew as a CBZ file #3556

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

dbolack-ab
Copy link
Collaborator

This PR exports the Brew as a CBZ archive readable by various "comic" document readers.

The export isn't quite perfect, there appear to be some issues with some borders ( order of operations, maybe? ) within the library being used. Given this is a minor issue with a subsite of divs, I'm pushing this now for evaluation while I look for alternatives and/or fix the library.

To prevent menubar clutter, this PR moves the PDF printing item to a new Export menu and adds the CBZ export below it.

Img substitution generates correct URLs but the substitution load seems to fail?
Still won't parse  some bits
This version of the code works *IF* all CSS URLs are relocated to trusted locations - IE, the local server.

After this I will be continuing my work attempting to do URL rewrites for arbitrary purposes in support of this PR and direct PDF creation.
This feature works in two parts.

This first part is by adding a prioxy-passthrough for resources. This enables the code to get around XSS issues we were previously having,.

The second part clones the first page, massages URLs in it's <Links>, <style>, and <img> tags to use the
L to load the resources then generate two thumbnails. One is 115px tall and the other is set at 50% the page height. Currently, only the smaller of the two is stored as a new BrewStub field.
This changes the PDF print option to an Export menu with PDF as the first choice and CBZ as the second.

CBZ Export is functional, but not quite perfect. There are a few border effects that do not seem to work correctly with the image export.

As the export progresses the left margin will vanish while it processes to account for the the canvas convertor interpretting the margin. As a plus this functions as a progress meter. :)
@5e-Cleric
Copy link
Member

I'm not sure any user would notice, but i like the idea of exporting to other file formats. We likely want to mark this as export to comic file format(CBZ).

Also, if we are exporting to .CBZ, might as well export as .ZIP if users want too, right?

Copy link
Collaborator

@G-Ambatte G-Ambatte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't personally have a use-case for this feature, I am not specifically against it's inclusion.
At this point, I have only investigated the tests failures; I would suggest it should probably have it's own test suite prior to final merging.

server/middleware/content-negotiation.js Outdated Show resolved Hide resolved
@dbolack-ab
Copy link
Collaborator Author

Also, if we are exporting to .CBZ, might as well export as .ZIP if users want too, right?

Given a CBZ is just a zip file of images, it's just an extension.

@ericscheid
Copy link
Collaborator

Also, if we are exporting to .CBZ, might as well export as .ZIP if users want too, right?

A .zip of what, exactly? What is the underlying document format that is being zipped (i.e. other than CBZ) ?

@dbolack-ab
Copy link
Collaborator Author

A .zip of what, exactly? What is the underlying document format that is being zipped (i.e. other than CBZ) ?

A set of JPGs/PNGs. So far as I have been able to discern, there is no true format for CBR/CBZ files. It simply walks through the archive in alphabetical order. If there are folders, they are walked as well.

@5e-Cleric
Copy link
Member

Also, if we are exporting to .CBZ, might as well export as .ZIP if users want too, right?

A .zip of what, exactly? What is the underlying document format that is being zipped (i.e. other than CBZ) ?

Well, let's cite wikipedia on this one:

Comic book archive is not a distinct file format. It is a filename extension naming convention.

The filename extension indicates the archive type used:

Comic book archive files mainly consist of a series of image files with specific naming, typically PNG or JPEG files, stored as a single archive file. Occasionally GIF, BMP, and TIFF files are seen. Folders may be used to group images in a more logical layout within the archive, like book chapters.

So it is a compressed file of images of every page, to make a comic book.
They are used by software like Calibre or CDisplay

@ericscheid
Copy link
Collaborator

Yes, a .cbz is a file which is container of components, bundled into a zip. The components of the Comic Book Archive are a bunch of basic files (mostly image files), organised according to particular fules. It's a format, or at least a meta-format.

What I was getting at with my question is are there other end-format constructs that we might want to possibly include as export formats? Things like, oh, ebook, or maybe even a SPA of html/image components for static hosting of brews elsewhere.

@5e-Cleric
Copy link
Member

5e-Cleric commented Jul 4, 2024

I'd be against the website approach, we could export to html, but i would not go pass that.

But an .epub export sounds like it would be a great idea, specially as epub files are html files under the hood, should be pretty simple to make. (more like a zip of html, css and xml files, but you get what i mean) There must be some library out there.

https://www.npmjs.com/package/@lesjoursfr/html-to-epub

@dbolack-ab
Copy link
Collaborator Author

I'd be against the website approach, we could export to html, but i would not go pass that.

But an .epub export sounds like it would be a great idea, specially as epub files are html files under the hood, should be pretty simple to make. (more like a zip of html, css and xml files, but you get what i mean) There must be some library out there.

https://www.npmjs.com/package/@lesjoursfr/html-to-epub

I'll look at this in another PR in the future. We're off-track.

@5e-Cleric
Copy link
Member

So, don't we need #2278 to make this feature? i thought we were stuck with that, or does #3501 work?

@calculuschild calculuschild added the P3 - low priority Obscure tweak or fix for a single user label Jul 5, 2024
@dbolack-ab
Copy link
Collaborator Author

So, don't we need #2278 to make this feature? i thought we were stuck with that, or does #3501 work?

#3501 works. Two bugs with it were fixed with this PR and backported into it.

#2278 is functionally implemented with this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 - low priority Obscure tweak or fix for a single user 🔍 R0 - Needs first review 👀 PR ready but has not been reviewed
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

None yet

6 participants