Oops... forgot to change plugin script for public pages... fixed.
This commit is contained in:
parent
b93d0a6916
commit
a9fcd70fb6
5 changed files with 66 additions and 79 deletions
|
@ -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
|
## 1.5.0 - 2022-08-24
|
||||||
### Changed
|
### Changed
|
||||||
- raised version number to 1.5.0 to avoid confusion with a forked version of this app
|
- raised version number to 1.5.0 to avoid confusion with a forked version of this app
|
||||||
|
|
|
@ -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
|
[README]: https://github.com/Yetangitu/owncloud-apps/blob/master/files_reader/README.md
|
||||||
]]>
|
]]>
|
||||||
</description>
|
</description>
|
||||||
<version>1.5.0</version>
|
<version>1.5.1</version>
|
||||||
<licence>AGPL</licence>
|
<licence>AGPL</licence>
|
||||||
<author>Frank de Lange</author>
|
<author>Frank de Lange</author>
|
||||||
<documentation>
|
<documentation>
|
||||||
|
|
BIN
dist/files_reader-1.5.0.tar.gz
vendored
BIN
dist/files_reader-1.5.0.tar.gz
vendored
Binary file not shown.
|
@ -11,40 +11,56 @@
|
||||||
|
|
||||||
|
|
||||||
(function(OCA) {
|
(function(OCA) {
|
||||||
|
|
||||||
OCA.Files_Reader = OCA.Files_Reader || {};
|
OCA.Files_Reader = OCA.Files_Reader || {};
|
||||||
const epub_enabled = OCP.InitialState.loadState('files_reader', 'epub_enabled');
|
const epub_enabled = OCP.InitialState.loadState('files_reader', 'epub_enabled');
|
||||||
const pdf_enabled = OCP.InitialState.loadState('files_reader', 'pdf_enabled');
|
const pdf_enabled = OCP.InitialState.loadState('files_reader', 'pdf_enabled');
|
||||||
const cbx_enabled = OCP.InitialState.loadState('files_reader', 'cbx_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 mimeMappings = {
|
||||||
const cbx_types= [
|
'application/epub+zip': 'epub',
|
||||||
'application/comicbook+7z',
|
'application/pdf': 'pdf',
|
||||||
'application/comicbook+rar',
|
'application/x-cbr': 'cbx',
|
||||||
'application/comicbook+tar',
|
'application/comicbook+7z': 'cbx',
|
||||||
'application/comicbook+zip',
|
'application/comicbook+rar': 'cbx',
|
||||||
'application/x-cbr',
|
'application/comicbook+tar': 'cbx',
|
||||||
];
|
'application/comicbook+zip': 'cbx'
|
||||||
|
};
|
||||||
|
|
||||||
|
const isMobileUAD = window.navigator.userAgentData?.mobile;
|
||||||
var isMobile = navigator.userAgent.match(/Mobi/i);
|
const isMobile = typeof isMobileUAD === 'boolean'
|
||||||
var hasTouch = 'ontouchstart' in document.documentElement;
|
? isMobileUAD
|
||||||
|
: navigator.userAgent.match(/Mobi/i);
|
||||||
|
|
||||||
function actionHandler(fileName, mime, context) {
|
function actionHandler(fileName, mime, context) {
|
||||||
var sharingToken = $('#sharingToken').val();
|
const downloadUrl = Files.getDownloadUrl(fileName, context.dir);
|
||||||
var downloadUrl = OC.generateUrl('/s/{token}/download?files={files}&path={path}', {
|
OCA.Files_Reader.Plugin.show(downloadUrl, mimeMappings[mime], true);
|
||||||
token: sharingToken,
|
|
||||||
files: fileName,
|
|
||||||
path: context.dir
|
|
||||||
});
|
|
||||||
OCA.Files_Reader.Plugin.show(downloadUrl, mime, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace OCA.Files_Reader.Plugin
|
* @namespace OCA.Files_Reader.Plugin
|
||||||
*/
|
*/
|
||||||
OCA.Files_Reader.Plugin = {
|
OCA.Files_Reader.Plugin = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mimeType
|
||||||
|
*/
|
||||||
|
getMapping: function(mimeType) {
|
||||||
|
return mimeMappings[mimeType];
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param fileList
|
* @param fileList
|
||||||
*/
|
*/
|
||||||
|
@ -79,12 +95,12 @@
|
||||||
* @param downloadUrl
|
* @param downloadUrl
|
||||||
* @param isFileList
|
* @param isFileList
|
||||||
*/
|
*/
|
||||||
show: function(downloadUrl, mimeType, isFileList) {
|
show: function(downloadUrl, fileType, isFileList) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var $iframe;
|
var $iframe;
|
||||||
var viewer = OC.generateUrl('/apps/files_reader/?file={file}&type={type}', {file: downloadUrl, type: mimeType});
|
var viewer = OC.generateUrl('/apps/files_reader/?file={file}&type={type}', {file: downloadUrl, type: fileType});
|
||||||
// launch in new window on mobile and touch devices...
|
// launch in new window on mobile devices...
|
||||||
if (isMobile || hasTouch) {
|
if (isMobile) {
|
||||||
window.open(viewer, downloadUrl);
|
window.open(viewer, downloadUrl);
|
||||||
} else {
|
} else {
|
||||||
$iframe = '<iframe style="width:100%;height:100%;display:block;position:absolute;top:0;" src="' + viewer + '" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" sandbox="allow-scripts allow-same-origin"/>';
|
$iframe = '<iframe style="width:100%;height:100%;display:block;position:absolute;top:0;" src="' + viewer + '" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" sandbox="allow-scripts allow-same-origin"/>';
|
||||||
|
@ -108,48 +124,23 @@
|
||||||
*/
|
*/
|
||||||
_extendFileActions: function(fileActions) {
|
_extendFileActions: function(fileActions) {
|
||||||
var self = this;
|
var self = this;
|
||||||
fileActions.registerAction({
|
for (handler in mimeHandlers) {
|
||||||
name: 'view-epub',
|
const actionName = 'view-' + handler;
|
||||||
displayName: 'View',
|
mimeHandlers[handler].mimeTypes.forEach(function(mimeType) {
|
||||||
mime: 'application/epub+zip',
|
fileActions.registerAction({
|
||||||
permissions: OC.PERMISSION_READ,
|
name: actionName,
|
||||||
actionHandler: function(fileName, context){
|
displayName: 'View',
|
||||||
return actionHandler(fileName, 'application/epub+zip', context);
|
mime: mimeType,
|
||||||
}
|
permissions: OC.PERMISSION_READ,
|
||||||
});
|
actionHandler: function(fileName, context){
|
||||||
for (let i = 0; i < cbx_types.length; i++) {
|
return actionHandler(fileName, mimeType, context);
|
||||||
fileActions.registerAction({
|
}
|
||||||
name: 'view-cbr',
|
});
|
||||||
displayName: 'View',
|
|
||||||
mime: cbx_types[i],
|
if (mimeHandlers[handler].default === 'true')
|
||||||
permissions: OC.PERMISSION_READ,
|
fileActions.setDefault(mimeType, actionName);
|
||||||
actionHandler: function(fileName, context) {
|
|
||||||
return actionHandler(fileName, 'application/x-cbr', context);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
fileActions.registerAction({
|
|
||||||
name: 'view-pdf',
|
|
||||||
displayName: 'View',
|
|
||||||
mime: 'application/pdf',
|
|
||||||
permissions: OC.PERMISSION_READ,
|
|
||||||
actionHandler: function(fileName, context) {
|
|
||||||
return actionHandler(fileName, 'application/pdf', context);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (epub_enabled === 'true')
|
|
||||||
fileActions.setDefault('application/epub+zip', 'view-epub');
|
|
||||||
if (cbx_enabled === 'true') {
|
|
||||||
for (let i = 0; i < cbx_types.length; i++) {
|
|
||||||
fileActions.setDefault(cbx_types[i], 'view-cbr');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (pdf_enabled === 'true')
|
|
||||||
fileActions.setDefault('application/pdf', 'view-pdf');
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -159,19 +150,11 @@ OC.Plugins.register('OCA.Files.FileList', OCA.Files_Reader.Plugin);
|
||||||
|
|
||||||
// FIXME: Hack for single public file view since it is not attached to the fileslist
|
// FIXME: Hack for single public file view since it is not attached to the fileslist
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
const mimetype=$('#mimetype').val();
|
const viewer = OCA.Files_Reader.Plugin;
|
||||||
if ($('#isPublic').val()
|
const fileType=viewer.getMapping($('#mimetype').val());
|
||||||
&& (mimetype === 'application/epub+zip'
|
if ($('#isPublic').val() && fileType) {
|
||||||
|| mimetype === 'application/pdf'
|
const sharingToken = $('#sharingToken').val();
|
||||||
|| mimetype === 'application/x-cbr'
|
const downloadUrl = OC.generateUrl('/s/{token}/download', {token: sharingToken});
|
||||||
|| mimetype.startsWith('application/comicbook'))
|
viewer.show(downloadUrl, fileType, false);
|
||||||
) {
|
|
||||||
var sharingToken = $('#sharingToken').val();
|
|
||||||
var downloadUrl = OC.generateUrl('/s/{token}/download', {token: sharingToken});
|
|
||||||
var viewer = OCA.Files_Reader.Plugin;
|
|
||||||
var mime = $('#mimetype').val();
|
|
||||||
if (mimetype.startsWith('application/comicbook'))
|
|
||||||
mime = 'application/x-cbr';
|
|
||||||
viewer.show(downloadUrl, mime, false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ class LoadPublicViewerListener implements IEventListener {
|
||||||
private IInitialState $initialStateService;
|
private IInitialState $initialStateService;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
IInitialState $initialStateService,
|
IInitialState $initialStateService
|
||||||
) {
|
) {
|
||||||
$this->initialStateService = $initialStateService;
|
$this->initialStateService = $initialStateService;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue