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

files_reader: fix not loading files with '+' in name (https://github.com/Yetangitu/owncloud-apps/issues/2), new dist file

This commit is contained in:
frankdelange 2014-12-16 09:15:23 +01:00
parent 9cf215dc16
commit b6ac51058d
5 changed files with 74 additions and 33 deletions

BIN
dist/files_reader-0.4.6.tar.gz vendored Normal file

Binary file not shown.

View file

@ -7,9 +7,5 @@ require 'files_opds/lib/epub-preview.php';
\OCP\App::registerPersonal('files_opds', 'personal'); \OCP\App::registerPersonal('files_opds', 'personal');
\OCP\App::registerAdmin('files_opds', 'admin'); \OCP\App::registerAdmin('files_opds', 'admin');
/* enable preview providers... */ /* register preview provider */
// \OCA\Files_Opds\Config::setPreview('OC\Preview\Epub',true);
/* ..and register preview provider */
\OC\Preview::registerProvider('OC\Preview\Epub'); \OC\Preview::registerProvider('OC\Preview\Epub');

View file

@ -93,32 +93,76 @@ class Meta
* @return array of metadata * @return array of metadata
*/ */
public static function get($id) { public static function get($id) {
if ($meta = self::load($id)) { if (!($meta = self::load($id))) {
return $meta; $meta = self::scan($id);
} else {
$meta = self::create($id);
$path = \OC\Files\Filesystem::getLocalFile(\OC\Files\Filesystem::getPath($id));
switch (strtolower(substr(strrchr($path, "."), 1))) {
case 'epub':
$epub = new Epub($path);
$meta['author'] = json_encode($epub->Authors());
$meta['title'] = $epub->Title();
$meta['date'] = $epub->Date();
$meta['publisher'] = $epub->Publisher();
$meta['copyright'] = $epub->Copyright();
$meta['language'] = $epub->Language();
$meta['description'] = strip_tags($epub->Description());
$meta['isbn'] = $epub->ISBN();
$meta['subjects'] = $epub->Subjects();
break;
default:
// set title to filename minus extension
$info = pathinfo($path);
$meta['title'] = basename($path,'.'.$info['extension']);
break;
}
self::save($meta);
return $meta;
} }
return $meta;
} }
/**
* @brief scan files for metadata
* PLAN: use search_lucene to extract metadata? Does not seem to support PDF1.6?
* solution: first ask search_lucene, if no data then scan file?
*
* @param int $id fileid
* @return array $meta metadata
*/
public static function scan($id) {
$meta = self::create($id);
$path = \OC\Files\Filesystem::getLocalFile(\OC\Files\Filesystem::getPath($id));
switch (strtolower(substr(strrchr($path, "."), 1))) {
case 'epub':
self::epub($path,$meta);
break;
case 'pdf':
self::pdf($path,$meta);
break;
}
/* if title is not set, assume metadata was invalid or not present
* use filename as title
*/
if (!($meta['title'])) {
$info = pathinfo($path);
$meta['title'] = basename($path,'.'.$info['extension']);
}
// self::save($meta);
return $meta;
}
/**
* @brief check epub for metadata
*
* @param string $path path to epub
* @param arrayref $meta reference to array of metadata
* @return bool $success (true if metadata found)
*/
public static function epub($path,&$meta) {
$epub = new Epub($path);
$meta['author'] = json_encode($epub->Authors());
$meta['title'] = $epub->Title();
$meta['date'] = $epub->Date();
$meta['publisher'] = $epub->Publisher();
$meta['copyright'] = $epub->Copyright();
$meta['language'] = $epub->Language();
$meta['description'] = strip_tags($epub->Description());
$meta['isbn'] = $epub->ISBN();
$meta['subjects'] = $epub->Subjects();
return true;
}
/**
* @brief check pdf for metadata
*
* @param string $path path to pdf
* @param arrayref $meta reference to array of metadata
* @return bool $success (true if metadata found)
*/
public static function pdf($path,&$meta) {
return false;
}
} }

View file

@ -3,7 +3,7 @@
<id>files_reader</id> <id>files_reader</id>
<name>Reader (ebook reader)</name> <name>Reader (ebook reader)</name>
<description>Online ePub file reader</description> <description>Online ePub file reader</description>
<version>0.4.5</version> <version>0.4.6</version>
<licence>LGPL</licence> <licence>LGPL</licence>
<author>Frank de Lange, (taken clues from Thomas Müller/files_pdfviewer, using slightly modified Futurepress/epub.js)</author> <author>Frank de Lange, (taken clues from Thomas Müller/files_pdfviewer, using slightly modified Futurepress/epub.js)</author>
<require>7.0</require> <require>7.0</require>

View file

@ -11,7 +11,8 @@ $mime = "application/zip+epub";
// download link varies by sharing status, compose it here // download link varies by sharing status, compose it here
$dllink = $share === '' $dllink = $share === ''
? OC_Helper::linkTo('files', 'ajax/download.php', array('dir' => urldecode($dir), 'files' => urldecode($file), 'share' => $share )) // ? OC_Helper::linkTo('files', 'ajax/download.php', array('dir' => urldecode($dir), 'files' => urldecode($file), 'share' => $share ))
? OC_Helper::linkTo('files', 'ajax/download.php', array('dir' => $dir, 'files' => $file, 'share' => $share ))
: OC_Helper::linkToPublic('files') . '&t=' . rawurlencode($share) . '&download'; : OC_Helper::linkToPublic('files') . '&t=' . rawurlencode($share) . '&download';
// needed for css/script inclusion // needed for css/script inclusion