use BookStack\Entities\Queries\BookQueries;
use BookStack\Exports\ExportFormatter;
+use BookStack\Exports\ZipExports\ZipExportBuilder;
use BookStack\Http\ApiController;
use Throwable;
return $this->download()->directly($markdown, $book->slug . '.md');
}
-}
+
+
+ /**
+ * Export a book to a contained ZIP export file.
+ * @throws NotFoundException
+ */
+ public function exportZip(int $id, ZipExportBuilder $builder)
+ {
+ $book = $this->queries->findVisibleByIdOrFail($id);
+ $bookName= $book->getShortName();
+
+ $zip = $builder->buildForBook($book);
+
+ return $this->download()->streamedFileDirectly($zip, $bookName . '.zip', filesize($zip), true);
+ }
+}
\ No newline at end of file
use BookStack\Entities\Queries\ChapterQueries;
use BookStack\Exports\ExportFormatter;
+use BookStack\Exports\ZipExports\ZipExportBuilder;
use BookStack\Http\ApiController;
use Throwable;
return $this->download()->directly($markdown, $chapter->slug . '.md');
}
-}
+
+ public function exportZip(int $id, ZipExportBuilder $builder)
+ {
+ $chapter = $this->queries->findVisibleByIdOrFail($id);
+ $chapterName= $chapter->getShortName();
+ $zip = $builder->buildForChapter($chapter);
+
+ return $this->download()->streamedFileDirectly($zip, $chapterName . '.zip', filesize($zip), true);
+ }
+}
\ No newline at end of file
use BookStack\Entities\Queries\PageQueries;
use BookStack\Exports\ExportFormatter;
+use BookStack\Exports\ZipExports\ZipExportBuilder;
use BookStack\Http\ApiController;
use Throwable;
return $this->download()->directly($markdown, $page->slug . '.md');
}
-}
+
+
+
+ public function exportZip(int $id, ZipExportBuilder $builder)
+ {
+ $page = $this->queries->findVisibleByIdOrFail($id);
+ $pageSlug = $page->slug;
+ $zip = $builder->buildForPage($page);
+
+ return $this->download()->streamedFileDirectly($zip, $pageSlug . '.zip', filesize($zip), true);
+ }
+}
\ No newline at end of file