Added 'previous directory (..)' link for navigating up a single directory

This commit is contained in:
Chris Kankiewicz
2019-12-08 00:06:00 -07:00
parent 73051d8866
commit d7c91269c4
3 changed files with 39 additions and 0 deletions

View File

@@ -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'));
}
}

View File

@@ -33,6 +33,29 @@
</div>
</div>
{% if not is_root %}
<a
href=".."
class="flex justify-between items-center rounded-lg p-4 hover:bg-gray-200 hover:p-4 hover:shadow"
>
<div class="flex-shrink text-gray-700 pr-2">
<i class="fas fa-level-up-alt fa-fw fa-lg"></i>
</div>
<div class="flex-grow truncate mr-2">
..
</div>
<div class="hidden whitespace-no-wrap text-right mx-2 w-1/6 sm:block">
</div>
<div class="hidden whitespace-no-wrap text-right truncate ml-2 w-1/4 sm:block">
</div>
</a>
{% endif %}
{% for file in files %}
<a
href="{{ file.getRelativePathname }}"

View File

@@ -29,6 +29,9 @@ $container->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);