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:
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
BIN
dist/files_reader-0.4.6.tar.gz
vendored
Normal file
Binary file not shown.
|
@ -7,9 +7,5 @@ require 'files_opds/lib/epub-preview.php';
|
|||
\OCP\App::registerPersonal('files_opds', 'personal');
|
||||
\OCP\App::registerAdmin('files_opds', 'admin');
|
||||
|
||||
/* enable preview providers... */
|
||||
// \OCA\Files_Opds\Config::setPreview('OC\Preview\Epub',true);
|
||||
|
||||
/* ..and register preview provider */
|
||||
/* register preview provider */
|
||||
\OC\Preview::registerProvider('OC\Preview\Epub');
|
||||
|
||||
|
|
|
@ -93,13 +93,53 @@ class Meta
|
|||
* @return array of metadata
|
||||
*/
|
||||
public static function get($id) {
|
||||
if ($meta = self::load($id)) {
|
||||
if (!($meta = self::load($id))) {
|
||||
$meta = self::scan($id);
|
||||
}
|
||||
return $meta;
|
||||
} else {
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
@ -110,15 +150,19 @@ class Meta
|
|||
$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 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<id>files_reader</id>
|
||||
<name>Reader (ebook reader)</name>
|
||||
<description>Online ePub file reader</description>
|
||||
<version>0.4.5</version>
|
||||
<version>0.4.6</version>
|
||||
<licence>LGPL</licence>
|
||||
<author>Frank de Lange, (taken clues from Thomas Müller/files_pdfviewer, using slightly modified Futurepress/epub.js)</author>
|
||||
<require>7.0</require>
|
||||
|
|
|
@ -11,7 +11,8 @@ $mime = "application/zip+epub";
|
|||
|
||||
// download link varies by sharing status, compose it here
|
||||
$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';
|
||||
|
||||
// needed for css/script inclusion
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue