diff --git a/assets/styles/app.css b/assets/styles/app.css index aba4857..eb9da0d 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -1,3 +1,8 @@ body { background-color: transparent; +} + +a:hover { + color: deepskyblue; + text-decoration: underline; } \ No newline at end of file diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml index 3f795d9..e13e04b 100644 --- a/config/packages/twig.yaml +++ b/config/packages/twig.yaml @@ -1,5 +1,7 @@ twig: file_name_pattern: '*.twig' + globals: + routing_service: '@App\Service\Twig\RoutingService' when@test: twig: diff --git a/src/Service/Twig/RoutingService.php b/src/Service/Twig/RoutingService.php new file mode 100644 index 0000000..fdca911 --- /dev/null +++ b/src/Service/Twig/RoutingService.php @@ -0,0 +1,23 @@ +attributes->get('dirs', ''); + $dirs = explode('/', $dirsString); + array_pop($dirs); + + return $this->urlGenerator->generate('app_home', ['dirs' => implode('/', $dirs)]); + } +} \ No newline at end of file diff --git a/templates/_partials/_row.html.twig b/templates/_partials/_row.html.twig index cf570e4..41567fe 100644 --- a/templates/_partials/_row.html.twig +++ b/templates/_partials/_row.html.twig @@ -1,13 +1,24 @@ +{% if file.name == '..' %} + {% set link = routing_service.goBack(app.request) %} +{% else %} + {% set link = path('app_home', {dirs: app.request.attributes.get('dirs') ~ '/' ~ file.name}) %} +{% endif %} + + - {% if file.type == 'dir' %} - {{ ux_icon('folder:closed', {height: '32px', width: '32px'}) }} - {% else %} - {{ ux_icon('file:default', {height: '32px', width: '32px'}) }} - {% endif %} + + {% if file.type == 'dir' %} + {{ ux_icon('folder:closed', {height: '32px', width: '32px'}) }} + {% else %} + {{ ux_icon('file:default', {height: '32px', width: '32px'}) }} + {% endif %} + - {{ file.name }} + + {{ file.name }} + {{ file.size }} diff --git a/templates/_partials/_table.html.twig b/templates/_partials/_table.html.twig index b159d15..5f7c8ed 100644 --- a/templates/_partials/_table.html.twig +++ b/templates/_partials/_table.html.twig @@ -14,6 +14,9 @@ + {% if app.request.requestUri != '/files' %} + {% include '_partials/_row.html.twig' with {file: {name: '..', size: '-', type: 'dir'}} %} + {% endif %} {% for dirContent in content %} {% include '_partials/_row.html.twig' with {file: dirContent} %} {% endfor %} @@ -24,10 +27,12 @@ {{ form_start(fileForm, {'attr': {'data-controller': 'upload-file'}}) }}
-