]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/BookExportController.php
move zip export into exportservice
[bookstack] / app / Http / Controllers / BookExportController.php
index cfa3d6a3a3d162e9eb5d3bf19afa5eb4a4f6b7b8..a92d94cc94f4f7a0b368dfb47b2a13f7009c8848 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace BookStack\Http\Controllers;
 
+use BookStack\Entities\Managers\BookContents;
 use BookStack\Entities\ExportService;
 use BookStack\Entities\Repos\BookRepo;
 use Throwable;
@@ -53,4 +54,24 @@ class BookExportController extends Controller
         $textContent = $this->exportService->bookToPlainText($book);
         return $this->downloadResponse($textContent, $bookSlug . '.txt');
     }
+
+    /**
+     * Export a book as a markdown file.
+     */
+    public function markdown(string $bookSlug)
+    {
+        $book = $this->bookRepo->getBySlug($bookSlug);
+        $textContent = $this->exportService->bookToMarkdown($book);
+        return $this->downloadResponse($textContent, $bookSlug . '.md');
+    }
+
+    /**
+     * Export a book as a zip file, made of markdown files.
+     */
+    public function zip(string $bookSlug)
+    {
+        $book = $this->bookRepo->getBySlug($bookSlug);
+        $filename = $this->exportService->bookToZip($book);
+        return response()->download($filename);
+    }
 }