mirror of
https://github.com/Yetangitu/owncloud-apps.git
synced 2025-10-02 14:49:17 +02:00
- add rudimentary epub parser for metadata extraction
- add cover images - add configurable preview settings (should probably be in core or in a separate app) - add some metadata to feed template (file size, type and filename)
This commit is contained in:
parent
64cfb7925e
commit
007b7c7791
13 changed files with 704 additions and 12 deletions
48
files_opds/lib/epub-preview.php
Normal file
48
files_opds/lib/epub-preview.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Files_Opds App
|
||||
*
|
||||
* @author Frank de Lange
|
||||
* @copyright 2014 Frank de Lange
|
||||
*
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
*/
|
||||
|
||||
namespace OC\Preview;
|
||||
|
||||
/**
|
||||
* Epub preview - returns cover or null
|
||||
*/
|
||||
class Epub extends Provider {
|
||||
|
||||
public function getMimeType() {
|
||||
return '/application\/epub\+zip/';
|
||||
}
|
||||
|
||||
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
||||
//get fileinfo
|
||||
$fileInfo = $fileview->getFileInfo($path);
|
||||
if(!$fileInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$absPath = $fileview->toTmpFile($path);
|
||||
|
||||
$epub = new \OCA\Files_Opds\Epub($absPath);
|
||||
|
||||
$cover = $epub->Cover();
|
||||
|
||||
if ($cover) {
|
||||
|
||||
$image = new \OC_Image();
|
||||
|
||||
$image->loadFromData($cover['data']);
|
||||
}
|
||||
|
||||
return (($cover !== null) && $image->valid()) ? $image : false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue