1
0
mirror of https://github.com/Kovah/LinkAce.git synced 2025-02-24 19:22:35 +01:00

Implement target handling for external links (#97)

This commit is contained in:
Kovah 2020-03-05 22:53:36 +01:00
parent 47a8c8b7a0
commit c4f2df0745
No known key found for this signature in database
GPG Key ID: AAAA031BA9830D7B
8 changed files with 18 additions and 8 deletions

View File

@ -213,3 +213,13 @@ function alert(?string $message = null, ?string $style = 'info'): Alert
return $alert->flash($message, $style);
}
/**
* Return proper link attributes based on the links_new_tab user setting
*
* @return string
*/
function linkTarget(): string
{
return usersettings('links_new_tab') ? 'target="_blank" rel="noopener noreferrer"' : '';
}

View File

@ -16,7 +16,7 @@
</a>
</td>
<td>
<a href="{{ $link->url }}" target="_blank">
<a href="{{ $link->url }}" {!! linkTarget() !!}>
{{ $link->url }}
</a>
</td>

View File

@ -3,7 +3,7 @@
{{ $link->title }}
</td>
<td>
<a href="{{ $link->url }}" target="_blank">
<a href="{{ $link->url }}" {!! linkTarget() !!}>
{{ $link->url }}
</a>
</td>

View File

@ -4,7 +4,7 @@
<div class="d-flex align-items-center">
<div class="mr-2">
{!! $link->getIcon('mr-1') !!}
<a href="{{ $link->url }}" target="_blank">{{ $link->title }}</a>
<a href="{{ $link->url }}" {!! linkTarget() !!}>{{ $link->title }}</a>
<small>({{ $link->url }})</small>
</div>
<div class="ml-auto text-right">

View File

@ -7,7 +7,7 @@
<i class="fas fa-lock text-muted mr-1" title="@lang('link.private')"></i>
@endif
{!! $link->getIcon('mr-1') !!}
<a href="{{ $link->url }}">{{ $link->title }}</a>
<a href="{{ $link->url }}" {!! linkTarget() !!}>{{ $link->title }}</a>
<br>
<small class="text-muted">({{ $link->shortUrl() }})</small>
</div>

View File

@ -8,7 +8,7 @@
@endif
</td>
<td>
<a href="{{ $link->url }}" target="_blank">
<a href="{{ $link->url }}" {!! linkTarget() !!}>
{{ $link->shortUrl() }}
</a>
</td>

View File

@ -7,7 +7,7 @@
<i class="fas fa-lock text-muted mr-1" title="@lang('link.private')"></i>
@endif
{!! $link->getIcon('mr-1') !!}
<a href="{{ $link->url }}">{{ $link->title }}</a>
<a href="{{ $link->url }}" {!! linkTarget() !!}>{{ $link->title }}</a>
<br>
<small class="text-muted">({{ $link->shortUrl() }})</small>
</div>

View File

@ -16,10 +16,10 @@
<div class="card-body">
<h2>
<a href="{{ $link->url }}">{{ $link->title }}</a>
<a href="{{ $link->url }}" {!! linkTarget() !!}>{{ $link->title }}</a>
</h2>
<div class="text-muted small mt-1 mb-3">
<a href="{{ $link->url }}">{{ $link->url }}</a>
<a href="{{ $link->url }}" {!! linkTarget() !!}>{{ $link->url }}</a>
</div>
<div class="row">