X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/d84f75c257d89aa3eb7a5288a5faeadcaa85fc43..refs/pull/1025/head:/app/Http/Controllers/BookController.php diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index decdfda49..ea39a771e 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -36,7 +36,7 @@ class BookController extends Controller */ public function index() { - $books = $this->entityRepo->getAllPaginated('book', 20); + $books = $this->entityRepo->getAllPaginated('book', 18); $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false; $popular = $this->entityRepo->getPopular('book', 4, 0); $new = $this->entityRepo->getRecentlyCreated('book', 4, 0); @@ -299,10 +299,7 @@ class BookController extends Controller { $book = $this->entityRepo->getBySlug('book', $bookSlug); $pdfContent = $this->exportService->bookToPdf($book); - return response()->make($pdfContent, 200, [ - 'Content-Type' => 'application/octet-stream', - 'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.pdf' - ]); + return $this->downloadResponse($pdfContent, $bookSlug . '.pdf'); } /** @@ -314,10 +311,7 @@ class BookController extends Controller { $book = $this->entityRepo->getBySlug('book', $bookSlug); $htmlContent = $this->exportService->bookToContainedHtml($book); - return response()->make($htmlContent, 200, [ - 'Content-Type' => 'application/octet-stream', - 'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.html' - ]); + return $this->downloadResponse($htmlContent, $bookSlug . '.html'); } /** @@ -328,10 +322,7 @@ class BookController extends Controller public function exportPlainText($bookSlug) { $book = $this->entityRepo->getBySlug('book', $bookSlug); - $htmlContent = $this->exportService->bookToPlainText($book); - return response()->make($htmlContent, 200, [ - 'Content-Type' => 'application/octet-stream', - 'Content-Disposition' => 'attachment; filename="' . $bookSlug . '.txt' - ]); + $textContent = $this->exportService->bookToPlainText($book); + return $this->downloadResponse($textContent, $bookSlug . '.txt'); } }