From d8501f2b331ca0b62611a742591669ebc9c373d0 Mon Sep 17 00:00:00 2001 From: SergiX44 Date: Wed, 18 Aug 2021 08:57:15 +0200 Subject: [PATCH] changed url building --- app/Controllers/MediaController.php | 4 ++-- app/Factories/ViewFactory.php | 1 + app/helpers.php | 11 +++++++++++ resources/templates/dashboard/grid.twig | 2 +- resources/templates/dashboard/list.twig | 2 +- resources/templates/upload/public.twig | 2 +- resources/templates/user/edit.twig | 4 ++-- src/css/app.css | 7 ++++++- 8 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/Controllers/MediaController.php b/app/Controllers/MediaController.php index c050bd4..3648796 100644 --- a/app/Controllers/MediaController.php +++ b/app/Controllers/MediaController.php @@ -84,8 +84,8 @@ class MediaController extends Controller 'delete_token' => $token, 'media' => $media, 'type' => $type, - 'url' => urlFor("/{$userCode}/{$mediaCode}"), - 'copy_raw' => $this->getSetting('copy_url_behavior', 'off') === 'raw', + 'url' => urlFor(glue($userCode, $mediaCode)), + 'copy_raw' => $this->session->get('copy_raw', false), ]); } diff --git a/app/Factories/ViewFactory.php b/app/Factories/ViewFactory.php index f20f77d..48ee204 100644 --- a/app/Factories/ViewFactory.php +++ b/app/Factories/ViewFactory.php @@ -42,6 +42,7 @@ class ViewFactory $twig->addFunction(new TwigFunction('inPath', 'inPath')); $twig->addFunction(new TwigFunction('humanFileSize', 'humanFileSize')); $twig->addFunction(new TwigFunction('param', 'param')); + $twig->addFunction(new TwigFunction('glue', 'glue')); return new View($twig); } diff --git a/app/helpers.php b/app/helpers.php index fafee40..a6f850c 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -493,3 +493,14 @@ if (!function_exists('isSecure')) { || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443); } } + +if (!function_exists('glue')) { + /** + * @param mixed ...$pieces + * @return string + */ + function glue(...$pieces): string + { + return '/'.implode('/', $pieces); + } +} diff --git a/resources/templates/dashboard/grid.twig b/resources/templates/dashboard/grid.twig index 64cd0f7..718d15f 100644 --- a/resources/templates/dashboard/grid.twig +++ b/resources/templates/dashboard/grid.twig @@ -19,7 +19,7 @@
{{ media.size }}
- diff --git a/resources/templates/dashboard/list.twig b/resources/templates/dashboard/list.twig index 40697ba..68cb08e 100644 --- a/resources/templates/dashboard/list.twig +++ b/resources/templates/dashboard/list.twig @@ -68,7 +68,7 @@ {% if media.username is not null %} - + {% else %} {% endif %} diff --git a/resources/templates/upload/public.twig b/resources/templates/upload/public.twig index 1670781..097c774 100644 --- a/resources/templates/upload/public.twig +++ b/resources/templates/upload/public.twig @@ -31,7 +31,7 @@