3 namespace BookStack\Http\Controllers;
5 use BookStack\Entities\Repos\PageRepo;
6 use BookStack\Exceptions\NotFoundException;
7 use Illuminate\Http\Request;
9 class PageTemplateController extends Controller
14 * PageTemplateController constructor.
16 public function __construct(PageRepo $pageRepo)
18 $this->pageRepo = $pageRepo;
22 * Fetch a list of templates from the system.
24 public function list(Request $request)
26 $page = $request->get('page', 1);
27 $search = $request->get('search', '');
28 $templates = $this->pageRepo->getTemplates(10, $page, $search);
31 $templates->appends(['search' => $search]);
34 return view('pages.parts.template-manager-list', [
35 'templates' => $templates,
40 * Get the content of a template.
42 * @throws NotFoundException
44 public function get(int $templateId)
46 $page = $this->pageRepo->getById($templateId);
48 if (!$page->template) {
49 throw new NotFoundException();
52 return response()->json([
53 'html' => $page->html,
54 'markdown' => $page->markdown,