From 8e627b16712e90134919c7366dffa4993a13165a Mon Sep 17 00:00:00 2001 From: Frankie B Date: Tue, 13 Jun 2023 23:07:20 +0100 Subject: Add global layout and homepage --- resources/css/app.css | 0 resources/views/components/lastfm.blade.php | 67 +++++++++++ resources/views/components/weatherdata.blade.php | 68 +++++++++++ resources/views/includes/footer.blade.php | 8 ++ resources/views/includes/head.blade.php | 13 +++ resources/views/includes/header.blade.php | 11 ++ resources/views/layouts/default.blade.php | 27 +++++ resources/views/pages/home.blade.php | 25 ++++ resources/views/welcome.blade.php | 140 ----------------------- 9 files changed, 219 insertions(+), 140 deletions(-) delete mode 100644 resources/css/app.css create mode 100644 resources/views/components/lastfm.blade.php create mode 100644 resources/views/components/weatherdata.blade.php create mode 100644 resources/views/includes/footer.blade.php create mode 100644 resources/views/includes/head.blade.php create mode 100644 resources/views/includes/header.blade.php create mode 100644 resources/views/layouts/default.blade.php create mode 100644 resources/views/pages/home.blade.php delete mode 100644 resources/views/welcome.blade.php (limited to 'resources') diff --git a/resources/css/app.css b/resources/css/app.css deleted file mode 100644 index e69de29..0000000 diff --git a/resources/views/components/lastfm.blade.php b/resources/views/components/lastfm.blade.php new file mode 100644 index 0000000..78c5f81 --- /dev/null +++ b/resources/views/components/lastfm.blade.php @@ -0,0 +1,67 @@ +get('services')['lastfm']; + +$curl_current = curl_init(); + +curl_setopt_array($curl_current, [ + CURLOPT_URL => "https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=".$cfg['user']."&nowplaying=true&format=json&api_key=".$cfg['key'], + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +]); + +$current_response = curl_exec($curl_current); +$err = curl_error($curl_current); + +curl_close($curl_current); + +if ($err) { + die("cURL Error #:" . $err); +} +$current_response = json_decode($current_response, true); +$nowplaying = $current_response['recenttracks']['track'][0]; + + +$tracks_to_show = 10; + +$curl = curl_init(); +curl_setopt_array($curl, [ + CURLOPT_URL => "https://ws.audioscrobbler.com/2.0/?method=user.gettoptracks&user=".$cfg['user']."&format=json&period=7day&api_key=".$cfg['key'], + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +]); + +$toptracks = curl_exec($curl); +$err = curl_error($curl); +curl_close($curl); +if ($err) { + die("cURL Error #:" . $err); +} + +$toptracks = json_decode($toptracks, true); +$tracks = $toptracks['toptracks']['track']; +$count = 0; +?> + +

Last.fm (Profile)

+ Last/Current Track: {{ $nowplaying['name'] }} • {{ $nowplaying['artist']['#text'] }} +

Top {{ $tracks_to_show }} Tracks (Last 7 days)

+
    +@foreach ($tracks as $track) + @if ($count >= $tracks_to_show) +
