Skip to content

Commit

Permalink
🐛 getCustomIcon()
Browse files Browse the repository at this point in the history
  • Loading branch information
MarceauKa committed Oct 30, 2019
1 parent 38d72bf commit 2fdc536
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/PwaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function manifest(Request $request, Shaarli $shaarli)
'prefer_related_applications' => false,
'icons' => [
[
'src' => url($shaarli->getCustomIcon()),
'src' => $shaarli->getCustomIconUrl(),
'type' => 'image/png',
'sizes' => '192x192 512x512',
]
Expand Down
11 changes: 11 additions & 0 deletions app/Services/Shaarli/Concerns/HandleCustomSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ public function handleCustomIcon(?UploadedFile $value): void
return;
}

public function getCustomIconUrl(): string
{
$icon = $this->getCustomIcon();

if ($icon === $this->getSettingsConfig()['custom_icon']['default']) {
return url($icon);
}

return Storage::disk('public')->url($icon);
}

public function handleCustomBackground($value): void
{
$data = (array)json_decode($value);
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/partials/head.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@stack('meta')
<link rel="manifest" href="{{ route('pwa.manifest') }}">
<base href="{{ url()->route('home') }}">
<link rel="icon" type="image/png" href="{{ url(app('shaarli')->getCustomIcon()) }}">
<link rel="icon" type="image/png" href="{{ app('shaarli')->getCustomIconUrl() }}">
<link rel="dns-prefetch" href="//fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
<link href="{{ mix('css/app.css') }}" rel="stylesheet">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/layouts/partials/navbar.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<nav class="navbar navbar-expand-md navbar-light mb-3">
<div class="container">
<a class="navbar-brand" href="{{ url('/') }}">
<img src="{{ url(app('shaarli')->getCustomIcon()) }}">
<img src="{{ app('shaarli')->getCustomIconUrl() }}">
<span>
{{ app('shaarli')->getName() }}
<sup class="fa-stack" v-if="!online">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/manage/settings.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<input type="file" class="custom-file-input" name="custom_icon" id="custom_icon" accept="image/png" />
</div>
<div class="input-group-append">
<img src="{{ url(app('shaarli')->getCustomIcon()) }}" class="img-fluid img-thumbnail" style="height: 37px;" />
<img src="{{ app('shaarli')->getCustomIconUrl() }}" class="img-fluid img-thumbnail" style="height: 37px;" />
</div>
</div>
@error('custom_icon')
Expand Down

0 comments on commit 2fdc536

Please sign in to comment.