1
0
Fork 0
mirror of https://github.com/Yetangitu/owncloud-apps.git synced 2025-10-02 14:49:17 +02:00

Add fixes from @manvalls

This commit is contained in:
Alfred Egger 2019-11-25 12:29:02 +01:00
parent 0678c795e2
commit f86c35f890
36 changed files with 181 additions and 135 deletions

6
.directory Normal file
View file

@ -0,0 +1,6 @@
[Dolphin]
Timestamp=2019,11,25,12,16,0
Version=4
[Settings]
HiddenFilesShown=true

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -12,8 +12,8 @@
namespace OCA\Files_Opds; namespace OCA\Files_Opds;
\OCP\JSON::callCheck(); \OC_JSON::callCheck();
\OCP\JSON::checkLoggedIn(); \OC_JSON::checkLoggedIn();
$defaults = new \OC_Defaults(); $defaults = new \OC_Defaults();
$l = \OC::$server->getL10N('files_opds'); $l = \OC::$server->getL10N('files_opds');
@ -53,11 +53,10 @@ if (isset($_POST['opdsCoverX'])) {
Config::setPreview('OC\Preview\MSOffice2007',$opdsPreviewMsOffice); Config::setPreview('OC\Preview\MSOffice2007',$opdsPreviewMsOffice);
} }
\OCP\JSON::success( \OC_JSON::success(
array( array(
'data' => array('message'=> $l->t('Settings updated successfully.')) 'data' => array('message'=> $l->t('Settings updated successfully.'))
) )
); );
exit(); exit();

View file

@ -14,8 +14,8 @@ namespace OCA\Files_Opds;
$l = \OC::$server->getL10N('files_opds'); $l = \OC::$server->getL10N('files_opds');
\OCP\JSON::checkLoggedIn(); \OC_JSON::checkLoggedIn();
\OCP\JSON::callCheck(); \OC_JSON::callCheck();
Bookshelf::clear(); Bookshelf::clear();
\OCP\JSON::success(array( "data" => array( "message" => $l->t("Bookshelf cleared")))); \OC_JSON::success(array( "data" => array( "message" => $l->t("Bookshelf cleared"))));

View file

@ -12,8 +12,8 @@
namespace OCA\Files_Opds; namespace OCA\Files_Opds;
\OCP\JSON::callCheck(); \OC_JSON::callCheck();
\OCP\JSON::checkLoggedIn(); \OC_JSON::checkLoggedIn();
$l = \OC::$server->getL10N('files_opds'); $l = \OC::$server->getL10N('files_opds');
@ -21,25 +21,27 @@ $opdsEnable = isset($_POST['opdsEnable']) ? $_POST['opdsEnable'] : 'false';
$rootPath = isset($_POST['rootPath']) ? $_POST['rootPath'] : '/Library'; $rootPath = isset($_POST['rootPath']) ? $_POST['rootPath'] : '/Library';
$fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : ''; $fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : '';
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg'; $skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName()); $feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OC_User::getDisplayName());
$opdsoldMime = isset($_POST['opdsoldMime']) ? $_POST['opdsoldMime'] : '';
if (!strlen($rootPath) || if (!strlen($rootPath) ||
\OC\Files\Filesystem::isValidPath($rootPath) === false || \OC\Files\Filesystem::isValidPath($rootPath) === false ||
\OC\Files\Filesystem::file_exists($rootPath) === false ) { \OC\Files\Filesystem::file_exists($rootPath) === false ) {
\OCP\JSON::error( \OC_JSON::error(
array( array(
'data' => array('message'=> $l->t('Directory does not exist!')) 'data' => array('message'=> $l->t('Directory does not exist!'))
) )
); );
} else { } else {
Config::set('root_path', $rootPath); Config::set('root_path', $rootPath);
Config::set('enable', $opdsEnable); Config::set('enable', $opdsEnable);
Config::set('file_types', $fileTypes); Config::set('file_types', $fileTypes);
Config::set('skip_list', $skipList); Config::set('skip_list', $skipList);
Config::set('feed_title', $feedTitle); Config::set('feed_title', $feedTitle);
Config::set('old_mime', $opdsoldMime);
Config::set('id', Util::genUuid()); Config::set('id', Util::genUuid());
\OCP\JSON::success( \OC_JSON::success(
array( array(
'data' => array('message'=> $l->t('Settings updated successfully.')) 'data' => array('message'=> $l->t('Settings updated successfully.'))
) )
@ -47,4 +49,3 @@ if (!strlen($rootPath) ||
} }
exit(); exit();

View file

@ -14,8 +14,8 @@ namespace OCA\Files_Opds;
$l = \OC::$server->getL10N('files_opds'); $l = \OC::$server->getL10N('files_opds');
\OCP\JSON::checkLoggedIn(); \OC_JSON::checkLoggedIn();
\OCP\JSON::callCheck(); \OC_JSON::callCheck();
Meta::rescan(); Meta::rescan();
\OCP\JSON::success(array( "data" => array( "message" => $l->t("Rescan scheduled")))); \OC_JSON::success(array( "data" => array( "message" => $l->t("Rescan scheduled"))));

View file

@ -37,7 +37,7 @@ See [README] for more information on (mis)features of this app.
<database>sqlite</database> <database>sqlite</database>
<database>mysql</database> <database>mysql</database>
<owncloud min-version="8.2" max-version="10.0" /> <owncloud min-version="8.2" max-version="10.0" />
<nextcloud min-version="8.1" max-version="13.0" /> <nextcloud min-version="8.1" max-version="14.0" />
</dependencies> </dependencies>
<settings> <settings>
<admin>OCA\Files_Opds\Settings\Admin</admin> <admin>OCA\Files_Opds\Settings\Admin</admin>

View file

@ -39,8 +39,10 @@ $(document).ready(function(){
var opdsSettings = { var opdsSettings = {
save : function() { save : function() {
var opdsEnable = document.getElementById('opds-enable').checked ? 'true' : 'false'; var opdsEnable = document.getElementById('opds-enable').checked ? 'true' : 'false';
var opdsoldMime = document.getElementById('opds-oldmime').checked ? 'true' : 'false';
var data = { var data = {
opdsEnable : opdsEnable, opdsEnable : opdsEnable,
opdsoldMime : opdsoldMime,
rootPath : $('#opds-root-path').val(), rootPath : $('#opds-root-path').val(),
fileTypes : $('#opds-file-types').val(), fileTypes : $('#opds-file-types').val(),
skipList : $('#opds-skip-list').val(), skipList : $('#opds-skip-list').val(),
@ -61,5 +63,6 @@ $(document).ready(function(){
} }
}); });
$('#opds-enable').on("change", opdsSettings.save); $('#opds-enable').on("change", opdsSettings.save);
$('#opds-oldmime').on("change", opdsSettings.save);
}); });

View file

@ -25,7 +25,7 @@ class Config
* @return string retrieved value or default * @return string retrieved value or default
*/ */
public static function get($key, $default) { public static function get($key, $default) {
return \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_opds', $key, $default); return \OC::$server->getConfig()->getUserValue(\OC::$server->getUserSession()->getUser()->getUID(), 'files_opds', $key, $default);
} }
/** /**
@ -36,7 +36,7 @@ class Config
* @return bool success * @return bool success
*/ */
public static function set($key, $value) { public static function set($key, $value) {
return \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_opds', $key, $value); return \OC::$server->getConfig()->setUserValue(\OC::$server->getUserSession()->getUser()->getUID(), 'files_opds', $key, $value);
} }
/** /**
@ -47,7 +47,7 @@ class Config
* @return string retrieved value or default * @return string retrieved value or default
*/ */
public static function getApp($key, $default) { public static function getApp($key, $default) {
return \OCP\Config::getAppValue('files_opds', $key, $default); return \OC::$server->getConfig()->getAppValue('files_opds', $key, $default);
} }
/** /**
@ -58,17 +58,17 @@ class Config
* @return bool success * @return bool success
*/ */
public static function setApp($key, $value) { public static function setApp($key, $value) {
return \OCP\Config::setAppValue('files_opds', $key, $value); return \OC::$server->getConfig()->setAppValue('files_opds', $key, $value);
} }
/** /**
* @brief get preview status * @brief get preview status
* *
* @param string format * @param string format
* @return bool (true = enabled, false = disabled) * @return bool (true = enabled, false = disabled)
*/ */
public static function getPreview($format) { public static function getPreview($format) {
$enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null); $enablePreviewProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', null);
if (!($enablePreviewProviders === null)) { if (!($enablePreviewProviders === null)) {
return in_array($format, $enablePreviewProviders); return in_array($format, $enablePreviewProviders);
} }
@ -83,7 +83,7 @@ class Config
* @return bool * @return bool
*/ */
public static function setPreview($format, $enable = 'false') { public static function setPreview($format, $enable = 'false') {
$enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null); $enablePreviewProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', null);
if ($enable == 'true') { if ($enable == 'true') {
if ($enablePreviewProviders === null) { if ($enablePreviewProviders === null) {
// set up default providers // set up default providers
@ -103,7 +103,7 @@ class Config
} }
} }
if (!(\OCP\Config::setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) { if (!(\OC::$server->getConfig()->setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)"); logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)");
return true; return true;
} }

View file

@ -24,7 +24,7 @@ class Feed
* @return string feed id * @return string feed id
*/ */
public static function getFeedId() { public static function getFeedId() {
return Config::get('id', ''); return Config::get('id', '');
} }
/** /**
@ -66,8 +66,8 @@ class Feed
$tmpl->assign('id', $id); $tmpl->assign('id', $id);
$tmpl->assign('type', $type); $tmpl->assign('type', $type);
$tmpl->assign('dir', $dir); $tmpl->assign('dir', $dir);
$tmpl->assign('user', \OCP\User::getDisplayName()); $tmpl->assign('user', \OC_User::getDisplayName());
$tmpl->assign('feed_title', Config::get('feed_title',\OCP\User::getDisplayName() . "'s Library")); $tmpl->assign('feed_title', Config::get('feed_title',\OC_User::getDisplayName() . "'s Library"));
$tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog")); $tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog"));
$tmpl->assign('feed_updated', time()); $tmpl->assign('feed_updated', time());
$tmpl->printPage(); $tmpl->printPage();

View file

@ -64,7 +64,7 @@ class Meta
protected static function load($id) { protected static function load($id) {
$sql = 'SELECT * FROM `*PREFIX*opds_metadata` WHERE id = ?'; $sql = 'SELECT * FROM `*PREFIX*opds_metadata` WHERE id = ?';
$args = array($id); $args = array($id);
$query = \OCP\DB::prepare($sql); $query = \OC_DB::prepare($sql);
$result = $query->execute($args); $result = $query->execute($args);
return ($row = $result->fetchRow()) ? $row : false; return ($row = $result->fetchRow()) ? $row : false;
@ -79,7 +79,7 @@ class Meta
protected static function save($meta) { protected static function save($meta) {
$sql = "SELECT `id` FROM *PREFIX*opds_metadata WHERE `id`=?"; $sql = "SELECT `id` FROM *PREFIX*opds_metadata WHERE `id`=?";
$args = array($meta['id']); $args = array($meta['id']);
$query = \OCP\DB::prepare($sql); $query = \OC_DB::prepare($sql);
$result = $query->execute($args); $result = $query->execute($args);
$data = $result->fetchRow(); $data = $result->fetchRow();
if (isset($data['id'])) { if (isset($data['id'])) {
@ -118,7 +118,7 @@ class Meta
$meta['rescan'] $meta['rescan']
); );
} }
$query = \OCP\DB::prepare($sql); $query = \OC_DB::prepare($sql);
return $query->execute($args); return $query->execute($args);
} }
@ -150,7 +150,7 @@ class Meta
public static function remove($id) { public static function remove($id) {
$sql = "DELETE FROM *PREFIX*opds_metadata WHERE `id`=?"; $sql = "DELETE FROM *PREFIX*opds_metadata WHERE `id`=?";
$args = array($id); $args = array($id);
$query = \OCP\DB::prepare($sql); $query = \OC_DB::prepare($sql);
return $query->execute($args); return $query->execute($args);
} }
@ -162,7 +162,7 @@ class Meta
public static function rescan() { public static function rescan() {
$sql = "UPDATE *PREFIX*opds_metadata SET `rescan`=?"; $sql = "UPDATE *PREFIX*opds_metadata SET `rescan`=?";
$args = array(date("Y-m-d H:i:s")); $args = array(date("Y-m-d H:i:s"));
$query = \OCP\DB::prepare($sql); $query = \OC_DB::prepare($sql);
$result = $query->execute($args); $result = $query->execute($args);
} }

View file

@ -113,7 +113,7 @@ class Util
*/ */
public static function genUuid() { public static function genUuid() {
$defaults = new \OC_Defaults(); $defaults = new \OC_Defaults();
$hash = md5(\OCP\User::getDisplayName() . $defaults->getBaseUrl()); $hash = md5(\OC_User::getDisplayName() . $defaults->getBaseUrl());
$hash = substr($hash, 0, 8 ) .'-'. $hash = substr($hash, 0, 8 ) .'-'.
substr($hash, 8, 4) .'-3'. substr($hash, 8, 4) .'-3'.
substr($hash, 13, 3) .'-9'. substr($hash, 13, 3) .'-9'.

View file

@ -18,14 +18,17 @@ $l = \OC::$server->getL10N('files_opds');
$tmpl = new \OCP\Template('files_opds', 'personal'); $tmpl = new \OCP\Template('files_opds', 'personal');
$opdsEnable = Config::get('enable', false); $opdsEnable = Config::get('enable', false);
$opdsoldMime = Config::get('old_mime', false);
$tmpl->assign('opdsEnable-checked', ($opdsEnable === 'true') ? 'checked="checked"' : ''); $tmpl->assign('opdsEnable-checked', ($opdsEnable === 'true') ? 'checked="checked"' : '');
$tmpl->assign('opdsEnable-value', ($opdsEnable === 'true') ? '1' : '0'); $tmpl->assign('opdsEnable-value', ($opdsEnable === 'true') ? '1' : '0');
$tmpl->assign('rootPath', Config::get('root_path', '/Library')); $tmpl->assign('rootPath', Config::get('root_path', '/Library'));
$tmpl->assign('fileTypes', Config::get('file_types', '')); $tmpl->assign('fileTypes', Config::get('file_types', ''));
$tmpl->assign('skipList', Config::get('skip_list', 'metadata.opf,cover.jpg')); $tmpl->assign('skipList', Config::get('skip_list', 'metadata.opf,cover.jpg'));
$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OCP\User::getDisplayName()))); $tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OC_User::getDisplayName())));
$tmpl->assign('bookshelf-count', Bookshelf::count()); $tmpl->assign('bookshelf-count', Bookshelf::count());
$tmpl->assign('feedUrl', Util::linkToAbsolute('','index.php') . '/apps/files_opds/'); $tmpl->assign('feedUrl', Util::linkToAbsolute('','index.php') . '/apps/files_opds/');
$tmpl->assign('opdsoldMime-checked', ($opdsoldMime === 'true') ? 'checked="checked"' : '');
$tmpl->assign('opdsoldMime-value', ($opdsoldMime === 'true') ? '1' : '0');
return $tmpl->fetchPage(); return $tmpl->fetchPage();

View file

@ -48,7 +48,9 @@ switch ($_['type']) {
case 'bookshelf': case 'bookshelf':
foreach ($_['bookshelf'] as $file) { foreach ($_['bookshelf'] as $file) {
print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ])); foreach( $file as $key => $value )
$newfile["file_".$key] = $value;
print_unescaped($this->inc('part.feed.acquisition', $newfile ));
} }
break; break;
@ -60,10 +62,13 @@ switch ($_['type']) {
case 'directory': case 'directory':
default: default:
foreach ($_['files'] as $file) { foreach ($_['files'] as $file) {
foreach( $file as $key => $value )
$newfile["file_".$key] = $value;
if ($file['type'] == 'dir') { if ($file['type'] == 'dir') {
print_unescaped($this->inc('part.feed.navigation', [ 'file' => $file ])); print_unescaped($this->inc('part.feed.navigation', $newfile ));
} else { } else {
print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ])); print_unescaped($this->inc('part.feed.acquisition', $newfile ));
} }
} }
break; break;

View file

@ -1,38 +1,47 @@
<entry> <?php
<title><?php p($_['file']['meta']['title']); ?></title> namespace OCA\Files_Opds;
<updated><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file']['meta']['updated']))); ?></updated>
<id>id:<?php p($_['file']['id']); ?></id> if ( Config::get('old_mime', 'false') !== 'false' && strpos($_['file_mimetype'],'comicbook') !== false){
<dcterms:extent><?php p($_['file']['humansize']); ?></dcterms:extent> $mime = 'application/x-cbr';
<?php $authors = json_decode($_['file']['meta']['author'],true); if(is_array($authors)): foreach ($authors as $author): ?> } else {
$mime = $_['file_mimetype'];
}
?>
<entry>
<title><?php p($_['file_meta']['title']); ?></title>
<updated><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file_meta']['updated']))); ?></updated>
<id>id:<?php p($_['file_id']); ?></id>
<dcterms:extent><?php p($_['file_humansize']); ?></dcterms:extent>
<?php $authors = json_decode($_['file_meta']['author'],true); if(is_array($authors)): foreach ($authors as $author): ?>
<author> <author>
<name><?php p($author); ?></name> <name><?php p($author); ?></name>
</author> </author>
<?php endforeach; endif; ?> <?php endforeach; endif; ?>
<?php if($_['file']['meta']['isbn']): ?> <?php if($_['file_meta']['isbn']): ?>
<dc:identifier>urn:isbn:<?php p($_['file']['meta']['isbn']); ?></dc:identifier> <dc:identifier>urn:isbn:<?php p($_['file_meta']['isbn']); ?></dc:identifier>
<?php endif; ?> <?php endif; ?>
<?php if($_['file']['meta']['publisher']): ?> <?php if($_['file_meta']['publisher']): ?>
<dc:publisher><?php p($_['file']['meta']['publisher']); ?></dc:publisher> <dc:publisher><?php p($_['file_meta']['publisher']); ?></dc:publisher>
<?php endif; ?> <?php endif; ?>
<?php if($_['file']['meta']['language']): ?> <?php if($_['file_meta']['language']): ?>
<dc:language><?php p($_['file']['meta']['language']); ?></dc:language> <dc:language><?php p($_['file_meta']['language']); ?></dc:language>
<?php endif; ?> <?php endif; ?>
<dc:issued><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file']['meta']['date']))); ?></dc:issued> <dc:issued><?php p(date("Y-m-d\TH:i:sP",strtotime($_['file_meta']['date']))); ?></dc:issued>
<link type="<?php p($_['file']['mimetype']); ?>" <link type="<?php p($mime); ?>"
rel="alternate" rel="alternate"
href="?id=<?php p($_['file']['id']); ?>"/> href="?id=<?php p($_['file_id']); ?>"/>
<link type="<?php p($_['file']['mimetype']); ?>" <link type="<?php p($mime); ?>"
rel="http://opds-spec.org/acquisition/open-access" rel="http://opds-spec.org/acquisition/open-access"
href="?id=<?php p($_['file']['id']); ?>"/> href="?id=<?php p($_['file_id']); ?>"/>
<link href="?pid=<?php p($_['file']['id']); ?>" <link href="?pid=<?php p($_['file_id']); ?>"
rel="http://opds-spec.org/image" rel="http://opds-spec.org/image"
type="image/jpeg" /> type="image/jpeg" />
<link href="?tid=<?php p($_['file']['id']); ?>" <link href="?tid=<?php p($_['file_id']); ?>"
rel="http://opds-spec.org/image/thumbnail" rel="http://opds-spec.org/image/thumbnail"
type="image/jpeg" /> type="image/jpeg" />
<?php if ($_['file']['meta']['description']): ?> <?php if ($_['file_meta']['description']): ?>
<content type="text"><?php p($_['file']['meta']['description']); p("\n\n"); ?><?php p(formatMetadata($_['file']['humansize'],$_['file']['mimetype'],$_['file']['name'])); ?></content> <content type="text"><?php p($_['file_meta']['description']); p("\n\n"); ?><?php p(formatMetadata($_['file_humansize'],$mime,$_['file_name'])); ?></content>
<?php else: ?> <?php else: ?>
<summary type="text"><?php p(formatMetadata($_['file']['humansize'],$_['file']['mimetype'],$_['file']['name'])); ?></summary> <summary type="text"><?php p(formatMetadata($_['file_humansize'],$mime,$_['file_name'])); ?></summary>
<?php endif; ?> <?php endif; ?>
</entry> </entry>

View file

@ -1,12 +1,12 @@
<entry> <entry>
<title><?php p($_['file']['name']); ?></title> <title><?php p($_['file_name']); ?></title>
<updated><?php p(date("Y-m-d\TH:i:sP", $_['file']['mtime'])); ?></updated> <updated><?php p(date("Y-m-d\TH:i:sP", $_['file_mtime'])); ?></updated>
<id>id:<?php p($_['file']['id']); ?></id> <id>id:<?php p($_['file_id']); ?></id>
<link type="application/atom+xml;profile=opds-catalog;kind=navigation" <link type="application/atom+xml;profile=opds-catalog;kind=navigation"
rel="alternate" rel="alternate"
href="?id=<?php p($_['file']['id']); ?>"/> href="?id=<?php p($_['file_id']); ?>"/>
<link type="application/atom+xml;profile=opds-catalog;kind=navigation" <link type="application/atom+xml;profile=opds-catalog;kind=navigation"
rel="subsection" rel="subsection"
href="?id=<?php p($_['file']['id']); ?>"/> href="?id=<?php p($_['file_id']); ?>"/>
<content type="text"></content> <content type="text"></content>
</entry> </entry>

View file

@ -23,7 +23,8 @@ style('files_opds', 'settings');
</table> </table>
<div> <div>
<input id="opds-enable" name="opds-enable" value="<?php p($_['opdsEnable-value']) ?>" <?php p($_['opdsEnable-checked']) ?> type="checkbox" class="checkbox"> <input id="opds-enable" name="opds-enable" value="<?php p($_['opdsEnable-value']) ?>" <?php p($_['opdsEnable-checked']) ?> type="checkbox" class="checkbox">
<label for="opds-enable"><?php p($l->t('enable OPDS catalog')) ?></label> <label for="opds-enable"><?php p($l->t('enable OPDS catalog')) ?></label>
</div> </div>
<br> <br>
<table> <table>
@ -43,6 +44,10 @@ style('files_opds', 'settings');
<td><label for="opds-skip-list"><?php p($l->t('Skip these filenames:')) ?></label></td> <td><label for="opds-skip-list"><?php p($l->t('Skip these filenames:')) ?></label></td>
<td><input type="text" id="opds-skip-list" title="<?php p($l->t("Enter list of comma-separated file names which should be skipped. Leave blank to use the default skip list.")); ?>" value="<?php p($_['skipList']) ?>" /></td> <td><input type="text" id="opds-skip-list" title="<?php p($l->t("Enter list of comma-separated file names which should be skipped. Leave blank to use the default skip list.")); ?>" value="<?php p($_['skipList']) ?>" /></td>
</tr> </tr>
<tr>
<td><label for="opds-oldmime"><?php p($l->t('Use alternative Mimetypes for Comicbook:')) ?></label></td>
<td><input id="opds-oldmime" name="opds-oldmime" value="<?php p($_['opdsoldMime-value']) ?>" <?php p($_['opdsoldMime-checked']) ?> type="checkbox" title="For example use application/x-cbr instead of application/comicbook+rar"/></td>
</tr>
</table> </table>
<br> <br>
<div> <div>

View file

@ -21,9 +21,9 @@ $EpubEnable = isset($_POST['EpubEnable']) ? $_POST['EpubEnable'] : 'false';
$PdfEnable = isset($_POST['PdfEnable']) ? $_POST['PdfEnable'] : 'false'; $PdfEnable = isset($_POST['PdfEnable']) ? $_POST['PdfEnable'] : 'false';
$CbxEnable = isset($_POST['CbxEnable']) ? $_POST['CbxEnable'] : 'false'; $CbxEnable = isset($_POST['CbxEnable']) ? $_POST['CbxEnable'] : 'false';
\OC::$server->getAppConfig()->setValue('files_reader', 'epub_enable', $EpubEnable); Config::set('epub_enable', $EpubEnable);
\OC::$server->getAppConfig()->setValue('files_reader', 'pdf_enable', $PdfEnable); Config::set('pdf_enable', $PdfEnable);
\OC::$server->getAppConfig()->setValue('files_reader', 'cbx_enable', $CbxEnable); Config::set('cbx_enable', $CbxEnable);
\OC_JSON::success( \OC_JSON::success(
array( array(

View file

@ -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.2.3</version> <version>1.3.0</version>
<licence>AGPL</licence> <licence>AGPL</licence>
<author>Frank de Lange</author> <author>Frank de Lange</author>
<documentation> <documentation>
@ -47,15 +47,7 @@ See [README] for more exhaustive information on features and potential misfeatur
<category>files</category> <category>files</category>
<category>multimedia</category> <category>multimedia</category>
<category>office</category> <category>office</category>
<types>
<filesystem/>
</types>
<dependencies> <dependencies>
<owncloud min-version="8.2" max-version="10.0" /> <nextcloud min-version="14" max-version="17"/>
<nextcloud min-version="8.1" max-version="14.0"/>
<database>pgsql</database>
<database>sqlite</database>
<database>mysql</database>
</dependencies> </dependencies>
<ocsid>167127</ocsid>
</info> </info>

View file

@ -65,6 +65,8 @@
$('.directDownload').show(); $('.directDownload').show();
} }
$('iframe').remove(); $('iframe').remove();
$('body').off('focus.filesreader');
$(window).off('popstate.filesreader');
}, },
/** /**
@ -73,10 +75,10 @@
*/ */
show: function(downloadUrl, mimeType, isFileList) { show: function(downloadUrl, mimeType, isFileList) {
var self = this; var self = this;
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: mimeType});
// launch in new window on mobile and touch devices... // launch in new window on all devices
window.open(viewer, downloadUrl); window.open(viewer, downloadUrl);
}, },
/** /**
* @param fileActions * @param fileActions
@ -84,6 +86,16 @@
*/ */
_extendFileActions: function(fileActions) { _extendFileActions: function(fileActions) {
var self = this; var self = this;
var cbxMime = [
'application/x-cbr',
'application/comicbook+7z',
'application/comicbook+ace',
'application/comicbook+rar',
'application/comicbook+tar',
'application/comicbook+truecrypt',
'application/comicbook+zip'
];
fileActions.registerAction({ fileActions.registerAction({
name: 'view-epub', name: 'view-epub',
displayName: 'View', displayName: 'View',
@ -93,15 +105,22 @@
return actionHandler(fileName, 'application/epub+zip', context); return actionHandler(fileName, 'application/epub+zip', context);
} }
}); });
fileActions.registerAction({
name: 'view-cbr', cbxMime.forEach(function(mime, i){
displayName: 'View', fileActions.registerAction({
mime: 'application/x-cbr', name: 'view-cbr-' + i,
permissions: OC.PERMISSION_READ, displayName: 'View',
actionHandler: function(fileName, context) { mime: mime,
return actionHandler(fileName, 'application/x-cbr', context); permissions: OC.PERMISSION_READ,
} actionHandler: function (fileName, context) {
return actionHandler(fileName, 'application/x-cbr', context);
}
});
if (oc_appconfig.filesReader.enableCbx === 'true')
fileActions.setDefault(mime, 'view-cbr-' + i);
}); });
fileActions.registerAction({ fileActions.registerAction({
name: 'view-pdf', name: 'view-pdf',
displayName: 'View', displayName: 'View',
@ -114,8 +133,6 @@
if (oc_appconfig.filesReader.enableEpub === 'true') if (oc_appconfig.filesReader.enableEpub === 'true')
fileActions.setDefault('application/epub+zip', 'view-epub'); fileActions.setDefault('application/epub+zip', 'view-epub');
if (oc_appconfig.filesReader.enableCbx === 'true')
fileActions.setDefault('application/x-cbr', 'view-cbr');
if (oc_appconfig.filesReader.enablePdf === 'true') if (oc_appconfig.filesReader.enablePdf === 'true')
fileActions.setDefault('application/pdf', 'view-pdf'); fileActions.setDefault('application/pdf', 'view-pdf');
} }

View file

@ -19,7 +19,7 @@ use \OC\User\User as User;
class Hooks { class Hooks {
public static function register() { public static function register() {
Util::connectHook('js', 'OCA\Files_Reader\Hooks', 'announce_settings'); Util::connectHook('\OCP\Config', 'js', 'OCA\Files_Reader\Hooks', 'announce_settings');
\OC::$server->getRootFolder()->listen('\OC\Files', 'preDelete', function (Node $node) { \OC::$server->getRootFolder()->listen('\OC\Files', 'preDelete', function (Node $node) {
$fileId = $node->getId(); $fileId = $node->getId();
@ -38,9 +38,9 @@ class Hooks {
// TODO: rmeove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties // TODO: rmeove this when Owncloud starts encoding oc_appconfig as JSON just like it already encodes most other properties
$isJson = self::isJson($settings['array']['oc_appconfig']); $isJson = self::isJson($settings['array']['oc_appconfig']);
$array = ($isJson) ? json_decode($settings['array']['oc_appconfig'], true) : $settings['array']['oc_appconfig']; $array = ($isJson) ? json_decode($settings['array']['oc_appconfig'], true) : $settings['array']['oc_appconfig'];
$array['filesReader']['enableEpub'] = \OC::$server->getConfig()->getAppValue('epub_enable', 'true'); $array['filesReader']['enableEpub'] = Config::get('epub_enable', 'true');
$array['filesReader']['enablePdf'] = \OC::$server->getConfig()->getAppValue('pdf_enable', 'true'); $array['filesReader']['enablePdf'] = Config::get('pdf_enable', 'true');
$array['filesReader']['enableCbx'] = \OC::$server->getConfig()->getAppValue('cbx_enable', 'true'); $array['filesReader']['enableCbx'] = Config::get('cbx_enable', 'true');
$settings['array']['oc_appconfig'] = ($isJson) ? json_encode($array) : $array; $settings['array']['oc_appconfig'] = ($isJson) ? json_encode($array) : $array;
} }

View file

@ -25,7 +25,7 @@ class Config
* @return string retrieved value or default * @return string retrieved value or default
*/ */
public static function get($key, $default) { public static function get($key, $default) {
return \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_reader', $key, $default); return \OC::$server->getConfig()->getUserValue(\OCP\User::getUser(), 'files_reader', $key, $default);
} }
/** /**
@ -36,7 +36,7 @@ class Config
* @return bool success * @return bool success
*/ */
public static function set($key, $value) { public static function set($key, $value) {
return \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_reader', $key, $value); return \OC::$server->getConfig()->setUserValue(\OCP\User::getUser(), 'files_reader', $key, $value);
} }
/** /**
@ -47,7 +47,7 @@ class Config
* @return string retrieved value or default * @return string retrieved value or default
*/ */
public static function getApp($key, $default) { public static function getApp($key, $default) {
return \OCP\Config::getAppValue('files_reader', $key, $default); return \OC::$server->getConfig()->getAppValue('files_reader', $key, $default);
} }
/** /**
@ -58,6 +58,6 @@ class Config
* @return bool success * @return bool success
*/ */
public static function setApp($key, $value) { public static function setApp($key, $value) {
return \OCP\Config::setAppValue('files_reader', $key, $value); return \OC::$server->getConfig()->setAppValue('files_reader', $key, $value);
} }
} }

View file

@ -15,9 +15,9 @@ use OCP\Util;
#$l = \OC::$server->getL10N('files_reader'); #$l = \OC::$server->getL10N('files_reader');
$tmpl = new \OCP\Template('files_reader', 'settings-personal'); $tmpl = new \OCP\Template('files_reader', 'settings-personal');
$EpubEnable = \OC::$server->getConfig()->getAppValue('epub_enable', 'true'); $EpubEnable = Config::get('epub_enable', 'true');
$PdfEnable = \OC::$server->getConfig()->getAppValue('pdf_enable', 'true'); $PdfEnable = Config::get('pdf_enable', 'true');
$CbxEnable = \OC::$server->getConfig()->getAppValue('cbx_enable', 'true'); $CbxEnable = Config::get('cbx_enable', 'true');
$tmpl->assign('EpubEnable', $EpubEnable); $tmpl->assign('EpubEnable', $EpubEnable);
$tmpl->assign('PdfEnable', $PdfEnable); $tmpl->assign('PdfEnable', $PdfEnable);
$tmpl->assign('CbxEnable', $CbxEnable); $tmpl->assign('CbxEnable', $CbxEnable);

View file

@ -36,9 +36,9 @@
<title> <title>
<?php p($title);?> <?php p($title);?>
</title> </title>
<link rel="shortcut icon" href="img/book.png"> <link rel="shortcut icon" href="<?php p($urlGenerator->linkTo('files_reader', 'img/book.png')) ?>">
<link rel="stylesheet" href="vendor/icomoon/style.css?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>">
<link rel="stylesheet" href="vendor/cbrjs/css/cbr.css?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/cbrjs/css/cbr.css')) ?>?v=<?php p($version) ?>">
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'js/lib/Blob.js')) ?>?v=<?php p($version) ?>"> </script> <script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'js/lib/Blob.js')) ?>?v=<?php p($version) ?>"> </script>
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/libs/jquery.min.js')) ?>?v=<?php p($version) ?>"> </script> <script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/libs/jquery.min.js')) ?>?v=<?php p($version) ?>"> </script>
<script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/sindresorhus/screenfull.js')) ?>?v=<?php p($version) ?>"> </script> <script type="text/javascript" nonce="<?php p($nonce) ?>" src="<?php p($urlGenerator->linkTo('files_reader', 'vendor/sindresorhus/screenfull.js')) ?>?v=<?php p($version) ?>"> </script>
@ -109,7 +109,9 @@
<!-- /toolbar --> <!-- /toolbar -->
<!-- loading overlay --> <!-- loading overlay -->
<div id="cbr-loading-overlay" class="cbr-control control overlay" name="loadingOverlay" style="display:none"></div> <div id="cbr-loading-overlay" class="cbr-control control overlay" name="loadingOverlay" style="display:none">
<img src="<?php p($urlGenerator->linkTo('files_reader', 'img/loading.gif')) ?>">
</div>
<!-- /loading overlay --> <!-- /loading overlay -->
<!-- busy overlay --> <!-- busy overlay -->

View file

@ -36,7 +36,7 @@
<title> <title>
<?php p($title);?> <?php p($title);?>
</title> </title>
<link rel="shortcut icon" href="img/book.png"> <link rel="shortcut icon" href="<?php p($urlGenerator->linkTo('files_reader', 'img/book.png')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/css/main.css')) ?>?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/css/main.css')) ?>?v=<?php p($version) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/css/sidebar.css')) ?>?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/epubjs/css/sidebar.css')) ?>?v=<?php p($version) ?>">
@ -155,7 +155,7 @@
<div class="control-group"> <div class="control-group">
<input type="checkbox" id="use_custom_colors" name="use_custom_colors"> <input type="checkbox" id="use_custom_colors" name="use_custom_colors">
<label for="use_custom_colors"> <label for="use_custom_colors">
Use custom colors Use custom colors
</label> </label>
<div class="center-box"> <div class="center-box">
<input type="color" id="day_color" value="#0a0a0a"> <input type="color" id="day_color" value="#0a0a0a">
@ -209,7 +209,7 @@
<div class="control-group"> <div class="control-group">
<input type="checkbox" id="touch_nav" name="touch_nav"> <input type="checkbox" id="touch_nav" name="touch_nav">
<label for="touch_nav"> <label for="touch_nav">
disable extra-wide page turn areas disable extra-wide page turn areas
</label> </label>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -283,7 +283,7 @@
</div> </div>
</div> </div>
<div id="loader"> <div id="loader">
<img src="img/loading.gif"> <img src="<?php p($urlGenerator->linkTo('files_reader', 'img/loading.gif')) ?>">
</div> </div>
<!-- /navigation + viewer --> <!-- /navigation + viewer -->

View file

@ -36,7 +36,7 @@
<title> <title>
<?php p($title);?> <?php p($title);?>
</title> </title>
<link rel="shortcut icon" href="img/book.png"> <link rel="shortcut icon" href="<?php p($urlGenerator->linkTo('files_reader', 'img/book.png')) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/icomoon/style.css')) ?>?v=<?php p($version) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/main.css')) ?>?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/main.css')) ?>?v=<?php p($version) ?>">
<link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/sidebar.css')) ?>?v=<?php p($version) ?>"> <link rel="stylesheet" href="<?php p($urlGenerator->linkTo('files_reader', 'vendor/pdfjs/css/sidebar.css')) ?>?v=<?php p($version) ?>">
@ -113,7 +113,7 @@
<ul id="outline" class="outline"> <ul id="outline" class="outline">
</ul> </ul>
</div> </div>
<!-- currently not used <!-- currently not used
<div id="notesView" class="notes-view view"> <div id="notesView" class="notes-view view">
<div> <div>
@ -183,7 +183,7 @@
<div class="control-group"> <div class="control-group">
<input type="checkbox" id="touch_nav" name="touch_nav"> <input type="checkbox" id="touch_nav" name="touch_nav">
<label for="touch_nav"> <label for="touch_nav">
disable extra-wide page turn areas disable extra-wide page turn areas
</label> </label>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -310,7 +310,7 @@
</div> </div>
</div> </div>
<div id="loader"> <div id="loader">
<img src="img/loading.gif"> <img src="<?php p($urlGenerator->linkTo('files_reader', 'img/loading.gif')) ?>">
</div> </div>
<!-- /navigation + viewer --> <!-- /navigation + viewer -->

View file

@ -50,7 +50,7 @@ CBRJS.Reader = function(bookPath, _options) {
} }
xhr.open('GET',url, true); xhr.open('GET',url, true);
options.start(filename); options.start(filename);
xhr.responseType = "arraybuffer"; xhr.responseType = "arraybuffer";
@ -70,10 +70,10 @@ CBRJS.Reader = function(bookPath, _options) {
reader.options.session.size = e.total; reader.options.session.size = e.total;
}; };
xhr.onload = function () { xhr.onload = function () {
if ((this.status === 200) && this.response) { if ((this.status === 200) && this.response) {
var done = false; var done = false;
var ua = new bitjs.archive[archive_class](this.response, 'vendor/bitjs/'); var ua = new bitjs.archive[archive_class](this.response, document.head.dataset.basepath + 'vendor/bitjs/');
ua.addEventListener(bitjs.archive.UnarchiveEvent.Type.START, function (e) { ua.addEventListener(bitjs.archive.UnarchiveEvent.Type.START, function (e) {
$progressbar.css('width', '0%'); $progressbar.css('width', '0%');
@ -120,9 +120,9 @@ CBRJS.Reader = function(bookPath, _options) {
$('.icon-unarchive').removeClass('active'); $('.icon-unarchive').removeClass('active');
$('.icon-unarchive').addClass('error'); $('.icon-unarchive').addClass('error');
$('#message').text('Failed to extract images from archive, file corrupted?'); $('#message').text('Failed to extract images from archive, file corrupted?');
}); });
} }
ua.start(); ua.start();
}; };
@ -261,7 +261,7 @@ ComicBook = (function ($) {
thumbnails: true, // true / false (use thumbnails in index) thumbnails: true, // true / false (use thumbnails in index)
thumbnailWidth: 200, // width of thumbnail thumbnailWidth: 200, // width of thumbnail
sidebarWide: false, // use wide sidbar sidebarWide: false, // use wide sidbar
currentPage: 0, // current page currentPage: 0, // current page
keyboard: { keyboard: {
32: 'next', // space 32: 'next', // space
34: 'next', // page-down 34: 'next', // page-down
@ -276,7 +276,7 @@ ComicBook = (function ($) {
70: 'toggleFullscreen', // f 70: 'toggleFullscreen', // f
27: 'closeSidebar' // esc 27: 'closeSidebar' // esc
}, },
vendorPath: 'vendor/', vendorPath: document.head.dataset.basepath + 'vendor/',
forward_buffer: 3, forward_buffer: 3,
session: { session: {
getCursor: function() {}, getCursor: function() {},
@ -442,7 +442,7 @@ ComicBook = (function ($) {
break; break;
default: default:
console.log("unknown enhancement: " + JSON.stringify(prop)); console.log("unknown enhancement: " + JSON.stringify(prop));
} }
} }
}; };
@ -570,7 +570,7 @@ ComicBook = (function ($) {
}; };
/** /**
* Insert thumbnail into TOC * Insert thumbnail into TOC
*/ */
ComicBook.prototype.tocInsert = function (image, page, replace) { ComicBook.prototype.tocInsert = function (image, page, replace) {
var placeholder = toc.children[page].firstChild; var placeholder = toc.children[page].firstChild;
@ -578,7 +578,7 @@ ComicBook = (function ($) {
placeholder.parentNode.replaceChild( placeholder.parentNode.replaceChild(
self.getThumb(image), self.getThumb(image),
placeholder placeholder
); );
} }
toc.children[page].addEventListener('click', function (e) { toc.children[page].addEventListener('click', function (e) {
@ -1407,7 +1407,7 @@ ComicBook = (function ($) {
page = options.currentPage; page = options.currentPage;
} }
document.getElementById('toc').parentNode.scrollTop = document.getElementById('toc').parentNode.scrollTop =
document.getElementById('page-' + String(page + 1)).offsetTop document.getElementById('page-' + String(page + 1)).offsetTop
- Math.floor($('.panels').height() * 1.5); - Math.floor($('.panels').height() * 1.5);
}; };
@ -1474,5 +1474,3 @@ ComicBook = (function ($) {
} }
})(window, jQuery); })(window, jQuery);

View file

@ -116,7 +116,13 @@ body:not(.mobile) .navigate:hover {
#cbr-loading-overlay { #cbr-loading-overlay {
z-index: 100; z-index: 100;
background: #000 url("img/loading.gif") no-repeat center; padding: 0;
width: 20px;
height: 20px;
}
#cbr-loading-overlay > img {
width: 100%;
} }
.overlay { .overlay {