mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-09-02 18:33:04 +02:00
Added 'previous directory (..)' link for navigating up a single directory
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
@@ -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 }}"
|
||||
|
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user