aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrankie B <git@diskfloppy.me>2024-07-11 22:23:46 +0100
committerFrankie B <git@diskfloppy.me>2024-07-11 22:23:46 +0100
commit069cf70f5be260e6fcf44d80a9befca01e4c5ed6 (patch)
treeecb1efc8146ed3799bd42a093288f3102dc11a47
parentccec714beed04d1585444c9321781b39db27f53d (diff)
Remove admin pages
-rw-r--r--app/Http/Controllers/AdminBookmarksController.php15
-rw-r--r--app/Http/Controllers/AdminGuestbookController.php34
-rw-r--r--app/Http/Controllers/AdminImportController.php69
-rw-r--r--resources/views/admin/bookmarks.blade.php28
-rw-r--r--resources/views/admin/guestbook.blade.php32
-rw-r--r--resources/views/admin/import-success.blade.php12
-rw-r--r--resources/views/admin/import.blade.php18
7 files changed, 0 insertions, 208 deletions
diff --git a/app/Http/Controllers/AdminBookmarksController.php b/app/Http/Controllers/AdminBookmarksController.php
deleted file mode 100644
index c7d8afd..0000000
--- a/app/Http/Controllers/AdminBookmarksController.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\Models\BookmarkCategory;
-use Illuminate\Support\Facades\DB;
-use Illuminate\View\View;
-
-class AdminBookmarksController extends Controller
-{
- public function show() : View {
- $categories = BookmarkCategory::with('sites')->get();
- return view('admin.bookmarks', compact('categories'));
- }
-}
diff --git a/app/Http/Controllers/AdminGuestbookController.php b/app/Http/Controllers/AdminGuestbookController.php
deleted file mode 100644
index 5ebf451..0000000
--- a/app/Http/Controllers/AdminGuestbookController.php
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\Models\GuestbookEntry;
-use Illuminate\Support\Facades\DB;
-use Illuminate\View\View;
-use UAParser\Parser;
-
-class AdminGuestbookController extends Controller
-{
- function getGuestbookUniqueAddr(): int {
- $uniqueIpsCount = DB::table('guestbook__entries')->distinct()->count('ip');
- return $uniqueIpsCount;
- }
-
- function getGuestbookEntriesCount(): int {
- $entryCount = DB::table('guestbook__entries')->count();
- return $entryCount;
- }
- public function show() : View {
- $guestbook_unique_addr = $this->getGuestbookUniqueAddr();
- $guestbook_entry_count = $this->getGuestbookEntriesCount();
- $entries = GuestbookEntry::selectEntries();
- $parser = Parser::create();
-
- return view('admin.guestbook', [
- 'guestbook_unique_addr' => $guestbook_unique_addr,
- 'guestbook_entry_count' => $guestbook_entry_count,
- 'entries' => $entries,
- 'parser' => $parser,
- ]);
- }
-}
diff --git a/app/Http/Controllers/AdminImportController.php b/app/Http/Controllers/AdminImportController.php
deleted file mode 100644
index dc32cec..0000000
--- a/app/Http/Controllers/AdminImportController.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-namespace App\Http\Controllers;
-
-use App\Models\BookmarkCategory;
-use App\Models\BookmarkSite;
-use App\Models\GuestbookEntry;
-use Exception;
-use Illuminate\Http\Request;
-use Illuminate\View\View;
-
-class AdminImportController extends Controller
-{
- public function show() : View {
- return view('admin.import');
- }
-
- public function submit(Request $request)
- {
- $request->validate([
- 'data_file' => 'required|mimes:json',
- ]);
-
- $file = $request->file('data_file');
- $jsonContent = file_get_contents($file->getRealPath());
- $data = json_decode($jsonContent, true);
- $tables = [];
- foreach($data as $item) {
- if ($item['type'] !== "table") continue;
- $tables[$item['name']] = [
- 'data' => $item['data'],
- 'count' => count($item['data'])
- ];
-
- if ($item['name'] === "guestbook__entries") {
- GuestbookEntry::importGuestbookEntry($item['data']);
- }
- $this->import($item['data'], $item['name']);
- }
- return view('admin.import-success', ['tables' => $tables]);
- }
-
- /**
- * Imports the given data to the specified table
- *
- * @param array $data The data to import
- * @param string $table_name The name of the table to import to
- * @return void
- * @throws Exception Invalid table specified, to be replaced with custom exception
- */
- public function import(array $data, string $table_name): void {
- switch ($table_name) {
- case 'guestbook__entries':
- GuestbookEntry::importGuestbookEntry($data);
- break;
- case 'bookmark__categories' :
- BookmarkCategory::importBookmarkCategory($data);
- break;
- case 'bookmark__sites':
- BookmarkSite::importBookmark($data);
- break;
- case 'guestbook__bans':
- break;
- default:
- // TODO: Replace with custom exception
- throw new Exception("Invalid table specified ($table_name)");
- }
- }
-}
diff --git a/resources/views/admin/bookmarks.blade.php b/resources/views/admin/bookmarks.blade.php
deleted file mode 100644
index f06539c..0000000
--- a/resources/views/admin/bookmarks.blade.php
+++ /dev/null
@@ -1,28 +0,0 @@
-<x-layout>
- <x-slot:title>Admin | Bookmarks</x-slot:title>
- @foreach($categories as $category)
- <div class="info-section info-admin-section">
- <h2>{{ $category->name }}</h2>
- <table class="info-admin">
- <tr>
- <th>ID</th>
- <th>Name</th>
- <th>Description</th>
- <th>URL</th>
- <th>Priority</th>
- <th class="blank"></th>
- </tr>
- @foreach($category->sites as $site)
- <tr>
- <td>{{ $site->id }}</td>
- <td>{{ $site->name }}</td>
- <td>{{ $site->description }}</td>
- <td>{{ $site->url }}</td>
- <td>{{ $site->priority }}</td>
- <td><a href="?action=delete&id={{ $site->id }}"><button>Delete</button></a></td>
- </tr>
- @endforeach
- </table>
- </div>
- @endforeach
-</x-layout>
diff --git a/resources/views/admin/guestbook.blade.php b/resources/views/admin/guestbook.blade.php
deleted file mode 100644
index 1f5dab3..0000000
--- a/resources/views/admin/guestbook.blade.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<x-layout>
- <x-slot:title>Admin | Guestbook</x-slot:title>
- <div class="info-section">
- <h2>Statistics</h2>
- <hr>
- <strong>Unique IP addresses:</strong> {{ $guestbook_unique_addr }}<br>
- <strong>Entries:</strong> {{ $guestbook_entry_count }}
- </div>
- <br>
- <div class="info-section">
- <h2>Entries</h2>
- <hr>
- <table class="info-admin fullwidth">
- <tr>
- <th>ID</th>
- <th>Name</th>
- <th>IP Address</th>
- <th>Message</th>
- <th class="blank"></th>
- </tr>
- @foreach ($entries as $entry)
- <tr>
- <td>{{ $entry->id }}</td>
- <td>{{ $entry->name }}</td>
- <td>{{ $entry->ip }}</td>
- <td>{{ $entry->message }}</td>
- <td><a href="?action=delete&id={{ $entry->id }}"><button>Delete</button></a></td>
- </tr>
- @endforeach
- </table>
- </div>
-</x-layout>
diff --git a/resources/views/admin/import-success.blade.php b/resources/views/admin/import-success.blade.php
deleted file mode 100644
index f6d5eb3..0000000
--- a/resources/views/admin/import-success.blade.php
+++ /dev/null
@@ -1,12 +0,0 @@
-<x-layout>
- <x-slot:title>Admin | Import</x-slot:title>
- <div class="info-section">
- <h2>Imported data</h2>
- <hr>
- <ul>
- @foreach($tables as $name => $data)
- <li><strong>{{ ucwords(str_replace('__', ' ', $name)) }}:</strong> {{ $data['count'] }} record(s)</li>
- @endforeach
- </ul>
- </div>
-</x-layout>
diff --git a/resources/views/admin/import.blade.php b/resources/views/admin/import.blade.php
deleted file mode 100644
index e663724..0000000
--- a/resources/views/admin/import.blade.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<x-layout>
- <x-slot:title>Admin | Import</x-slot:title>
- <form class="import" action="{{ route('admin.import.submit') }}" method="post" enctype="multipart/form-data">
- @csrf
- <label for="data_file"><strong>File:</strong></label>
- <input class="file" type="file" name="data_file" accept=".json"><br>
- <h2>What to import:</h2>
- <input type="checkbox" name="guestbook__entries" checked>
- <label for="guestbook__entries">Guestbook Entries</label><br>
- <input type="checkbox" name="guestbook__bans" checked>
- <label for="guestbook__bans">Guestbook Bans</label><br>
- <input type="checkbox" name="guestbook__entries" checked>
- <label for="bookmark__categories">Bookmark Categories</label><br>
- <input type="checkbox" name="guestbook__entries" checked>
- <label for="bookmark_sites">Bookmark Sites</label><br>
- <button type="submit">Import</button>
- </form>
-</x-layout>