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

Remote manifest items support #61

Closed
vers-one opened this issue Sep 18, 2022 · 0 comments · Fixed by #62 or #69
Closed

Remote manifest items support #61

vers-one opened this issue Sep 18, 2022 · 0 comments · Fixed by #62 or #69
Assignees

Comments

@vers-one
Copy link
Owner

vers-one commented Sep 18, 2022

Description

EPUB 3 standard supports remote manifest items and metadata links (i.e. files referenced by absolute URLs like http://example.com/book/123/font.ttf as opposed to local files like Content/font.ttf which are packaged within the EPUB file). EpubReader doesn't support remote manifest items and treats all absolute URLs as file names within the EPUB file.

Most of EPUB books don't contain references to remote resources.

Proposed solution

  1. Replace the implementation of the EpubContentFile / EpubContentFileRef classes and the classes derived from them with the following class hierarchy:

    EpubContentFile
    |-EpubLocalContentFile
    | |-EpubLocalTextContentFile
    | |-EpubLocalByteContentFile
    |-EpubRemoteContentFile
    | |-EpubRemoteTextContentFile
    | |-EpubRemoteByteContentFile
    
    EpubContentFileRef
    |-EpubLocalContentFileRef
    | |-EpubLocalTextContentFileRef
    | |-EpubLocalByteContentFileRef
    |-EpubRemoteContentFileRef
    | |-EpubRemoteTextContentFileRef
    | |-EpubRemoteByteContentFileRef
    
  2. Add ContentLocation property to the base classes with the following type: enum EpubContentLocation { LOCAL, REMOTE }.

  3. Add ContentFileType property to the base classes with the following type: enum EpubContentFileType { TEXT, BYTE_ARRAY }.

  4. Implement EpubContentCollection and EpubContentCollectionRef classes with two properties: Local and Remote which contain local and remote files / file references respectively. Use these classes for Html, Css, Images, Fonts, and AllFiles properties in the EpubContent / EpubContentRef classes.

  5. Implement content downloader for remote content files.

  6. Add ContentDownloaderOptions class to enable / disable downloading remote content and to let the application to supply its own content downloader.

  7. Extract the code to load local content and download remote content out of the EpubContentFileRef class into two separate classes: EpubLocalContentLoader and EpubRemoteContentLoader. Pass the reference to the content loader through the constructor parameter in the EpubContentFileRef class.

  8. Even though EPUB specification restricts types of remote resources to just audio, video, and font files, it would be better to relax this restriction in the EpubReader to allow all types of files to be remote resources to make the overall design simpler for the consumer of the library. However, EpubReader should still check that all HTML files in the EPUB spine, as well as the cover image and the EPUB 2 NCX / EPUB 3 navigation documents are local resources since these files are essential for constructing the parsed EPUB schema of the book.

Breaking changes

This solution introduces a breaking change: application will have to replace book.Content.<property> (where <property> is one of the following properties: Html, Css, Images, Fonts, or AllFiles) with book.Content.<property>.Local (unless application needs to handle remote items too).

Additionally, if application stores references to content files, then the following type replacement will be required:

  • EpubContentFileEpubLocalContentFile
  • EpubTextContentFileEpubLocalTextContentFile
  • EpubByteContentFileEpubLocalByteContentFile
  • EpubContentFileRefEpubLocalContentFileRef
  • EpubTextContentFileRefEpubLocalTextContentFileRef
  • EpubByteContentFileRefEpubLocalByteContentFileRef

Additional context

@vers-one vers-one self-assigned this Sep 18, 2022
@vers-one vers-one linked a pull request Sep 18, 2022 that will close this issue
2 tasks
@vers-one vers-one linked a pull request Nov 7, 2022 that will close this issue
2 tasks
@vers-one vers-one reopened this Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant