diff --git a/README.md b/README.md index cd5af78..6292f3c 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ The OPDS root feed links to a hierarchical navigation feed mirroring the directo The feed is in compliance with the OPDS 1.1 specification according to the online OPDS validator (http://opds-validator.appspot.com/). -In the personal settings page there are options to enable/disable the feed (it is disabled by default), set the feed root directory (the default is /Library), enter a list of extensions to which the feed should be limited (by default this field is empty so it publishes all files descending from the feed root) and clear the personal bookshelf. +In the personal settings page there are options to enable/disable the feed (it is disabled by default), set the feed title, set the feed root directory (the default is /Library), enter a list of extensions to which the feed should be limited (by default this field is empty so it publishes all files descending from the feed root) and clear the personal bookshelf. -The admin settings page contains options to change file preview preferences (which should probably be in core or in a separate app as this changes a system-wide setting ('enabledPreviewProviders')). Also on the admin settings page is an option to change the cover image and thumbnail dimensions. +The admin settings page contains options to set the feed subtitle, change file preview preferences (which should probably be in core or in a separate app as this changes a system-wide setting ('enabledPreviewProviders')) and change the cover image and thumbnail dimensions. The OPDS feed is disabled when the app is installed, enable it in the personal settings page under the header 'OPDS'. Every user has his/her own feed, which feed you get depends on which credentials you enter. diff --git a/dist/files_opds-0.4.tar.gz b/dist/files_opds-0.4.tar.gz new file mode 100644 index 0000000..9b2b76f Binary files /dev/null and b/dist/files_opds-0.4.tar.gz differ diff --git a/files_opds/admin.php b/files_opds/admin.php index 4bfc869..575d9a2 100644 --- a/files_opds/admin.php +++ b/files_opds/admin.php @@ -10,17 +10,21 @@ namespace OCA\Files_Opds; +$l = new \OC_L10N('files_opds'); + \OCP\Util::addScript('files_opds', 'admin'); \OCP\Util::addStyle('files_opds', 'settings'); +$defaults = new \OC_Defaults(); $formats = array( ["epub" => Config::getPreview('OC\Preview\Epub') ? 1 : 0 ], ["pdf" => Config::getPreview('OC\Preview\PDF') ? 1 : 0], - ["openoffice" => Config::getPreview('OC\Preview\OpenOffice') ? 1 : 0], + ["opendocument" => Config::getPreview('OC\Preview\OpenDocument') ? 1 : 0], ["msoffice" => Config::getPreview('OC\Preview\MSOfficeDoc') ? 1 : 0] ); $tmpl = new \OCP\Template('files_opds', 'admin'); +$tmpl->assign('feedSubtitle', Config::getApp('feed-subtitle', $l->t("%s OPDS catalog", $defaults->getName()))); $tmpl->assign('previewFormats', $formats); $tmpl->assign('cover-x', Config::getApp('cover-x', '200')); $tmpl->assign('cover-y', Config::getApp('cover-y', '200')); diff --git a/files_opds/ajax/admin.php b/files_opds/ajax/admin.php index caaadf1..6dc814d 100644 --- a/files_opds/ajax/admin.php +++ b/files_opds/ajax/admin.php @@ -14,6 +14,7 @@ namespace OCA\Files_Opds; \OCP\JSON::callCheck(); \OCP\JSON::checkLoggedIn(); +$defaults = new \OC_Defaults(); $l = new \OC_L10N('files_opds'); @@ -23,11 +24,13 @@ if (isset($_POST['opdsCoverX'])) { $opdsCoverY = isset($_POST['opdsCoverY']) ? (int) $_POST['opdsCoverY'] : 200; $opdsThumbX = isset($_POST['opdsThumbX']) ? (int) $_POST['opdsThumbX'] : 36; $opdsThumbY = isset($_POST['opdsThumbY']) ? (int) $_POST['opdsThumbY'] : 36; + $opdsFeedSubtitle = isset($_POST['opdsFeedSubtitle']) ? $_POST['opdsFeedSubtitle'] : $l->t("%s OPDS catalog", $defaults->getName()); Config::setApp('cover-x', $opdsCoverX); Config::setApp('cover-y', $opdsCoverY); Config::setApp('thumb-x', $opdsThumbX); Config::setApp('thumb-y', $opdsThumbX); + Config::setApp('feed_subtitle', $opdsFeedSubtitle); } else { // set preview preferences $opdsPreviewEpub = $_POST['opdsPreviewEpub']; diff --git a/files_opds/ajax/personal.php b/files_opds/ajax/personal.php index 8ea0704..64fc9b5 100644 --- a/files_opds/ajax/personal.php +++ b/files_opds/ajax/personal.php @@ -20,6 +20,7 @@ $l = new \OC_L10N('files_opds'); $opdsEnable = isset($_POST['opdsEnable']) ? $_POST['opdsEnable'] : 'false'; $rootPath = isset($_POST['rootPath']) ? $_POST['rootPath'] : null; $fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : ''; +$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName()); if (!is_null($rootPath)){ if (\OC\Files\Filesystem::file_exists($rootPath) === false ){ @@ -38,6 +39,7 @@ if (!is_null($rootPath)){ } Config::set('enable', $opdsEnable); Config::set('file_types', $fileTypes); + Config::set('feed_title', $feedTitle); Config::set('id', Util::genUuid()); exit(); } diff --git a/files_opds/appinfo/info.xml b/files_opds/appinfo/info.xml index a378c62..1613baf 100644 --- a/files_opds/appinfo/info.xml +++ b/files_opds/appinfo/info.xml @@ -4,7 +4,7 @@ OPDS catalog Personal OPDS catalog AGPL - 0.3.1 + 0.4 Frank de Lange 7.0 true diff --git a/files_opds/js/admin.js b/files_opds/js/admin.js index 3aaa0aa..598ce9f 100644 --- a/files_opds/js/admin.js +++ b/files_opds/js/admin.js @@ -4,19 +4,19 @@ $(document).ready(function(){ save : function() { var epub = document.getElementById('opds-preview-epub').checked ? 'true' : 'false'; var pdf = document.getElementById('opds-preview-pdf').checked ? 'true' : 'false'; - var openoffice = document.getElementById('opds-preview-openoffice').checked ? 'true' : 'false'; + var opendocument = document.getElementById('opds-preview-opendocument').checked ? 'true' : 'false'; var msoffice = document.getElementById('opds-preview-msoffice').checked ? 'true' : 'false'; var data = { opdsPreviewEpub : epub, opdsPreviewPdf : pdf, - opdsPreviewOpenOffice : openoffice, + opdsPreviewOpenDocument : opendocument, opdsPreviewMsOffice : msoffice }; OC.msg.startSaving('#opds-admin .msg'); $.post(OC.filePath('files_opds', 'ajax', 'admin.php'), data, opdsAdminSettings.afterSave); }, afterSave : function(data){ - OC.msg.finishedSaving('#opds .msg', data); + OC.msg.finishedSaving('#opds-admin .msg', data); } }; @@ -26,23 +26,24 @@ $(document).ready(function(){ opdsCoverX : $('#opds-cover-x').val(), opdsCoverY : $('#opds-cover-y').val(), opdsThumbX : $('#opds-thumb-x').val(), - opdsThumbY : $('#opds-thumb-y').val() + opdsThumbY : $('#opds-thumb-y').val(), + opdsFeedSubtitle : $('#opds-feed-subtitle').val() }; OC.msg.startSaving('#opds-admin .msg'); $.post(OC.filePath('files_opds', 'ajax', 'admin.php'), data, opdsAdminCoverSettings.afterSave); }, afterSave : function(data){ - OC.msg.finishedSaving('#opds .msg', data); + OC.msg.finishedSaving('#opds-admin .msg', data); } }; $('#opds-preview-epub').on("change", opdsAdminSettings.save); $('#opds-preview-pdf').on("change", opdsAdminSettings.save); - $('#opds-preview-openoffice').on("change", opdsAdminSettings.save); + $('#opds-preview-opendocument').on("change", opdsAdminSettings.save); $('#opds-preview-msoffice').on("change", opdsAdminSettings.save); - $('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y').blur(opdsAdminCoverSettings.save); - $('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y').keypress(function( event ) { + $('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y,#opds-feed-subtitle').blur(opdsAdminCoverSettings.save); + $('#opds-cover-x,#opds-cover-y,#opds-thumb-x,#opds-thumb-y,#opds-feed-subtitle').keypress(function( event ) { if (event.which == 13) { event.preventDefault(); opdsAdminCoverSettings.save(); diff --git a/files_opds/js/personal.js b/files_opds/js/personal.js index 32c9b21..297b452 100644 --- a/files_opds/js/personal.js +++ b/files_opds/js/personal.js @@ -24,7 +24,8 @@ $(document).ready(function(){ var data = { opdsEnable : opdsEnable, rootPath : $('#opds-root-path').val(), - fileTypes : $('#opds-file-types').val() + fileTypes : $('#opds-file-types').val(), + feedTitle : $('#opds-feed-title').val() }; OC.msg.startSaving('#opds-personal .msg'); $.post(OC.filePath('files_opds', 'ajax', 'personal.php'), data, opdsSettings.afterSave); @@ -33,8 +34,8 @@ $(document).ready(function(){ OC.msg.finishedSaving('#opds-personal .msg', data); } }; - $('#opds-root-path,#opds-file-types').blur(opdsSettings.save); - $('#opds-root-path,#opds-file-types').keypress(function( event ) { + $('#opds-root-path,#opds-file-types,#opds-feed-title').blur(opdsSettings.save); + $('#opds-root-path,#opds-file-types,#opds-feed-title').keypress(function( event ) { if (event.which == 13) { event.preventDefault(); opdsSettings.save(); diff --git a/files_opds/lib/feed.php b/files_opds/lib/feed.php index 0edccb7..0c3516c 100644 --- a/files_opds/lib/feed.php +++ b/files_opds/lib/feed.php @@ -12,6 +12,7 @@ namespace OCA\Files_Opds; + /** * Feed class for OPDS */ @@ -64,7 +65,9 @@ class Feed $tmpl->assign('id', $id); $tmpl->assign('dir', $dir); $tmpl->assign('user', \OCP\User::getDisplayName()); - $tmpl->assign('ocname', $defaults->getName()); + $tmpl->assign('feed_title', Config::get('feed_title',\OCP\User::getDisplayName() . "'s Library")); + $tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog")); + $tmpl->assign('feed_updated', time()); $tmpl->printPage(); } diff --git a/files_opds/lib/files.php b/files_opds/lib/files.php index 929677b..a46398c 100644 --- a/files_opds/lib/files.php +++ b/files_opds/lib/files.php @@ -27,7 +27,7 @@ class Files extends \OCA\Files\Helper $entry = array(); $entry['id'] = $i['fileid']; - $entry['mtime'] = $i['mtime'] * 1000; + $entry['mtime'] = $i['mtime']; $entry['name'] = $i->getName(); $entry['type'] = $i['type']; if ($i['type'] === 'file') { diff --git a/files_opds/personal.php b/files_opds/personal.php index 3ed234d..6560e05 100644 --- a/files_opds/personal.php +++ b/files_opds/personal.php @@ -18,6 +18,7 @@ $tmpl->assign('opdsEnable-checked', ($opdsEnable === 'true') ? 'checked="checked $tmpl->assign('opdsEnable-value', ($opdsEnable === 'true') ? '1' : '0'); $tmpl->assign('rootPath', Config::get('root_path', '/Library')); $tmpl->assign('fileTypes', Config::get('file_types', '')); +$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OCP\User::getDisplayName()))); $tmpl->assign('bookshelf-count', Bookshelf::count()); $tmpl->assign('feedUrl', \OC_Helper::linkToAbsolute('','index.php') . '/apps/files_opds/'); diff --git a/files_opds/templates/admin.php b/files_opds/templates/admin.php index 0ac3a99..d8f4886 100644 --- a/files_opds/templates/admin.php +++ b/files_opds/templates/admin.php @@ -10,6 +10,8 @@ * later. */ +$l = new \OC_L10N('files_opds'); + function checkBox($format) { foreach($format as $name => $enabled) { echo '' : '>'); @@ -19,9 +21,14 @@ function checkBox($format) { ?> -
-

t('OPDS')); ?>

-

Enable preview for:

+
+

t('OPDS')); ?>

+
+ + " value="" /> +
+
+

t('Enable preview for:')); ?>

@@ -31,14 +38,14 @@ function checkBox($format) {

-

Cover size

+

t('Cover size')); ?>

" value="" /> " value="" />
-

Cover thumbnail size

+

t('Cover thumbnail size')); ?>

" value="" /> diff --git a/files_opds/templates/feed.php b/files_opds/templates/feed.php index 75e7e94..01ce793 100644 --- a/files_opds/templates/feed.php +++ b/files_opds/templates/feed.php @@ -25,8 +25,8 @@ echo ''; xmlns:dcterms="http://purl.org/dc/terms/" xmlns:opds="http://opds-spec.org/2010/catalog"> id: - <?php p($l->t("%s's library", array($_['user']))); ?> - t("%s OPDS Catalog", array($_['ocname']))); ?> + <?php p($_['feed_title']); ?> + @@ -38,103 +38,24 @@ echo ''; - - - <?php p($l->t("Browse catalog")); ?> - - t("Browse the catalog in alphabetical order")); ?> - - id:by_directory - - - <?php p($l->t("%s's bookshelf", array($_['user']))); ?> - - t("This bookshelf contains %s books", array($_['bookshelf-count']))); ?> - - id:by_bookshelf - - - - - <?php p($file['meta']['title']); ?> - - id: - - - - - - - urn:isbn: - - - - - - - - - - - - - - - - <?php p($file['name']); ?> - - id: - - - - - - - <?php p($file['meta']['title']); ?> - - id: - - - - - - - urn:isbn: - - - - - - - - - - - - - + +inc('part.feed.root')); +} elseif (($_['id'] == 'bookshelf')) { + foreach ($_['bookshelf'] as $file) { + print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ])); + } +} else { + foreach ($_['files'] as $file) { + if ($file['type'] == 'dir') { + print_unescaped($this->inc('part.feed.navigation', [ 'file' => $file ])); + } else { + print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ])); + } + } +} +?> diff --git a/files_opds/templates/part.feed.acquisition.php b/files_opds/templates/part.feed.acquisition.php new file mode 100644 index 0000000..83c18eb --- /dev/null +++ b/files_opds/templates/part.feed.acquisition.php @@ -0,0 +1,32 @@ + + <?php p($_['file']['meta']['title']); ?> + + id: + + + + + + + urn:isbn: + + + + + + + + + + + + + diff --git a/files_opds/templates/part.feed.navigation.php b/files_opds/templates/part.feed.navigation.php new file mode 100644 index 0000000..70568b2 --- /dev/null +++ b/files_opds/templates/part.feed.navigation.php @@ -0,0 +1,12 @@ + + <?php p($_['file']['name']); ?> + + id: + + + + diff --git a/files_opds/templates/part.feed.root.php b/files_opds/templates/part.feed.root.php new file mode 100644 index 0000000..16b7991 --- /dev/null +++ b/files_opds/templates/part.feed.root.php @@ -0,0 +1,16 @@ + + <?php p($l->t("Browse catalog")); ?> + + t("Browse the catalog in alphabetical order")); ?> + + id:by_directory + + + <?php p($l->t("%s's bookshelf", array($_['user']))); ?> + + t("This bookshelf contains %s books", array($_['bookshelf-count']))); ?> + + id:by_bookshelf + diff --git a/files_opds/templates/personal.php b/files_opds/templates/personal.php index ef92218..2d0252d 100644 --- a/files_opds/templates/personal.php +++ b/files_opds/templates/personal.php @@ -12,20 +12,28 @@ ?> -
-

t('OPDS')); ?>

+
+

t('OPDS')); ?>

type="checkbox">
-
- - " value="" /> -
-
- - " value="" /> -
+
+ + + + + + + + + + + + + +
" value="" />
" value="" />
" value="" />
+
" value=" t('Yes, I really want to clear my personal bookshelf')); ?>" hidden />