From: Raphaƫl Gertz Date: Fri, 18 Oct 2024 04:33:19 +0000 (+0200) Subject: Add directory and document methods X-Git-Tag: 0.0.4~4 X-Git-Url: https://git.rapsys.eu/treebundle/commitdiff_plain/6081ccbb83091e8ce6045f73b911bebfd2963ebd Add directory and document methods Fix facebook og:title fallback --- diff --git a/Controller/TreeController.php b/Controller/TreeController.php index 267cffa..a6e2ac1 100644 --- a/Controller/TreeController.php +++ b/Controller/TreeController.php @@ -156,12 +156,15 @@ class TreeController extends AbstractController { /** * The index page * - * Display file tree + * Display index * * @param Request $request The request instance * @return Response The rendered view */ - public function index(Request $request, string $path): Response { + public function index(Request $request): Response { + //Get roots + $this->context['roots'] = $this->config['roots']; + //Render template $response = $this->render('@RapsysTree/index.html.twig', $this->context); @@ -173,6 +176,52 @@ class TreeController extends AbstractController { return $response; } + /** + * The directory page + * + * Display directory + * + * @param Request $request The request instance + * @param string $path The directory path + * @return Response The rendered view + */ + public function directory(Request $request, string $path): Response { + header('Content-Type: text/plain'); + var_dump($path); + exit; + + //Render template + $response = $this->render('@RapsysTree/directory.html.twig', $this->context); + + $response->setEtag(md5($response->getContent())); + $response->setPublic(); + $response->isNotModified($request); + + //Return response + return $response; + } + + /** + * The document page + * + * Display document + * + * @param Request $request The request instance + * @param string $path The directory path + * @return Response The rendered view + */ + public function document(Request $request, string $path): Response { + //Render template + $response = $this->render('@RapsysTree/document.html.twig', $this->context); + + $response->setEtag(md5($response->getContent())); + $response->setPublic(); + $response->isNotModified($request); + + //Return response + return $response; + } + /** * Renders a view * @@ -227,9 +276,9 @@ class TreeController extends AbstractController { } //With empty facebook title and title - if (empty($parameters['facebook']['og:title']) && !empty($parameters['title'])) { + if (empty($parameters['facebook']['og:title']) && !empty($parameters['title']['page'])) { //Set facebook title - $parameters['facebook']['og:title'] = $parameters['title']; + $parameters['facebook']['og:title'] = $parameters['title']['page']; } //With empty facebook description and description