Inline PDF viewer in shared EPUB/CBZ files
This commit is contained in:
parent
7da83b2595
commit
4a30c02521
42
js/plugin.js
42
js/plugin.js
@ -144,15 +144,37 @@ OC.Plugins.register('OCA.Files.FileList', OCA.Epubreader.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
|
||||||
window.addEventListener('DOMContentLoaded', function () {
|
window.addEventListener('DOMContentLoaded', function () {
|
||||||
if ($('#isPublic').val()
|
var supported_mimetypes = ['application/epub+zip', 'application/pdf', 'application/x-cbr'];
|
||||||
&& ($('#mimetype').val() === 'application/epub+zip'
|
if (!$('#isPublic').val() || !supported_mimetypes.includes($('#mimetype').val())
|
||||||
|| $('#mimetype').val() === 'application/pdf'
|
) {
|
||||||
|| $('#mimetype').val() === 'application/x-cbr')
|
return;
|
||||||
) {
|
|
||||||
var sharingToken = $('#sharingToken').val();
|
|
||||||
var downloadUrl = OC.generateUrl('/s/{token}/download', {token: sharingToken});
|
|
||||||
var viewer = OCA.Epubreader.Plugin;
|
|
||||||
var mime = $('#mimetype').val();
|
|
||||||
viewer.show(downloadUrl, mime, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sharingToken = $('#sharingToken').val();
|
||||||
|
var downloadUrl = OC.generateUrl('/s/{token}/download', {token: sharingToken});
|
||||||
|
|
||||||
|
var content = $('#files-public-content');
|
||||||
|
var footerElmt = document.querySelector('body > footer') || document.querySelector('#app-content > footer')
|
||||||
|
var mainContent = document.querySelector('#content')
|
||||||
|
|
||||||
|
var mime = $('#mimetype').val();
|
||||||
|
var viewerUrl = OC.generateUrl('/apps/epubreader/?file={file}&type={type}', {file: downloadUrl, type: mime});
|
||||||
|
|
||||||
|
// Create viewer frame
|
||||||
|
const viewerNode = document.createElement('iframe')
|
||||||
|
viewerNode.style.height = '100%'
|
||||||
|
viewerNode.style.width = '100%'
|
||||||
|
viewerNode.style.position = 'absolute'
|
||||||
|
|
||||||
|
// Inject viewer
|
||||||
|
content.empty()
|
||||||
|
content.append(viewerNode)
|
||||||
|
viewerNode.src = viewerUrl
|
||||||
|
footerElmt.style.display = 'none'
|
||||||
|
mainContent.style.minHeight = 'calc(100% - var(--header-height))' // Make the viewer take the whole height as the footer is now hidden.
|
||||||
|
// overwrite style in order to fix the viewer on public pages
|
||||||
|
mainContent.style.marginLeft = '0'
|
||||||
|
mainContent.style.marginRight = '0'
|
||||||
|
mainContent.style.width = '100%'
|
||||||
|
mainContent.style.borderRadius = 'unset'
|
||||||
});
|
});
|
||||||
|
@ -17,7 +17,6 @@ use OCP\AppFramework\Http\ContentSecurityPolicy;
|
|||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\Files\FileInfo;
|
use OCP\Files\FileInfo;
|
||||||
use OCP\Files\Folder;
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\InvalidPathException;
|
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
use OCP\Files\NotFoundException;
|
use OCP\Files\NotFoundException;
|
||||||
use OCP\IRequest;
|
use OCP\IRequest;
|
||||||
@ -109,7 +108,7 @@ class PageController extends Controller
|
|||||||
*
|
*
|
||||||
* @param string $path path-fragment from url
|
* @param string $path path-fragment from url
|
||||||
*
|
*
|
||||||
* @throws InvalidPathException|NotFoundException
|
* @throws NotFoundException
|
||||||
*/
|
*/
|
||||||
private function getFileInfo(string $path): array
|
private function getFileInfo(string $path): array
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user