From c6ff0bc6911dbb4209f14b074a2ec9fc115af003 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 23 Aug 2023 08:44:40 +0200 Subject: [PATCH] Remove remaining MOBI stuff --- composer.lock | 50 +------------------ .../Controller/EntryRestController.php | 2 +- .../Controller/ExportController.php | 4 +- .../CoreBundle/Helper/EntriesExport.php | 49 ------------------ .../Controller/EntryRestControllerTest.php | 7 --- .../Controller/ExportControllerTest.php | 26 +--------- 6 files changed, 6 insertions(+), 132 deletions(-) diff --git a/composer.lock b/composer.lock index 82e75d5aa..5ff72d0f8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "8d38521d8cb653942ec9ede35d85882a", + "content-hash": "cb15e9db979aaff7612963cd8b68479d", "packages": [ { "name": "babdev/pagerfanta-bundle", @@ -14856,54 +14856,6 @@ ], "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", "version": "4.0.10", diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php index 89753facb..609085c1f 100644 --- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php +++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php @@ -411,7 +411,7 @@ class EntryRestController extends WallabagRestController * required=true, * @OA\Schema( * type="string", - * enum={"xml", "json", "txt", "csv", "pdf", "epub", "mobi"}, + * enum={"xml", "json", "txt", "csv", "pdf", "epub"}, * ) * ), * @OA\Response( diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php index c958a382c..03aa5fb1d 100644 --- a/src/Wallabag/CoreBundle/Controller/ExportController.php +++ b/src/Wallabag/CoreBundle/Controller/ExportController.php @@ -21,7 +21,7 @@ class ExportController extends AbstractController * Gets one entry content. * * @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+" * }) * @@ -55,7 +55,7 @@ class ExportController extends AbstractController * Export all entries for current user. * * @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" * }) * diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php index 350a396f8..fb5609cee 100644 --- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php +++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php @@ -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. * diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index e07cb4c32..938811617 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php @@ -75,13 +75,6 @@ class EntryRestControllerTest extends WallabagApiTestCase $this->assertStringContainsString('application/epub', $this->client->getResponse()->getContent()); $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 $client = $this->createAuthorizedClient(); $client->request('GET', '/api/entries/' . $entry->getId() . '/export.pdf'); diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php index 8ed942020..27c5fb9a9 100644 --- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php @@ -65,7 +65,7 @@ class ExportControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getTestClient(); - $client->request('GET', '/export/0.mobi'); + $client->request('GET', '/export/0.pdf'); $this->assertSame(404, $client->getResponse()->getStatusCode()); } @@ -80,7 +80,7 @@ class ExportControllerTest extends WallabagCoreTestCase ->getRepository(Entry::class) ->findOneByUsernameAndNotArchived('bob'); - $client->request('GET', '/export/' . $content->getId() . '.mobi'); + $client->request('GET', '/export/' . $content->getId() . '.pdf'); $this->assertSame(404, $client->getResponse()->getStatusCode()); } @@ -102,28 +102,6 @@ class ExportControllerTest extends WallabagCoreTestCase $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() { $this->logInAs('admin');