diff options
author | floppydiskette <git@diskfloppy.me> | 2024-08-08 22:22:38 +0100 |
---|---|---|
committer | floppydiskette <git@diskfloppy.me> | 2024-08-08 22:22:38 +0100 |
commit | 04fc009874db2d539ad881b649f7ebb512f05312 (patch) | |
tree | 9934681b96c15ceffbc9ce8d682621ff875f1b4f /app/Http/Controllers | |
parent | fc5cd70e729f639aaf1c6ff6a4bf3d5d52664de9 (diff) |
Init rails apprails
Diffstat (limited to 'app/Http/Controllers')
-rw-r--r-- | app/Http/Controllers/BookmarksController.php | 15 | ||||
-rw-r--r-- | app/Http/Controllers/CalculatorsController.php | 13 | ||||
-rw-r--r-- | app/Http/Controllers/ComputersController.php | 13 | ||||
-rw-r--r-- | app/Http/Controllers/Controller.php | 12 | ||||
-rw-r--r-- | app/Http/Controllers/GuestbookController.php | 47 | ||||
-rw-r--r-- | app/Http/Controllers/HomeController.php | 33 | ||||
-rw-r--r-- | app/Http/Controllers/MusicController.php | 69 |
7 files changed, 0 insertions, 202 deletions
diff --git a/app/Http/Controllers/BookmarksController.php b/app/Http/Controllers/BookmarksController.php deleted file mode 100644 index 56aacc7..0000000 --- a/app/Http/Controllers/BookmarksController.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\BookmarkSite; -use App\Models\BookmarkCategory; -use Illuminate\View\View; - -class BookmarksController extends Controller -{ - public function show() : View { - $categories = BookmarkCategory::with('sites')->get(); - return view('bookmarks', compact('categories')); - } -} diff --git a/app/Http/Controllers/CalculatorsController.php b/app/Http/Controllers/CalculatorsController.php deleted file mode 100644 index 38a7a41..0000000 --- a/app/Http/Controllers/CalculatorsController.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use Illuminate\Http\Request; -use Illuminate\View\View; - -class CalculatorsController extends Controller -{ - public function show() : View { - return view('calculators'); - } -} diff --git a/app/Http/Controllers/ComputersController.php b/app/Http/Controllers/ComputersController.php deleted file mode 100644 index e16e70d..0000000 --- a/app/Http/Controllers/ComputersController.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use Illuminate\Http\Request; -use Illuminate\View\View; - -class ComputersController extends Controller -{ - public function show() : View { - return view('computers'); - } -} diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php deleted file mode 100644 index 77ec359..0000000 --- a/app/Http/Controllers/Controller.php +++ /dev/null @@ -1,12 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use Illuminate\Foundation\Auth\Access\AuthorizesRequests; -use Illuminate\Foundation\Validation\ValidatesRequests; -use Illuminate\Routing\Controller as BaseController; - -class Controller extends BaseController -{ - use AuthorizesRequests, ValidatesRequests; -} diff --git a/app/Http/Controllers/GuestbookController.php b/app/Http/Controllers/GuestbookController.php deleted file mode 100644 index df726ef..0000000 --- a/app/Http/Controllers/GuestbookController.php +++ /dev/null @@ -1,47 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use App\Models\GuestbookEntry; -use Illuminate\Http\Request; -use Illuminate\Http\RedirectResponse; -use Illuminate\Contracts\View\View; -use Illuminate\Validation\ValidationException; -use UAParser\Parser; - -class GuestbookController extends Controller { - public function show(): View { - $entries = GuestbookEntry::selectEntries(); - $parser = Parser::create(); - - return view('guestbook') - ->with('entries', $entries) - ->with('parser', $parser); - } - - /** - * Creates a new guestbook entry - * - * @param Request $request - * @return RedirectResponse - * @throws ValidationException - */ - public function addEntry(Request $request): RedirectResponse { - $this->validate($request, [ - 'name' => 'required', - 'message' => 'required' - ]); - - - GuestbookEntry::insertGuestbookEntry($request); - return back()->with('success', 'Entry submitted successfully!'); - } - - public function banIP(string $addr) { - // TODO: Add banning system - // $matching_bans = DB::select('SELECT reason FROM guestbook__bans WHERE ip_address = ?', array($request->ip())); - // if (!empty($matching_bans)) { - // return view('errors.guestbook-ipban')->with('reason', $matching_bans[0]->reason); - // } - } -} diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php deleted file mode 100644 index e046d58..0000000 --- a/app/Http/Controllers/HomeController.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Config; -use Illuminate\Support\Facades\Http; -use Illuminate\View\View; -use DateTime; - -class HomeController extends Controller { - /** - * Returns age based on birthday date and current date (GMT) - * @return int - */ - function returnAge(): int { - date_default_timezone_set('Europe/London'); - $birthday = new DateTime("2005-06-07"); - $currentDate = DateTime::createFromFormat("Y-m-d", date("Y-m-d")); - $age = $birthday->diff($currentDate); - return $age->y; - } - - /** - * Shows home page - * @return View - */ - public function show(): View { - return view('home', [ - 'age' => $this->returnAge(), - ]); - } -} diff --git a/app/Http/Controllers/MusicController.php b/app/Http/Controllers/MusicController.php deleted file mode 100644 index 5e31d86..0000000 --- a/app/Http/Controllers/MusicController.php +++ /dev/null @@ -1,69 +0,0 @@ -<?php - -namespace App\Http\Controllers; - -use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Config; -use Illuminate\Support\Facades\Http; -use Illuminate\View\View; - -class MusicController extends Controller -{ - public function getCurrentTrack() { - // If it's already cached just return that - if (Cache::has('current_track')) { - return Cache::get('current_track'); - } - - $response = Http::withQueryParameters([ - 'method' => 'user.getrecenttracks', - 'user' => Config::get('services.lastfm.user'), - 'format' => 'json', - 'nowplaying' => 'true', - 'api_key' => Config::get('services.lastfm.key') - ])->get('https://ws.audioscrobbler.com/2.0/'); - $data = $response->json(); - error_log($response->body()); - $track_data = $data["recenttracks"]["track"][0]; - $current_track = [ - 'title' => $track_data["name"], - 'artist' => $track_data["artist"]["#text"], - 'url' => $track_data["url"], - ]; - Cache::put('current_track', $current_track, now()->addSeconds(15)); - return $current_track; - } - - public function getTopTracks() { - // If it's already cached just return that - if (Cache::has('top_tracks')) { - return Cache::get('top_tracks'); - } - - $response = Http::withQueryParameters([ - 'method' => 'user.gettoptracks', - 'user' => Config::get('services.lastfm.user'), - 'format' => 'json', - 'period' => '1month', - 'limit' => 10, - 'api_key' => Config::get('services.lastfm.key') - ])->get('https://ws.audioscrobbler.com/2.0/'); - $data = $response->json(); - $topTracks = []; - foreach ($data["toptracks"]["track"] as $track) { - $topTracks[] = [ - 'title' => $track["name"], - 'artist' => $track["artist"]["name"], - 'url' => $track["url"], - 'plays' => $track["playcount"], - ]; - } - Cache::put('top_tracks', $topTracks, now()->addSeconds(15)); - return $topTracks; - } - public function show() : View { - return view('music') - ->with('current_track', $this->getCurrentTrack()) - ->with('top_tracks', $this->getTopTracks()); - } -} |