]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/BookExportController.php
Merge branch 'markdown-export' of https://github.com/nikhiljha/BookStack-1 into nikhi...
[bookstack] / app / Http / Controllers / BookExportController.php
index 1c1f124422f962020d31e4f35595b2e65d0f80cf..58868fa5c03036711d47a345cb00584954ab79bb 100644 (file)
@@ -52,4 +52,24 @@ class BookExportController extends Controller
         $textContent = $this->exportFormatter->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);
+    }
 }