aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/views/components/errors/api-error.blade.php4
-rw-r--r--resources/views/components/errors/db-error.blade.php4
-rw-r--r--resources/views/pages/bookmarks.blade.php14
-rw-r--r--resources/views/pages/guestbook.blade.php16
-rw-r--r--resources/views/pages/music.blade.php14
-rw-r--r--resources/views/pages/weather.blade.php19
6 files changed, 65 insertions, 6 deletions
diff --git a/resources/views/components/errors/api-error.blade.php b/resources/views/components/errors/api-error.blade.php
new file mode 100644
index 0000000..1d4609a
--- /dev/null
+++ b/resources/views/components/errors/api-error.blade.php
@@ -0,0 +1,4 @@
+<div class="error-box">
+ <p><b>API Error:</b> There was an error connecting to the API.</p>
+ <p>If this error persists, please notify me via <a href="mailto:webmaster@diskfloppy.me">e-mail</a>.</p>
+</div>
diff --git a/resources/views/components/errors/db-error.blade.php b/resources/views/components/errors/db-error.blade.php
new file mode 100644
index 0000000..45f6157
--- /dev/null
+++ b/resources/views/components/errors/db-error.blade.php
@@ -0,0 +1,4 @@
+<div class="error-box">
+ <p><b>DB Error:</b> There was an error connecting to the database.</p>
+ <p>If this error persists, please notify me via <a href="mailto:webmaster@diskfloppy.me">e-mail</a>.</p>
+</div>
diff --git a/resources/views/pages/bookmarks.blade.php b/resources/views/pages/bookmarks.blade.php
index 54d464d..d7d8283 100644
--- a/resources/views/pages/bookmarks.blade.php
+++ b/resources/views/pages/bookmarks.blade.php
@@ -3,7 +3,18 @@
@section('description', 'This is the personal homepage of floppydisk.')
@section('content')
@php
- $categories = DB::select('
+ $db_alive = true;
+ try {
+ DB::connection()->getPdo();
+ } catch (Exception $e) {
+ $db_alive = false;
+ }
+ @endphp
+ @if (!$db_alive)
+ @include('components.errors.db-error')
+ @else
+ @php
+ $categories = DB::select('
SELECT id, name
FROM bookmark__categories
ORDER BY priority ASC
@@ -37,4 +48,5 @@
</table>
<br>
@endforeach
+ @endif
@stop
diff --git a/resources/views/pages/guestbook.blade.php b/resources/views/pages/guestbook.blade.php
index 08bc7cb..13415b4 100644
--- a/resources/views/pages/guestbook.blade.php
+++ b/resources/views/pages/guestbook.blade.php
@@ -1,13 +1,24 @@
@extends('layouts.default')
@section('title', 'Guestbook')
@section('content')
+ @php
+ $db_alive = true;
+ try {
+ DB::connection()->getPdo();
+ } catch (Exception $e) {
+ $db_alive = false;
+ }
+ @endphp
+ @if (!$db_alive)
+ @include('components.errors.db-error')
+ @else
<br>
<table class="gb-entry-form-container">
<tr>
<td>
<form method="POST" action="/guestbook">
@csrf
- <x-honeypot />
+ <x-honeypot/>
<table class="gb-entry-form">
<tr>
<td>
@@ -44,7 +55,7 @@
<p>A few things to note:</p>
<ul>
<li>You can submit an entry <u>once every hour</u>.</li>
- <li>Your IP address is logged but <u>not</u> publically displayed.</li>
+ <li>Your IP address is logged but <u>not</u> publicly displayed.</li>
<li>Any entries that appear to be spam <u>will</u> be removed.</li>
</ul>
</td>
@@ -74,4 +85,5 @@
</table>
<br>
@endforeach
+ @endif
@stop
diff --git a/resources/views/pages/music.blade.php b/resources/views/pages/music.blade.php
index 3e97daa..775157a 100644
--- a/resources/views/pages/music.blade.php
+++ b/resources/views/pages/music.blade.php
@@ -7,6 +7,19 @@
$cfg = app('config')->get('services')['lastfm'];
$api_root = app('config')->get('app')['api_root'];
+ $api_alive = true;
+
+ try {
+ $data = file_get_contents($api_root.'/lastfm/current');
+ } catch (Exception $e) {
+ $api_alive = false;
+ }
+ @endphp
+ @if (!$api_alive)
+ @include('components.errors.api-error')
+ @else
+
+ @php
$current_track = json_decode(file_get_contents($api_root . '/lastfm/current'));
$top_tracks = json_decode(file_get_contents($api_root . '/lastfm/top'));
$count = 0;
@@ -51,4 +64,5 @@
</tr>
@endforeach
</table>
+ @endif
@stop
diff --git a/resources/views/pages/weather.blade.php b/resources/views/pages/weather.blade.php
index 823c448..369927f 100644
--- a/resources/views/pages/weather.blade.php
+++ b/resources/views/pages/weather.blade.php
@@ -13,10 +13,22 @@ function degreesToCompassDirection($degrees) {
return $cardinalDirections[round($degrees*16/360)];
}
-$data = json_decode(file_get_contents($api_root.'/weather'));
-$updated = gmdate('H:i Y-m-d', $data->updated);
-$data = $data->current;
+$api_alive = true;
+
+try {
+ $data = file_get_contents($api_root.'/weather');
+} catch (Exception $e) {
+ $api_alive = false;
+}
@endphp
+@if (!$api_alive)
+ @include('components.errors.api-error')
+@else
+ @php
+ $data = json_decode(file_get_contents($api_root.'/weather'));
+ $updated = gmdate('H:i Y-m-d', $data->updated);
+ $data = $data->current;
+ @endphp
<table class="info-table">
<caption>
<h1>Local Weather</h1>
@@ -45,4 +57,5 @@ $data = $data->current;
</table>
<br>
<small><i>(Last Update: {{ $updated }})</i></small>
+@endif
@stop