+ @break + @endif +
  • + {{ $track['name'] }} • {{ $track['artist']['name'] }} + ({{$track['playcount']}} plays) +
  • + +@endforeach diff --git a/resources/views/components/weatherdata.blade.php b/resources/views/components/weatherdata.blade.php new file mode 100644 index 0000000..28e163d --- /dev/null +++ b/resources/views/components/weatherdata.blade.php @@ -0,0 +1,68 @@ + "http://weather.diskfloppy.me/data/weatherData.json", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 300, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +]); + +$current_response = curl_exec($curl_current); +$err = curl_error($curl_current); + +curl_close($curl_current); + +$curl_current = curl_init(); + +curl_setopt_array($curl_current, [ + CURLOPT_URL => "http://weather.diskfloppy.me/data/got.txt", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 300, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +]); + +$last_update = curl_exec($curl_current); +$err = curl_error($curl_current); + +curl_close($curl_current); + +if ($err) { + die("cURL Error: " . $err); +} +$current_response = json_decode($current_response, true); +$weather_data = $current_response['data']['conditions'][0]; +$windDirDeg = $weather_data['wind_dir_last']; +$windDir = ""; +// W I N D +if (349 <= $windDirDeg || $windDirDeg <= 11) { $windDir = "N"; } +else if (12 <= $windDirDeg && $windDirDeg <= 33) { $windDir = "NNE"; } +else if (34 <= $windDirDeg && $windDirDeg <= 56) { $windDir = "NE"; } +else if (57 <= $windDirDeg && $windDirDeg <= 78) { $windDir = "ENE"; } +else if (79 <= $windDirDeg && $windDirDeg <= 101) { $windDir = "E"; } +else if (102 <= $windDirDeg && $windDirDeg <= 123) { $windDir = "ESE"; } +else if (124 <= $windDirDeg && $windDirDeg <= 146) { $windDir = "SE"; } +else if (147 <= $windDirDeg && $windDirDeg <= 168) { $windDir = "SSE"; } +else if (169 <= $windDirDeg && $windDirDeg <= 191) { $windDir = "S"; } +else if (192 <= $windDirDeg && $windDirDeg <= 213) { $windDir = "SSW"; } +else if (214 <= $windDirDeg && $windDirDeg <= 236) { $windDir = "SW"; } +else if (237 <= $windDirDeg && $windDirDeg <= 258) { $windDir = "WSW"; } +else if (259 <= $windDirDeg && $windDirDeg <= 281) { $windDir = "W"; } +else if (282 <= $windDirDeg && $windDirDeg <= 303) { $windDir = "WNE"; } +else if (304 <= $windDirDeg && $windDirDeg <= 326) { $windDir = "NW"; } +else if (327 <= $windDirDeg && $windDirDeg <= 348) { $windDir = "WNW"; } + +?> +

    Local Weather (Last Update: {{ gmdate('H:i Y-m-d', intval(rtrim($last_update))) }})

    + Wind Speed: {{ $weather_data['wind_speed_last'] }} mph
    + Wind Direction: {{ $weather_data['wind_dir_last']}}°, {{ $windDir }}
    + Temperature: {{ round(($weather_data['temp']-32)*(5/9), 1) }}°C
    + Rain Rate: {{ round($weather_data['rain_rate_last']*0.2, 2) }} mm/hr
    + Humidity: {{ round($weather_data['hum']) }}%
    diff --git a/resources/views/includes/footer.blade.php b/resources/views/includes/footer.blade.php new file mode 100644 index 0000000..09dcf38 --- /dev/null +++ b/resources/views/includes/footer.blade.php @@ -0,0 +1,8 @@ +
    +
    + Any Damn Browser  + Linux NOW!  + vim  + Valid CSS!  + Valid HTML 4.01!
    +
    diff --git a/resources/views/includes/head.blade.php b/resources/views/includes/head.blade.php new file mode 100644 index 0000000..ed4f29e --- /dev/null +++ b/resources/views/includes/head.blade.php @@ -0,0 +1,13 @@ + + + + + + + + + ~floppydisk / @yield('title') + + + + diff --git a/resources/views/includes/header.blade.php b/resources/views/includes/header.blade.php new file mode 100644 index 0000000..37dccbe --- /dev/null +++ b/resources/views/includes/header.blade.php @@ -0,0 +1,11 @@ + diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php new file mode 100644 index 0000000..77c3f76 --- /dev/null +++ b/resources/views/layouts/default.blade.php @@ -0,0 +1,27 @@ + + + + + + + + @include('includes.head') + + + +
    +
    + @include('includes.header') +
    + +
    +
    + @yield('content') +
    + +
    +
    + + diff --git a/resources/views/pages/home.blade.php b/resources/views/pages/home.blade.php new file mode 100644 index 0000000..f21528f --- /dev/null +++ b/resources/views/pages/home.blade.php @@ -0,0 +1,25 @@ +@extends('layouts.default') +@section('title', 'test') +@section('description', 'This is the personal homepage of floppydisk.') +@section('content') +

    Hi!

    +

    This is the personal homepage of floppydisk.

    + + + @include('components.lastfm') + + + @include('components.weatherdata') + +

    Contact

    +

    Mail: contact@diskfloppy.me
    + IRC: floppydisk @ r-type
    +

    + +

    Elsewhere

    +

    Mastodon: @floppydisk_@mastodon.sdf.org
    + Twitter: @floppydisk__
    + GitHub: floppydisk05
    + SDF: ~floppydisk +

    +@stop diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php deleted file mode 100644 index 638ec96..0000000 --- a/resources/views/welcome.blade.php +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - - Laravel - - - - - - - - - -
    - @if (Route::has('login')) -
    - @auth - Home - @else - Log in - - @if (Route::has('register')) - Register - @endif - @endauth -
    - @endif - - -
    - - -- cgit v1.2.3-54-g00ecf