+
+ /**
+ * Exports a page to pdf format using barryvdh/laravel-dompdf wrapper.
+ * https://github.com/barryvdh/laravel-dompdf
+ * @param $bookSlug
+ * @param $pageSlug
+ * @return \Illuminate\Http\Response
+ */
+ public function exportPdf($bookSlug, $pageSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
+ $pdfContent = $this->exportService->pageToPdf($page);
+ return response()->make($pdfContent, 200, [
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.pdf'
+ ]);
+ }
+
+ /**
+ * Export a page to a self-contained HTML file.
+ * @param $bookSlug
+ * @param $pageSlug
+ * @return \Illuminate\Http\Response
+ */
+ public function exportHtml($bookSlug, $pageSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
+ $containedHtml = $this->exportService->pageToContainedHtml($page);
+ return response()->make($containedHtml, 200, [
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.html'
+ ]);
+ }
+
+ /**
+ * Export a page to a simple plaintext .txt file.
+ * @param $bookSlug
+ * @param $pageSlug
+ * @return \Illuminate\Http\Response
+ */
+ public function exportPlainText($bookSlug, $pageSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
+ $containedHtml = $this->exportService->pageToPlainText($page);
+ return response()->make($containedHtml, 200, [
+ 'Content-Type' => 'application/octet-stream',
+ 'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.txt'
+ ]);
+ }
+
+ /**
+ * Show a listing of recently created pages
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function showRecentlyCreated()
+ {
+ $pages = $this->pageRepo->getRecentlyCreatedPaginated(20);
+ return view('pages/detailed-listing', [
+ 'title' => 'Recently Created Pages',
+ 'pages' => $pages
+ ]);
+ }
+
+ /**
+ * Show a listing of recently created pages
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function showRecentlyUpdated()
+ {
+ $pages = $this->pageRepo->getRecentlyUpdatedPaginated(20);
+ return view('pages/detailed-listing', [
+ 'title' => 'Recently Updated Pages',
+ 'pages' => $pages
+ ]);
+ }
+
+ /**
+ * Show the Restrictions view.
+ * @param $bookSlug
+ * @param $pageSlug
+ * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
+ */
+ public function showRestrict($bookSlug, $pageSlug)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
+ $this->checkOwnablePermission('restrictions-manage', $page);
+ $roles = $this->userRepo->getRestrictableRoles();
+ return view('pages/restrictions', [
+ 'page' => $page,
+ 'roles' => $roles
+ ]);
+ }
+
+ /**
+ * Set the permissions for this page.
+ * @param $bookSlug
+ * @param $pageSlug
+ * @param Request $request
+ * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
+ */
+ public function restrict($bookSlug, $pageSlug, Request $request)
+ {
+ $book = $this->bookRepo->getBySlug($bookSlug);
+ $page = $this->pageRepo->getBySlug($pageSlug, $book->id);
+ $this->checkOwnablePermission('restrictions-manage', $page);
+ $this->pageRepo->updateEntityPermissionsFromRequest($request, $page);
+ session()->flash('success', 'Page Permissions Updated');
+ return redirect($page->getUrl());
+ }
+