Update theme to use some colors from catppuccin, add error handling for API/DB
This commit is contained in:
		
					parent
					
						
							
								88b5abee0b
							
						
					
				
			
			
				commit
				
					
						689c494928
					
				
			
		
					 7 changed files with 85 additions and 14 deletions
				
			
		|  | @ -1,6 +1,7 @@ | ||||||
| :root { | :root { | ||||||
|     --background: #1c1b22; |     --background: #181926; | ||||||
|     --foreground: #dddddd; |     --foreground: #cad3f5; | ||||||
|  |     --links: #8aadf4; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| body { | body { | ||||||
|  | @ -128,7 +129,7 @@ div.note { | ||||||
| 
 | 
 | ||||||
| table { | table { | ||||||
|     border-collapse: collapse; |     border-collapse: collapse; | ||||||
|     border-color: #fff; |     border-color: var(--foreground); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table.weather th { | table.weather th { | ||||||
|  | @ -178,7 +179,7 @@ td { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .header .title { | .header .title { | ||||||
|     color: #fff; |     color: var(--foreground); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| .header { | .header { | ||||||
|  | @ -186,7 +187,6 @@ .header { | ||||||
|     font-weight: normal; |     font-weight: normal; | ||||||
|     padding-bottom: 0; |     padding-bottom: 0; | ||||||
|     text-align: center; |     text-align: center; | ||||||
|     color: #ffffff; |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| h1 { | h1 { | ||||||
|  | @ -224,7 +224,7 @@ table.commits tr td { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| a { | a { | ||||||
|     color: #99f; |     color: var(--links); | ||||||
|     text-decoration: none; |     text-decoration: none; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -265,7 +265,7 @@ table.gb-entry-form tbody tr td textarea { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table.gb-entry tr td { | table.gb-entry tr td { | ||||||
|     border: solid #ffffff 1px; |     border: solid var(--foreground) 1px; | ||||||
|     width: 500px; |     width: 500px; | ||||||
|     vertical-align: top; |     vertical-align: top; | ||||||
|     padding: 5px; |     padding: 5px; | ||||||
|  | @ -278,7 +278,7 @@ table.gb-entry { | ||||||
| table.gb-admin { | table.gb-admin { | ||||||
|     margin-bottom: 5px; |     margin-bottom: 5px; | ||||||
|     width: 500px; |     width: 500px; | ||||||
|     border: #fff solid; |     border: var(--foreground) solid; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| table.gb-admin tr td { | table.gb-admin tr td { | ||||||
|  | @ -371,3 +371,15 @@ .spec-title { | ||||||
| .computer-specs { | .computer-specs { | ||||||
|     margin-top: 5px; |     margin-top: 5px; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | .error-box { | ||||||
|  |     width: 500px; | ||||||
|  |     border: 5px solid #c81a11; | ||||||
|  |     background-color: #f64a3c; | ||||||
|  |     padding: 5px; | ||||||
|  | } | ||||||
|  | .error-box a, | ||||||
|  | .error-box p { | ||||||
|  |     margin: 0; | ||||||
|  |     color: var(--foreground) | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								resources/views/components/errors/api-error.blade.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/views/components/errors/api-error.blade.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -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> | ||||||
							
								
								
									
										4
									
								
								resources/views/components/errors/db-error.blade.php
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								resources/views/components/errors/db-error.blade.php
									
										
									
									
									
										Normal file
									
								
							|  | @ -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> | ||||||
|  | @ -3,7 +3,18 @@ | ||||||
| @section('description', 'This is the personal homepage of floppydisk.') | @section('description', 'This is the personal homepage of floppydisk.') | ||||||
| @section('content') | @section('content') | ||||||
|     @php |     @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 |         SELECT id, name | ||||||
|         FROM bookmark__categories |         FROM bookmark__categories | ||||||
|         ORDER BY priority ASC |         ORDER BY priority ASC | ||||||
|  | @ -37,4 +48,5 @@ | ||||||
|         </table> |         </table> | ||||||
|         <br> |         <br> | ||||||
|     @endforeach |     @endforeach | ||||||
|  |     @endif | ||||||
| @stop | @stop | ||||||
|  |  | ||||||
|  | @ -1,13 +1,24 @@ | ||||||
| @extends('layouts.default') | @extends('layouts.default') | ||||||
| @section('title', 'Guestbook') | @section('title', 'Guestbook') | ||||||
| @section('content') | @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> |     <br> | ||||||
|     <table class="gb-entry-form-container"> |     <table class="gb-entry-form-container"> | ||||||
|         <tr> |         <tr> | ||||||
|             <td> |             <td> | ||||||
|                 <form method="POST" action="/guestbook"> |                 <form method="POST" action="/guestbook"> | ||||||
|                     @csrf |                     @csrf | ||||||
|                     <x-honeypot /> |                     <x-honeypot/> | ||||||
|                     <table class="gb-entry-form"> |                     <table class="gb-entry-form"> | ||||||
|                         <tr> |                         <tr> | ||||||
|                             <td> |                             <td> | ||||||
|  | @ -44,7 +55,7 @@ | ||||||
|                 <p>A few things to note:</p> |                 <p>A few things to note:</p> | ||||||
|                 <ul> |                 <ul> | ||||||
|                     <li>You can submit an entry <u>once every hour</u>.</li> |                     <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> |                     <li>Any entries that appear to be spam <u>will</u> be removed.</li> | ||||||
|                 </ul> |                 </ul> | ||||||
|             </td> |             </td> | ||||||
|  | @ -74,4 +85,5 @@ | ||||||
|         </table> |         </table> | ||||||
|         <br> |         <br> | ||||||
|     @endforeach |     @endforeach | ||||||
|  |     @endif | ||||||
| @stop | @stop | ||||||
|  |  | ||||||
|  | @ -7,6 +7,19 @@ | ||||||
|         $cfg = app('config')->get('services')['lastfm']; |         $cfg = app('config')->get('services')['lastfm']; | ||||||
|         $api_root = app('config')->get('app')['api_root']; |         $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')); |         $current_track = json_decode(file_get_contents($api_root . '/lastfm/current')); | ||||||
|         $top_tracks = json_decode(file_get_contents($api_root . '/lastfm/top')); |         $top_tracks = json_decode(file_get_contents($api_root . '/lastfm/top')); | ||||||
|         $count = 0; |         $count = 0; | ||||||
|  | @ -51,4 +64,5 @@ | ||||||
|             </tr> |             </tr> | ||||||
|         @endforeach |         @endforeach | ||||||
|     </table> |     </table> | ||||||
|  |     @endif | ||||||
| @stop | @stop | ||||||
|  |  | ||||||
|  | @ -13,10 +13,22 @@ function degreesToCompassDirection($degrees) { | ||||||
|     return $cardinalDirections[round($degrees*16/360)]; |     return $cardinalDirections[round($degrees*16/360)]; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| $data = json_decode(file_get_contents($api_root.'/weather')); | $api_alive = true; | ||||||
| $updated = gmdate('H:i Y-m-d', $data->updated); | 
 | ||||||
| $data = $data->current; | try { | ||||||
|  |     $data = file_get_contents($api_root.'/weather'); | ||||||
|  | } catch (Exception $e) { | ||||||
|  |     $api_alive = false; | ||||||
|  | } | ||||||
| @endphp | @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"> | <table class="info-table"> | ||||||
|     <caption> |     <caption> | ||||||
|         <h1>Local Weather</h1> |         <h1>Local Weather</h1> | ||||||
|  | @ -45,4 +57,5 @@ function degreesToCompassDirection($degrees) { | ||||||
| </table> | </table> | ||||||
| <br> | <br> | ||||||
| <small><i>(Last Update: {{ $updated }})</i></small> | <small><i>(Last Update: {{ $updated }})</i></small> | ||||||
|  | @endif | ||||||
| @stop | @stop | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Frankie B
				Frankie B