Merge pull request #6876 from wallabag/fix/remove-remaining-mobi

Remove remaining MOBI stuff
This commit is contained in:
Jérémy Benoist 2023-08-23 10:20:23 +02:00 committed by GitHub
commit e30b5a856a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 132 deletions

50
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "8d38521d8cb653942ec9ede35d85882a", "content-hash": "cb15e9db979aaff7612963cd8b68479d",
"packages": [ "packages": [
{ {
"name": "babdev/pagerfanta-bundle", "name": "babdev/pagerfanta-bundle",
@ -14856,54 +14856,6 @@
], ],
"time": "2023-07-26T07:16:09+00:00" "time": "2023-07-26T07:16:09+00:00"
}, },
{
"name": "wallabag/php-mobi",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/wallabag/php-mobi.git",
"reference": "e725dd27e2d15830a54da27bab08ccef816890aa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/wallabag/php-mobi/zipball/e725dd27e2d15830a54da27bab08ccef816890aa",
"reference": "e725dd27e2d15830a54da27bab08ccef816890aa",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"symfony/polyfill-mbstring": "^1.12"
},
"type": "library",
"autoload": {
"files": [
"MOBIClass/MOBI.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Sander Kromwijk",
"email": "s.kromwijk@gmail.co",
"role": "Original developer"
},
{
"name": "Nicolas Lœuillet",
"email": "nicolas@loeuillet.org",
"homepage": "http://www.cdetc.fr"
}
],
"description": "A Mobipocket file (.mobi) creator in PHP.",
"homepage": "https://github.com/wallabag/php-mobi",
"support": {
"issues": "https://github.com/wallabag/php-mobi/issues",
"source": "https://github.com/wallabag/php-mobi/tree/1.1.1"
},
"time": "2022-03-22T10:25:12+00:00"
},
{ {
"name": "wallabag/phpepub", "name": "wallabag/phpepub",
"version": "4.0.10", "version": "4.0.10",

View file

@ -411,7 +411,7 @@ class EntryRestController extends WallabagRestController
* required=true, * required=true,
* @OA\Schema( * @OA\Schema(
* type="string", * type="string",
* enum={"xml", "json", "txt", "csv", "pdf", "epub", "mobi"}, * enum={"xml", "json", "txt", "csv", "pdf", "epub"},
* ) * )
* ), * ),
* @OA\Response( * @OA\Response(

View file

@ -21,7 +21,7 @@ class ExportController extends AbstractController
* Gets one entry content. * Gets one entry content.
* *
* @Route("/export/{id}.{format}", name="export_entry", requirements={ * @Route("/export/{id}.{format}", name="export_entry", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv", * "format": "epub|pdf|json|xml|txt|csv",
* "id": "\d+" * "id": "\d+"
* }) * })
* *
@ -55,7 +55,7 @@ class ExportController extends AbstractController
* Export all entries for current user. * Export all entries for current user.
* *
* @Route("/export/{category}.{format}", name="export_entries", requirements={ * @Route("/export/{category}.{format}", name="export_entries", requirements={
* "format": "epub|mobi|pdf|json|xml|txt|csv", * "format": "epub|pdf|json|xml|txt|csv",
* "category": "all|unread|starred|archive|tag_entries|untagged|search|annotated|same_domain" * "category": "all|unread|starred|archive|tag_entries|untagged|search|annotated|same_domain"
* }) * })
* *

View file

@ -247,55 +247,6 @@ class EntriesExport
); );
} }
/**
* Use PHPMobi to dump a .mobi file.
*
* @return Response
*/
private function produceMobi()
{
$mobi = new \MOBI();
$content = new \MOBIFile();
/*
* Book metadata
*/
$content->set('title', $this->title);
$content->set('author', $this->author);
$content->set('subject', $this->title);
/*
* Front page
*/
$content->appendParagraph($this->getExportInformation('PHPMobi'));
if (file_exists($this->logoPath)) {
$content->appendImage(imagecreatefrompng($this->logoPath));
}
$content->appendPageBreak();
/*
* Adding actual entries
*/
foreach ($this->entries as $entry) {
$content->appendChapterTitle($entry->getTitle());
$content->appendParagraph($entry->getContent());
$content->appendPageBreak();
}
$mobi->setContentProvider($content);
return Response::create(
$mobi->toString(),
200,
[
'Accept-Ranges' => 'bytes',
'Content-Description' => 'File Transfer',
'Content-type' => 'application/x-mobipocket-ebook',
'Content-Disposition' => 'attachment; filename="' . $this->getSanitizedFilename() . '.mobi"',
'Content-Transfer-Encoding' => 'binary',
]
);
}
/** /**
* Use TCPDF to dump a .pdf file. * Use TCPDF to dump a .pdf file.
* *

View file

@ -75,13 +75,6 @@ class EntryRestControllerTest extends WallabagApiTestCase
$this->assertStringContainsString('application/epub', $this->client->getResponse()->getContent()); $this->assertStringContainsString('application/epub', $this->client->getResponse()->getContent());
$this->assertSame('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type')); $this->assertSame('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type'));
// re-auth client for mobi
$client = $this->createAuthorizedClient();
$client->request('GET', '/api/entries/' . $entry->getId() . '/export.mobi');
$this->assertSame(200, $client->getResponse()->getStatusCode());
$this->assertSame('application/x-mobipocket-ebook', $client->getResponse()->headers->get('Content-Type'));
// re-auth client for pdf // re-auth client for pdf
$client = $this->createAuthorizedClient(); $client = $this->createAuthorizedClient();
$client->request('GET', '/api/entries/' . $entry->getId() . '/export.pdf'); $client->request('GET', '/api/entries/' . $entry->getId() . '/export.pdf');

View file

@ -65,7 +65,7 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->logInAs('admin'); $this->logInAs('admin');
$client = $this->getTestClient(); $client = $this->getTestClient();
$client->request('GET', '/export/0.mobi'); $client->request('GET', '/export/0.pdf');
$this->assertSame(404, $client->getResponse()->getStatusCode()); $this->assertSame(404, $client->getResponse()->getStatusCode());
} }
@ -80,7 +80,7 @@ class ExportControllerTest extends WallabagCoreTestCase
->getRepository(Entry::class) ->getRepository(Entry::class)
->findOneByUsernameAndNotArchived('bob'); ->findOneByUsernameAndNotArchived('bob');
$client->request('GET', '/export/' . $content->getId() . '.mobi'); $client->request('GET', '/export/' . $content->getId() . '.pdf');
$this->assertSame(404, $client->getResponse()->getStatusCode()); $this->assertSame(404, $client->getResponse()->getStatusCode());
} }
@ -102,28 +102,6 @@ class ExportControllerTest extends WallabagCoreTestCase
$this->assertSame('binary', $headers->get('content-transfer-encoding')); $this->assertSame('binary', $headers->get('content-transfer-encoding'));
} }
public function testMobiExport()
{
$this->logInAs('admin');
$client = $this->getTestClient();
$content = $client->getContainer()
->get(EntityManagerInterface::class)
->getRepository(Entry::class)
->findOneByUsernameAndNotArchived('admin');
ob_start();
$crawler = $client->request('GET', '/export/' . $content->getId() . '.mobi');
ob_end_clean();
$this->assertSame(200, $client->getResponse()->getStatusCode());
$headers = $client->getResponse()->headers;
$this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type'));
$this->assertSame('attachment; filename="' . $this->getSanitizedFilename($content->getTitle()) . '.mobi"', $headers->get('content-disposition'));
$this->assertSame('binary', $headers->get('content-transfer-encoding'));
}
public function testPdfExport() public function testPdfExport()
{ {
$this->logInAs('admin'); $this->logInAs('admin');