changed url building
This commit is contained in:
parent
ef0d3c1708
commit
d8501f2b33
8 changed files with 25 additions and 8 deletions
|
@ -84,8 +84,8 @@ class MediaController extends Controller
|
||||||
'delete_token' => $token,
|
'delete_token' => $token,
|
||||||
'media' => $media,
|
'media' => $media,
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'url' => urlFor("/{$userCode}/{$mediaCode}"),
|
'url' => urlFor(glue($userCode, $mediaCode)),
|
||||||
'copy_raw' => $this->getSetting('copy_url_behavior', 'off') === 'raw',
|
'copy_raw' => $this->session->get('copy_raw', false),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ class ViewFactory
|
||||||
$twig->addFunction(new TwigFunction('inPath', 'inPath'));
|
$twig->addFunction(new TwigFunction('inPath', 'inPath'));
|
||||||
$twig->addFunction(new TwigFunction('humanFileSize', 'humanFileSize'));
|
$twig->addFunction(new TwigFunction('humanFileSize', 'humanFileSize'));
|
||||||
$twig->addFunction(new TwigFunction('param', 'param'));
|
$twig->addFunction(new TwigFunction('param', 'param'));
|
||||||
|
$twig->addFunction(new TwigFunction('glue', 'glue'));
|
||||||
|
|
||||||
return new View($twig);
|
return new View($twig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,3 +493,14 @@ if (!function_exists('isSecure')) {
|
||||||
|| (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443);
|
|| (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('glue')) {
|
||||||
|
/**
|
||||||
|
* @param mixed ...$pieces
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function glue(...$pieces): string
|
||||||
|
{
|
||||||
|
return '/'.implode('/', $pieces);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<div class="pl-3 pt-2d5"><span class="badge badge-dark shadow-lg">{{ media.size }}</span></div>
|
<div class="pl-3 pt-2d5"><span class="badge badge-dark shadow-lg">{{ media.size }}</span></div>
|
||||||
<div class="text-right pr-3 pt-2d5">
|
<div class="text-right pr-3 pt-2d5">
|
||||||
<div class="btn-group shadow-lg">
|
<div class="btn-group shadow-lg">
|
||||||
<button type="button" class="btn btn-sm btn-success btn-clipboard" data-toggle="tooltip" title="{{ lang('copy_link') }}" data-clipboard-text="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension) }}{{ copy_raw ? '/raw.' ~ media.extension }}">
|
<button type="button" class="btn btn-sm btn-success btn-clipboard" data-toggle="tooltip" title="{{ lang('copy_link') }}" data-clipboard-text="{{ urlFor(glue(media.user_code, media.code) ~ (copy_raw ? '/raw.' ~ media.extension : '.' ~ media.extension)) }}">
|
||||||
<i class="fas fa-link"></i>
|
<i class="fas fa-link"></i>
|
||||||
</button>
|
</button>
|
||||||
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension ~ '/download') }}" class="btn btn-sm btn-secondary" data-toggle="tooltip" title="{{ lang('download') }}"><i class="fas fa-cloud-download-alt"></i></a>
|
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension ~ '/download') }}" class="btn btn-sm btn-secondary" data-toggle="tooltip" title="{{ lang('download') }}"><i class="fas fa-cloud-download-alt"></i></a>
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
{% if media.username is not null %}
|
{% if media.username is not null %}
|
||||||
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension) }}" class="btn btn-sm btn-outline-secondary" data-toggle="tooltip" title="{{ lang('open') }}" target="_blank"><i class="fas fa-external-link-alt"></i></a>
|
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension) }}" class="btn btn-sm btn-outline-secondary" data-toggle="tooltip" title="{{ lang('open') }}" target="_blank"><i class="fas fa-external-link-alt"></i></a>
|
||||||
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension ~ '/download') }}" class="btn btn-sm btn-outline-primary" data-toggle="tooltip" title="{{ lang('download') }}"><i class="fas fa-cloud-download-alt"></i></a>
|
<a href="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension ~ '/download') }}" class="btn btn-sm btn-outline-primary" data-toggle="tooltip" title="{{ lang('download') }}"><i class="fas fa-cloud-download-alt"></i></a>
|
||||||
<a href="javascript:void(0)" class="btn btn-sm btn-outline-success btn-clipboard" data-toggle="tooltip" title="{{ lang('copy_link') }}" data-clipboard-text="{{ urlFor('/' ~ media.user_code ~ '/' ~ media.code ~ '.' ~ media.extension) }}{{ copy_raw ? '/raw.' ~ media.extension }}"><i class="fas fa-link"></i></a>
|
<a href="javascript:void(0)" class="btn btn-sm btn-outline-success btn-clipboard" data-toggle="tooltip" title="{{ lang('copy_link') }}" data-clipboard-text="{{ urlFor(glue(media.user_code, media.code) ~ (copy_raw ? '/raw.' ~ media.extension : '.' ~ media.extension)) }}"><i class="fas fa-link"></i></a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ route('upload.raw', {'id': media.id}) }}" class="btn btn-sm btn-outline-dark" data-toggle="tooltip" title="{{ lang('raw') }}" target="_blank"><i class="fas fa-external-link-alt"></i></a>
|
<a href="{{ route('upload.raw', {'id': media.id}) }}" class="btn btn-sm btn-outline-dark" data-toggle="tooltip" title="{{ lang('raw') }}" target="_blank"><i class="fas fa-external-link-alt"></i></a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarCollapse">
|
<div class="collapse navbar-collapse" id="navbarCollapse">
|
||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
<a href="javascript:void(0)" class="btn btn-success my-2 my-sm-0 btn-clipboard" data-toggle="tooltip" title="{{ lang('copy_link') }}" data-clipboard-text="{{ url }}{{ copy_raw ? '/raw.' ~ media.extension }}"><i class="fas fa-link fa-lg fa-fw"></i></a>
|
<a href="javascript:void(0)" class="btn btn-success my-2 my-sm-0 btn-clipboard" data-toggle="tooltip" title="{{ lang('copy_link') }}" data-clipboard-text="{{ urlFor(glue(media.user_code, media.code) ~ (copy_raw ? '/raw.' ~ media.extension : '.' ~ media.extension)) }}"><i class="fas fa-link fa-lg fa-fw"></i></a>
|
||||||
<a href="{{ url }}/raw" class="btn btn-secondary my-2 my-sm-0" data-toggle="tooltip" title="{{ lang('raw') }}"><i class="fas fa-file-alt fa-lg fa-fw"></i></a>
|
<a href="{{ url }}/raw" class="btn btn-secondary my-2 my-sm-0" data-toggle="tooltip" title="{{ lang('raw') }}"><i class="fas fa-file-alt fa-lg fa-fw"></i></a>
|
||||||
<a href="{{ url }}/download" class="btn btn-warning my-2 my-sm-0" data-toggle="tooltip" title="{{ lang('download') }}"><i class="fas fa-cloud-download-alt fa-lg fa-fw"></i></a>
|
<a href="{{ url }}/download" class="btn btn-warning my-2 my-sm-0" data-toggle="tooltip" title="{{ lang('download') }}"><i class="fas fa-cloud-download-alt fa-lg fa-fw"></i></a>
|
||||||
{% if session.get('logged') %}
|
{% if session.get('logged') %}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<label for="token" class="col-sm-3 col-form-label">{{ lang('token') }}</label>
|
<label for="token" class="col-sm-3 col-form-label">{{ lang('token') }}</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" id="token" class="form-control" value="{{ user.token }}" readonly>
|
<input type="text" id="token" class="form-control privacy-blur" value="{{ user.token }}" readonly>
|
||||||
<div class="input-group-append">
|
<div class="input-group-append">
|
||||||
<button class="btn btn-outline-success btn-clipboard" type="button" data-clipboard-target="#token"><i class="fas fa-fw fa-copy"></i> {{ lang('copy') }}</button>
|
<button class="btn btn-outline-success btn-clipboard" type="button" data-clipboard-target="#token"><i class="fas fa-fw fa-copy"></i> {{ lang('copy') }}</button>
|
||||||
<button class="btn btn-outline-primary refresh-token" data-id="{{ user.id }}" type="button"><i class="fas fa-fw fa-sync"></i> {{ lang('update') }}</button>
|
<button class="btn btn-outline-primary refresh-token" data-id="{{ user.id }}" type="button"><i class="fas fa-fw fa-sync"></i> {{ lang('update') }}</button>
|
||||||
|
|
|
@ -224,3 +224,8 @@ body {
|
||||||
.hljs-ln-code {
|
.hljs-ln-code {
|
||||||
padding-left: 5px !important;
|
padding-left: 5px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.privacy-blur:not(:focus) {
|
||||||
|
color: transparent;
|
||||||
|
text-shadow: 0 0 5px rgba(0,0,0,0.5);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue