From 1db51c5c5852df2250df8091a6931c008741153a Mon Sep 17 00:00:00 2001 From: danielweck Date: Tue, 20 Sep 2016 17:54:48 +0100 Subject: [PATCH 1/2] submodule --- readium-shared-js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readium-shared-js b/readium-shared-js index aa0d57228..71df2031b 160000 --- a/readium-shared-js +++ b/readium-shared-js @@ -1 +1 @@ -Subproject commit aa0d5722818e21b7fd0c16f21f58f09976215a39 +Subproject commit 71df2031ba26c81ac50d2214b2f45072b9f92b39 From a3231ba0ecb75ff0ad3d579ff2cdc9ded8287168 Mon Sep 17 00:00:00 2001 From: "r.hanson" Date: Mon, 21 Nov 2016 16:53:34 -0600 Subject: [PATCH 2/2] Resource Fetcher plugin bootstrapping code. --- js/Readium.js | 8 +++++- js/epub-fetch/publication_fetcher.js | 37 +++++++++++----------------- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/js/Readium.js b/js/Readium.js index b78c41426..cd24feb3f 100644 --- a/js/Readium.js +++ b/js/Readium.js @@ -142,7 +142,13 @@ define(['readium_shared_js/globals', 'text!version.json', 'jquery', 'underscore' this.openPackageDocument = function(ebookURL, callback, openPageRequest) { - + var resourcePluginKey='ResourceFetcherPlugin'; + var plugins = ReadiumSDK.Plugins.getLoadedPlugins() + if (_.has(plugins, resourcePluginKey)) { + _resourceFetcher = plugins[resourcePluginKey].CustomResourceFetcher.openPackageDocument(ebookURL, callback, openPageRequest, openPackageDocument_) + return; + } + if (!(ebookURL instanceof Blob) && !(ebookURL instanceof File) // && ebookURL.indexOf("file://") != 0 diff --git a/js/epub-fetch/publication_fetcher.js b/js/epub-fetch/publication_fetcher.js index e8aaa4dc5..f97451f78 100644 --- a/js/epub-fetch/publication_fetcher.js +++ b/js/epub-fetch/publication_fetcher.js @@ -46,8 +46,6 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip // Non exploded EPUBs (i.e. zipped .epub documents) should be fetched in a programmatical manner: _shouldConstructDomProgrammatically = !isEpubExploded; - console.log("_shouldConstructDomProgrammatically INIT: " + _shouldConstructDomProgrammatically); - createResourceFetcher(isEpubExploded, function(resourceFetcher) { //NOTE: _resourceFetcher == resourceFetcher @@ -95,18 +93,27 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip } function createResourceFetcher(isExploded, callback) { + + var resourcePluginKey='ResourceFetcherPlugin'; + var plugins = ReadiumSDK.Plugins.getLoadedPlugins() + if (_.has(plugins, resourcePluginKey)) { + _resourceFetcher = new plugins[resourcePluginKey].CustomResourceFetcher(self); + if (_resourceFetcher.shouldConstructDomProgrammatically) + _shouldConstructDomProgrammatically = _resourceFetcher.shouldConstructDomProgrammatically(); + callback(_resourceFetcher); + return; + } + if (isExploded) { - console.log(' --- using PlainResourceFetcher'); _resourceFetcher = new PlainResourceFetcher(self); callback(_resourceFetcher); } else { - console.log(' --- using ZipResourceFetcher'); _resourceFetcher = new ZipResourceFetcher(self, jsLibRoot); callback(_resourceFetcher); } } - + // PUBLIC API /** @@ -133,9 +140,7 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip * the base URI of their content document. */ this.shouldFetchMediaAssetsProgrammatically = function() { - - var ret = _shouldConstructDomProgrammatically && !isExploded(); - return ret; + return _shouldConstructDomProgrammatically; }; this.getEbookURL = function() { @@ -234,11 +239,7 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip _packageFullPath = packageFullPath; _packageDocumentAbsoluteUrl = _resourceFetcher.resolveURI(_packageFullPath); - - console.debug("PACKAGE: "); - console.log(_packageFullPath); - console.log(_packageDocumentAbsoluteUrl); - + if (packageFullPath && packageFullPath.charAt(0) != '/') { packageFullPath = '/' + packageFullPath; } @@ -315,8 +316,6 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip && new URI(relativeToPackagePath).scheme() !== '') { - console.log("shouldConstructDomProgrammatically EXTERNAL RESOURCE ..."); - if (fetchMode === 'blob') { var xhr = new XMLHttpRequest(); @@ -338,11 +337,6 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip } else { $.ajax({ - // encoding: "UTF-8", - // mimeType: "text/plain; charset=UTF-8", - // beforeSend: function( xhr ) { - // xhr.overrideMimeType("text/plain; charset=UTF-8"); - // }, isLocal: false, url: relativeToPackagePath, dataType: 'text', //https://api.jquery.com/jQuery.ajax/ @@ -400,8 +394,6 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip var cipherReference = $('CipherReference', encryptedData); cipherReference.each(function (index, CipherReference) { var cipherReferenceURI = $(CipherReference).attr('URI'); - console.log('Encryption/obfuscation algorithm ' + encryptionAlgorithm + ' specified for ' + - cipherReferenceURI); encryptions[cipherReferenceURI] = encryptionAlgorithm; }); }); @@ -422,7 +414,6 @@ define(['jquery', 'URIjs', './markup_parser', './plain_resource_fetcher', './zip if (_encryptionHandler.isEncryptionSpecified()) { // EPUBs that use encryption for any resources should be fetched in a programmatical manner: _shouldConstructDomProgrammatically = true; - console.log("_shouldConstructDomProgrammatically ENCRYPTION ACTIVE: " + _shouldConstructDomProgrammatically); } settingFinishedCallback();