From d7c91269c4a3a83227acf3a42b81c520dd46a156 Mon Sep 17 00:00:00 2001 From: Chris Kankiewicz Date: Sun, 8 Dec 2019 00:06:00 -0700 Subject: [PATCH] Added 'previous directory (..)' link for navigating up a single directory --- app/Controllers/DirectoryController.php | 13 +++++++++++++ app/themes/default/index.twig | 23 +++++++++++++++++++++++ index.php | 3 +++ 3 files changed, 39 insertions(+) diff --git a/app/Controllers/DirectoryController.php b/app/Controllers/DirectoryController.php index 9b9b37a..d9b4440 100644 --- a/app/Controllers/DirectoryController.php +++ b/app/Controllers/DirectoryController.php @@ -42,6 +42,7 @@ class DirectoryController return $this->view->render($response, 'index.twig', [ 'breadcrumbs' => $this->breadcrumbs($path), 'files' => $files->in($path), + 'is_root' => $this->isRoot($path), ]); } @@ -64,4 +65,16 @@ class DirectoryController return $carry; }, []); } + + /** + * Undocumented function. + * + * @param string $path + * + * @return bool + */ + protected function isRoot(string $path): bool + { + return realpath($path) === realpath($this->config->get('app.root')); + } } diff --git a/app/themes/default/index.twig b/app/themes/default/index.twig index 1d0612e..0e93123 100644 --- a/app/themes/default/index.twig +++ b/app/themes/default/index.twig @@ -33,6 +33,29 @@ + {% if not is_root %} + +
+ +
+ +
+ .. +
+ + + + +
+ {% endif %} + {% for file in files %} set(Twig::class, function (Config $config) { }); /** Configure the application components */ +$container->call(function (Config $config) { + $config->set('app.root', __DIR__); +}); $container->call(FilesComposer::class); $container->call(ViewComposer::class);