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

Resource Fetcher Plugin #144

Open
kimtuck opened this issue Nov 11, 2016 · 1 comment
Open

Resource Fetcher Plugin #144

kimtuck opened this issue Nov 11, 2016 · 1 comment

Comments

@kimtuck
Copy link

kimtuck commented Nov 11, 2016

This is a placeholder for a pull request I will post shortly. This is for a resource fetcher as a plugin. The code to be checked in for this pull request creates the ability to provide a resource fetcher as a plugin.

The current code examines the filename of the document to be loaded, and instanciates either a zipfile reader or a exploded epub reader. If the current zipfile loader and epub loader are moved into pluggable modules, then each fetcher can be interrogated to see if it is willing to open/retrieve the content. In this way, additional fetchers can be written. Fetchers could have a priority (which is not in this pull request). In this manner, (for example) a customized zipfile reader could be implemented with a higher priority than the baseline zipfile reader, and the customized zipfile reader would then be used.

The code for resource fetchers as plugins is already in production in Bibliotheca' Cloud Library reader.

I've added some additional events emitted by the code, which can be used by the resource fetcher to keep track of the state of the loading process:

When resolving resources, an event is emitted before resolving resources, and after those resources are resolved:
ReadiumSDK.emit('ContentDocumentFetcher-BeforeResolveResources');
self.resolveInternalPackageResources(contentDocumentResolvedCallback, errorCallback);
ReadiumSDK.emit('ContentDocumentFetcher-AfterResolveResources');

Events are emitted during the preprocessing of the stylesheet as well:
ReadiumSDK.emit('ContentDocumentFetcher-BeforeResolveResources');
......
ReadiumSDK.emit('ContentDocumentFetcher-AfterResolveResources');

I have a resource fetcher plugin written for Bibliotheca; it supports reading an epub by calling a service to get the contents of the epub; provides encryption of the content over the wire using a public/private key infrastructure, and batching multiple file requests into a single server request (that's what the extra events are for). I'm not willing to push that into the public repository, but I can send the code privately. It can serve as a template for a more generic plugin example.

@danielweck
Copy link
Member

Awesome contribution + tips, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants