diff --git a/src/Controller/BookController.php b/src/Controller/BookController.php index 06f4915b..8faf4347 100644 --- a/src/Controller/BookController.php +++ b/src/Controller/BookController.php @@ -103,15 +103,19 @@ public function read(Request $request, Book $book, string $slug, BookFileSystemM } switch ($book->getExtension()) { - // case 'epub': - // break; + case 'epub': + return $this->render('book/reader-files-epub.html.twig', [ + 'book' => $book, + 'file' => $fileSystemManager->getBookPublicPath($book), + ]); + case 'mobi': case 'pdf': case 'cbr': case 'cbz': $files = $fileSystemManager->extractFilesToRead($book); break; default: - $this->addFlash('danger', 'Unsupported book format'); + $this->addFlash('danger', 'Unsupported book format: '.$book->getExtension()); return $this->redirectToRoute('app_book', [ 'book' => $book->getId(), diff --git a/src/Service/BookFileSystemManager.php b/src/Service/BookFileSystemManager.php index efe7b9f8..7d2d6422 100644 --- a/src/Service/BookFileSystemManager.php +++ b/src/Service/BookFileSystemManager.php @@ -72,6 +72,13 @@ public function getBookFilename(Book $book): string return $this->handlePath($paths); } + public function getBookPublicPath(Book $book): string + { + $path = $this->getBookFilename($book); + + return str_replace($this->publicDir, '', $path); + } + public function getCoverFilename(Book $book): ?string { $paths = [$this->getCoverDirectory(), $book->getImagePath(), $book->getImageFilename()]; diff --git a/templates/book/reader-files-epub.html.twig b/templates/book/reader-files-epub.html.twig new file mode 100644 index 00000000..89200de2 --- /dev/null +++ b/templates/book/reader-files-epub.html.twig @@ -0,0 +1,94 @@ +{% extends themedTemplate('bare.html.twig') %} + +{% block title %}{{ book.authors|first }} {% if book.serie is not null %}> {{ book.serie }} #{{ book.serieIndex }} {% endif %}> {{ book.title }}{% endblock %} + +{% block stylesheets %} + + + + {{ parent() }} +{% endblock %} + +{% block javascripts %} + + {{ parent() }} +{% endblock %} + +{% block content %} +
+
+
+ +
+ +
+
+

Loading...

+
+
+ +
+ +
+
+
+{% endblock %}