diff --git a/CHANGELOG.md b/CHANGELOG.md index b479365..d1049ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.5.1 - 2022-08-24 +### Fixed + - Public pages also needed their plugin script changes, oops... fixed. + ## 1.5.0 - 2022-08-24 ### Changed - raised version number to 1.5.0 to avoid confusion with a forked version of this app diff --git a/appinfo/info.xml b/appinfo/info.xml index 953f56e..a01cad2 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -30,7 +30,7 @@ See [README] for more exhaustive information on features and potential misfeatur [README]: https://github.com/Yetangitu/owncloud-apps/blob/master/files_reader/README.md ]]> - 1.5.0 + 1.5.1 AGPL Frank de Lange diff --git a/dist/files_reader-1.5.0.tar.gz b/dist/files_reader-1.5.0.tar.gz deleted file mode 100644 index 5151de4..0000000 Binary files a/dist/files_reader-1.5.0.tar.gz and /dev/null differ diff --git a/js/plugin-public.js b/js/plugin-public.js index eec5bcd..19267d2 100644 --- a/js/plugin-public.js +++ b/js/plugin-public.js @@ -11,40 +11,56 @@ (function(OCA) { - OCA.Files_Reader = OCA.Files_Reader || {}; const epub_enabled = OCP.InitialState.loadState('files_reader', 'epub_enabled'); const pdf_enabled = OCP.InitialState.loadState('files_reader', 'pdf_enabled'); const cbx_enabled = OCP.InitialState.loadState('files_reader', 'cbx_enabled'); + const mimeHandlers = { + 'epub': { default: epub_enabled, mimeTypes: ['application/epub+zip']}, + 'pdf': { default: pdf_enabled, mimeTypes: ['application/pdf']}, + 'cbx': { default: cbx_enabled, mimeTypes: [ + 'application/comicbook+7z', + 'application/comicbook+rar', + 'application/comicbook+tar', + 'application/comicbook+zip', + 'application/x-cbr' + ]} + }; - /* comicbooks come in many different forms... */ - const cbx_types= [ - 'application/comicbook+7z', - 'application/comicbook+rar', - 'application/comicbook+tar', - 'application/comicbook+zip', - 'application/x-cbr', - ]; - + const mimeMappings = { + 'application/epub+zip': 'epub', + 'application/pdf': 'pdf', + 'application/x-cbr': 'cbx', + 'application/comicbook+7z': 'cbx', + 'application/comicbook+rar': 'cbx', + 'application/comicbook+tar': 'cbx', + 'application/comicbook+zip': 'cbx' + }; - var isMobile = navigator.userAgent.match(/Mobi/i); - var hasTouch = 'ontouchstart' in document.documentElement; + const isMobileUAD = window.navigator.userAgentData?.mobile; + const isMobile = typeof isMobileUAD === 'boolean' + ? isMobileUAD + : navigator.userAgent.match(/Mobi/i); function actionHandler(fileName, mime, context) { - var sharingToken = $('#sharingToken').val(); - var downloadUrl = OC.generateUrl('/s/{token}/download?files={files}&path={path}', { - token: sharingToken, - files: fileName, - path: context.dir - }); - OCA.Files_Reader.Plugin.show(downloadUrl, mime, true); + const downloadUrl = Files.getDownloadUrl(fileName, context.dir); + OCA.Files_Reader.Plugin.show(downloadUrl, mimeMappings[mime], true); } + + /** * @namespace OCA.Files_Reader.Plugin */ OCA.Files_Reader.Plugin = { + /** + * @param mimeType + */ + getMapping: function(mimeType) { + return mimeMappings[mimeType]; + }, + /** * @param fileList */ @@ -79,12 +95,12 @@ * @param downloadUrl * @param isFileList */ - show: function(downloadUrl, mimeType, isFileList) { + show: function(downloadUrl, fileType, isFileList) { var self = this; var $iframe; - var viewer = OC.generateUrl('/apps/files_reader/?file={file}&type={type}', {file: downloadUrl, type: mimeType}); - // launch in new window on mobile and touch devices... - if (isMobile || hasTouch) { + var viewer = OC.generateUrl('/apps/files_reader/?file={file}&type={type}', {file: downloadUrl, type: fileType}); + // launch in new window on mobile devices... + if (isMobile) { window.open(viewer, downloadUrl); } else { $iframe = '