Commit 6a1e790e authored by onny's avatar onny

add missing files

parent abb85eda
files_pdfviewer
files_ebookreader
======
This application integrates the [PDF.js](https://mozilla.github.io/pdf.js/) library into Nextcloud. Using this application users can view their PDF files online without downloading the file.
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/owncloud/files_pdfviewer/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/files_pdfviewer/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/owncloud/files_pdfviewer/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/nextcloud/files_pdfviewer/?branch=master)
[![Build Status](https://travis-ci.org/owncloud/files_pdfviewer.svg)](https://travis-ci.org/nextcloud/files_pdfviewer)
This application integrates the [Epub.js](https://github.com/futurepress/epub.js/) library into Nextcloud. Using this application users can view their ebook files online without downloading the file.
Maintainers
===========
- [Lukas Reschke](https://github.com/LukasReschke)
- [Jonas Heinrich](https://git.project-insanity.org/onny)
......@@ -3,26 +3,26 @@
<id>files_ebookreader</id>
<name>Ebook reader</name>
<summary>An ebook reader for Nextcloud</summary>
<description><![CDATA[This application integrates the PDF.js library into Nextcloud. Using this
application users can view their PDF files online without the need to
<description><![CDATA[This application integrates the Epub.js library into Nextcloud. Using this
application users can view their ebook files online without the need to
download the file.
When this application is enabled publicly shared PDF documents will also
get shown in the PDF viewer instead of only showing a single static
snapshot of the document. The PDF viewer requires a modern browser and
When this application is enabled publicly shared ebook documents will also
get shown in the ebook reader instead of only showing a single static
snapshot of the document. The ebook reader requires a modern browser and
will not work with Microsoft® Internet Explorer® versions below 9.
PDF.js is a JavaScript library developed by Mozilla, you can learn more
about the PDF.js project at [https://mozilla.github.io/pdf.js/](https://mozilla.github.io/pdf.js/)]]></description>
Epub.js is a JavaScript library developed by Futurepress, you can learn more
about the Epub.js project at [https://github.com/futurepress/epub.js/](https://github.com/futurepress/epub.js/)]]></description>
<version>0.1</version>
<licence>mit</licence>
<author>Jonas Heinrich</author>
<namespace>Files_EbookReader</namespace>
<default_enable/>
<category>files</category>
<category>office</category>
<bugs>https://github.com/nextcloud/files_pdfviewer/issues</bugs>
<category>media</category>
<bugs>https://git.project-insanity.org/onny/web-nextcloud-app-files_ebookreader</bugs>
<dependencies>
<nextcloud min-version="15" max-version="15" />
<nextcloud min-version="15" max-version="16" />
</dependencies>
</info>
......@@ -12,5 +12,5 @@ declare(strict_types=1);
namespace OCA\Files_EbookReader\AppInfo;
return ['routes' => [
['name' => 'display#showPdfViewer', 'url' => '/', 'verb' => 'GET'],
['name' => 'display#showEbookReader', 'url' => '/', 'verb' => 'GET'],
]];
......@@ -10,12 +10,12 @@
(function(OCA) {
OCA.FilesPdfViewer = OCA.FilesPdfViewer || {};
OCA.FilesEbookReader = OCA.FilesEbookReader || {};
/**
* @namespace OCA.FilesPdfViewer.PreviewPlugin
* @namespace OCA.FilesEbookReader.PreviewPlugin
*/
OCA.FilesPdfViewer.PreviewPlugin = {
OCA.FilesEbookReader.PreviewPlugin = {
/**
* @param fileList
......@@ -48,7 +48,7 @@
var self = this;
var shown = true;
var $iframe;
var viewer = OC.generateUrl('/apps/files_pdfviewer/?file={file}', {file: downloadUrl});
var viewer = OC.generateUrl('/apps/files_ebookreader/?file={file}', {file: downloadUrl});
$iframe = $('<iframe id="pdframe" style="width:100%;height:100%;display:block;position:absolute;top:0;z-index:1041;left:0;" src="'+viewer+'" sandbox="allow-scripts allow-same-origin allow-popups allow-modals allow-top-navigation" allowfullscreen="true"/>');
if(isFileList === true) {
......@@ -95,7 +95,7 @@
});
if(!$('html').hasClass('ie8')) {
history.pushState({}, '', '#pdfviewer');
history.pushState({}, '', '#ebookreader');
}
if(!$('html').hasClass('ie8')) {
......@@ -129,14 +129,14 @@
})(OCA);
OC.Plugins.register('OCA.Files.FileList', OCA.FilesPdfViewer.PreviewPlugin);
OC.Plugins.register('OCA.Files.FileList', OCA.FilesEbookReader.PreviewPlugin);
// FIXME: Hack for single public file view since it is not attached to the fileslist
$(document).ready(function(){
if ($('#isPublic').val() && $('#mimetype').val() === 'application/epub+zip') {
var sharingToken = $('#sharingToken').val();
var downloadUrl = OC.generateUrl('/s/{token}/download', {token: sharingToken});
var viewer = OCA.FilesPdfViewer.PreviewPlugin;
var viewer = OCA.FilesEbookReader.PreviewPlugin;
viewer.show(downloadUrl, false);
}
});
......@@ -156,7 +156,7 @@ $(document).ready(function(){
var downloadUrl = Files.getDownloadUrl(model.get('name'), model.get('path'));
var viewer = OC.generateUrl('/apps/files_pdfviewer/?minmode=true&file={file}', {file: downloadUrl});
var viewer = OC.generateUrl('/apps/files_ebookreader/?minmode=true&file={file}', {file: downloadUrl});
var $iframe = $('<iframe id="pdframe-sidebar" style="width:100%;height:' + previewHeight + 'px;display:block;" src="' + viewer + '" sandbox="allow-scripts allow-same-origin allow-popups allow-modals" />');
$thumbnailDiv.append($iframe);
......
......@@ -35,7 +35,7 @@ function initializeCustomPDFViewerApplication() {
// The download has to be forced to use the URL of the file; by default
// "PDFViewerApplication.download" uses a blob, but this causes a CSP error
// (at least, in Firefox) when trying to download it.
PDFViewerApplication.download = function() {
EbookReaderApplication.download = function() {
// "isDataSchema()" and "getPDFFileNameFromURL()" are copied from
// "vendor/pdfjs/web/viewer.js", as the functions defined in that file
// can not be accessed from the outside.
......
......@@ -41,7 +41,7 @@ class DisplayController extends Controller {
* @param bool $minmode
* @return TemplateResponse
*/
public function showPdfViewer(bool $minmode = false): TemplateResponse {
public function showEbookReader(bool $minmode = false): TemplateResponse {
$params = [
'urlGenerator' => $this->urlGenerator,
'minmode' => $minmode
......
......@@ -3,6 +3,7 @@
/** @var OCP\IURLGenerator $urlGenerator */
$urlGenerator = $_['urlGenerator'];
$version = \OC::$server->getAppManager()->getAppVersion('files_ebookreader');
$file = $_GET['file'];
?>
<!DOCTYPE html>
<!--
......@@ -27,7 +28,7 @@ Adobe CMap resources are covered by their own copyright but the same license:
See https://github.com/adobe-type-tools/cmap-resources
-->
<html dir="ltr" mozdisallowselectionprint moznomarginboxes>
<head data-workersrc="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/pdfjs/build/pdf.worker.js')) ?>?v=<?php p($version) ?>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
......@@ -35,20 +36,18 @@ See https://github.com/adobe-type-tools/cmap-resources
<title>Ebook reader</title>
<!-- This snippet is used in production (included from viewer.html) -->
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/normalize.css')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/main.css')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/popup.css')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/normalize.css')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/main.css')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/popup.css')) ?>">
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/jquery.min.js')) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/zip.min.js')) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/zip.min.js')) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>">
"use strict";
document.onreadystatechange = function () {
if (document.readyState == "complete") {
window.reader = ePubReader("https://onny.project-insanity.org/files/gryphius.epub", {
window.reader = ePubReader("<?php p($file) ?>", {
restore: true
});
}
......@@ -60,13 +59,13 @@ See https://github.com/adobe-type-tools/cmap-resources
<!-- <script src="js/libs/localforage.min.js"></script> -->
<!-- Full Screen -->
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/screenfull.min.js')) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/screenfull.min.js')) ?>"></script>
<!-- Render -->
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epub.js')) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/epub.js')) ?>"></script>
<!-- Reader -->
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/reader.js')) ?>"></script>
<script nonce="<?php p(\OC::$server->getContentSecurityPolicyNonceManager()->getNonce()) ?>" src="<?php p($urlGenerator->linkTo('files_ebookreader', 'vendor/epubjs/reader.js')) ?>"></script>
</head>
......
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="https://futurepress.github.io/epubjs-reader/css/normalize.css">
<link rel="stylesheet" href="https://futurepress.github.io/epubjs-reader/css/main.css">
<link rel="stylesheet" href="https://futurepress.github.io/epubjs-reader/css/popup.css">
<script src="https://futurepress.github.io/epubjs-reader/js/libs/jquery.min.js"></script>
<script src="https://futurepress.github.io/epubjs-reader/js/libs/zip.min.js"></script>
<script>
"use strict";
document.onreadystatechange = function () {
if (document.readyState == "complete") {
window.reader = ePubReader("https://onny.project-insanity.org/files/gryphius.epub", {
restore: true
});
}
};
</script>
<!-- File Storage -->
<!-- <script src="js/libs/localforage.min.js"></script> -->
<!-- Full Screen -->
<script src="https://futurepress.github.io/epubjs-reader/js/libs/screenfull.min.js"></script>
<!-- Render -->
<script src="https://futurepress.github.io/epubjs-reader/js/epub.js"></script>
<!-- Reader -->
<script src="https://futurepress.github.io/epubjs-reader/js/reader.js"></script>
<!-- Plugins -->
<!-- <script src="js/plugins/search.js"></script> -->
<!-- Highlights -->
<!-- <script src="js/libs/jquery.highlight.js"></script> -->
<!-- <script src="js/hooks/extensions/highlight.js"></script> -->
</head>
<body>
<div id="sidebar">
<div id="panels">
<!-- <input id="searchBox" placeholder="search" type="search"> -->
<!-- <a id="show-Search" class="show_view icon-search" data-view="Search">Search</a> -->
<a id="show-Toc" class="show_view icon-list-1 active" data-view="Toc">TOC</a>
<a id="show-Bookmarks" class="show_view icon-bookmark" data-view="Bookmarks">Bookmarks</a>
<!-- <a id="show-Notes" class="show_view icon-edit" data-view="Notes">Notes</a> -->
</div>
<div id="tocView" class="view">
</div>
<div id="searchView" class="view">
<ul id="searchResults"></ul>
</div>
<div id="bookmarksView" class="view">
<ul id="bookmarks"></ul>
</div>
<div id="notesView" class="view">
<div id="new-note">
<textarea id="note-text"></textarea>
<button id="note-anchor">Anchor</button>
</div>
<ol id="notes"></ol>
</div>
</div>
<div id="main">
<div id="titlebar">
<div id="opener">
<a id="slider" class="icon-menu">Menu</a>
</div>
<div id="metainfo">
<span id="book-title"></span>
<span id="title-seperator">&nbsp;&nbsp;&nbsp;&nbsp;</span>
<span id="chapter-title"></span>
</div>
<div id="title-controls">
<a id="bookmark" class="icon-bookmark-empty">Bookmark</a>
<a id="setting" class="icon-cog">Settings</a>
<a id="fullscreen" class="icon-resize-full">Fullscreen</a>
</div>
</div>
<div id="divider"></div>
<div id="prev" class="arrow"></div>
<div id="viewer"></div>
<div id="next" class="arrow"></div>
<div id="loader"><img src="img/loader.gif"></div>
</div>
<div class="modal md-effect-1" id="settings-modal">
<div class="md-content">
<h3>Settings</h3>
<div>
<p>
<input type="checkbox" id="sidebarReflow" name="sidebarReflow">Reflow text when sidebars are open.
</p>
</div>
<div class="closer icon-cancel-circled"></div>
</div>
</div>
<div class="overlay"></div>
</body>
</html>
<html>
<head>
<script src="https://futurepress.github.io/epubjs-reader/js/epub.js"></script>
</head>
<body>
<div id="area"></div>
<script>
document.onreadystatechange = function () {
if (document.readyState == "complete") {
var book = ePub("vendor/gryphius.epub");
var rendition = book.renderTo("area", {width: 600, height: 400});
var displayed = rendition.display();
}
}
</script>
</body>
</html>
<?php
if (!defined('PHPUNIT_RUN')) {
define('PHPUNIT_RUN', 1);
}
require_once __DIR__.'/../../../lib/base.php';
\OC::$loader->addValidRoot(\OC::$SERVERROOT . '/tests');
\OC_App::loadApp('files_pdfviewer');
if(!class_exists('\PHPUnit\Framework\TestCase')) {
require_once('PHPUnit/Autoload.php');
}
\OC_App::loadApp('files_pdfviewer');
OC_Hook::clear();
<?xml version="1.0" encoding="utf-8" ?>
<phpunit bootstrap="bootstrap.php"
strict="true"
verbose="true"
timeoutForSmallTests="900"
timeoutForMediumTests="900"
timeoutForLargeTests="900"
>
<testsuite name='ownCloud - Files_Pdfviewer App Tests'>
<directory suffix='test.php'>.</directory>
</testsuite>
<!-- filters for code coverage -->
<filter>
<whitelist>
<directory suffix=".php">../../files_pdfviewer</directory>
<exclude>
<directory suffix=".php">../../files_pdfviewer/vendor</directory>
<directory suffix=".php">../../files_pdfviewer/templates</directory>
<directory suffix=".php">../../files_pdfviewer/tests</directory>
</exclude>
</whitelist>
</filter>
<logging>
<!-- and this is where your report will be written -->
<log type="coverage-clover" target="./clover.xml"/>
</logging>
</phpunit>
<?php
/**
* @author Lukas Reschke
* @copyright 2014 Lukas Reschke lukas@owncloud.com
*
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Files_PdfViewer\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IRequest;
use OCP\IURLGenerator;
use Test\TestCase;
class DisplayControllerTest extends TestCase {
/** @var string */
private $appName;
/** @var IRequest */
private $request;
/** @var IURLGenerator */
private $urlGenerator;
/** @var DisplayController */
private $controller;
public function setUp(){
$this->appName = 'files_pdfviewer';
$this->request = $this->getMockBuilder(
'\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
$this->urlGenerator = $this->getMockBuilder(
'\OCP\IUrlGenerator')
->disableOriginalConstructor()
->getMock();
$this->controller = new DisplayController(
$this->appName,
$this->request,
$this->urlGenerator
);
parent::setUp();
}
public function testShowPdfViewer() {
$params = [
'urlGenerator' => $this->urlGenerator,
'minmode' => false
];
$expectedResponse = new TemplateResponse($this->appName, 'viewer', $params, 'blank');
$policy = new ContentSecurityPolicy();
$policy->addAllowedChildSrcDomain('\'self\'');
$policy->addAllowedFontDomain('data:');
$policy->addAllowedImageDomain('*');
$policy->allowEvalScript(false);
$expectedResponse->setContentSecurityPolicy($policy);
$this->assertEquals($expectedResponse, $this->controller->showPdfViewer());
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*! normalize.css v1.0.1 | MIT License | git.io/normalize */
/* ==========================================================================
HTML5 display definitions
========================================================================== */
/*
* Corrects `block` display not defined in IE 6/7/8/9 and Firefox 3.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
nav,
section,
summary {
display: block;
}
/*
* Corrects `inline-block` display not defined in IE 6/7/8/9 and Firefox 3.
*/
audio,
canvas,
video {
display: inline-block;
*display: inline;
*zoom: 1;
}
/*
* Prevents modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0;
}
/*
* Addresses styling for `hidden` attribute not present in IE 7/8/9, Firefox 3,
* and Safari 4.
* Known issue: no IE 6 support.
*/
[hidden] {
display: none;
}
/* ==========================================================================
Base
========================================================================== */
/*
* 1. Corrects text resizing oddly in IE 6/7 when body `font-size` is set using
* `em` units.
* 2. Prevents iOS text size adjust after orientation change, without disabling
* user zoom.
*/
html {
font-size: 100%; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-ms-text-size-adjust: 100%; /* 2 */
}
/*
* Addresses `font-family` inconsistency between `textarea` and other form
* elements.
*/
html,
button,
input,
select,
textarea {
font-family: sans-serif;
}
/*
* Addresses margins handled incorrectly in IE 6/7.
*/
body {
margin: 0;
}
/* ==========================================================================
Links
========================================================================== */
/*
* Addresses `outline` inconsistency between Chrome and other browsers.
*/
a:focus {
outline: thin dotted;
}
/*
* Improves readability when focused and also mouse hovered in all browsers.
*/
a:active,
a:hover {
outline: 0;
}
/* ==========================================================================
Typography
========================================================================== */
/*
* Addresses font sizes and margins set differently in IE 6/7.
* Addresses font sizes within `section` and `article` in Firefox 4+, Safari 5,
* and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0;
}
h2 {
font-size: 1.5em;
margin: 0.83em 0;
}
h3 {
font-size: 1.17em;
margin: 1em 0;
}
h4 {
font-size: 1em;
margin: 1.33em 0;
}
h5 {
font-size: 0.83em;
margin: 1.67em 0;
}
h6 {
font-size: 0.75em;
margin: 2.33em 0;
}
/*
* Addresses styling not present in IE 7/8/9, Safari 5, and Chrome.
*/
abbr[title] {
border-bottom: 1px dotted;
}
/*
* Addresses style set to `bolder` in Firefox 3+, Safari 4/5, and Chrome.
*/
b,
strong {
font-weight: bold;
}
blockquote {
margin: 1em 40px;
}
/*
* Addresses styling not present in Safari 5 and Chrome.
*/
dfn {
font-style: italic;
}
/*
* Addresses styling not present in IE 6/7/8/9.
*/
mark {
background: #ff0;
color: #000;
}
/*
* Addresses margins set differently in IE 6/7.
*/
p,
pre {
margin: 1em 0;
}
/*
* Corrects font family set oddly in IE 6, Safari 4/5, and Chrome.
*/
code,
kbd,
pre,
samp {
font-family: monospace, serif;
_font-family: 'courier new', monospace;
font-size: 1em;
}
/*
* Improves readability of pre-formatted text in all browsers.
*/
pre {
white-space: pre;
white-space: pre-wrap;
word-wrap: break-word;
}
/*
* Addresses CSS quotes not supported in IE 6/7.
*/
q {
quotes: none;
}
/*
* Addresses `quotes` property not supported in Safari 4.
*/
q:before,
q:after {
content: '';
content: none;
}
/*
* Addresses inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%;
}
/*
* Prevents `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
/* ==========================================================================
Lists
========================================================================== */
/*
* Addresses margins set differently in IE 6/7.
*/
dl,
menu,
ol,
ul {
margin: 1em 0;
}