aboutsummaryrefslogtreecommitdiff
path: root/resources
diff options
context:
space:
mode:
authorFrankie B <git@diskfloppy.me>2023-07-16 21:02:51 +0100
committerGitHub <noreply@github.com>2023-07-16 21:02:51 +0100
commit7c16dc53b55aa50d6c9ac0bdea2f51fbbf2b20b0 (patch)
treed81c7682b4696d4182ab375d64fa69c4ff755647 /resources
parent691d0d933d9c2d9289fa01c7153371e45998ac53 (diff)
feat: site admin (#8)
Diffstat (limited to 'resources')
-rw-r--r--resources/views/errors/generic-error.blade.php9
-rw-r--r--resources/views/errors/no-auth.blade.php8
-rw-r--r--resources/views/includes/admin/header.blade.php12
-rw-r--r--resources/views/includes/header.blade.php8
-rw-r--r--resources/views/layouts/default-admin.blade.php23
-rw-r--r--resources/views/pages/admin/guestbook-del-confirm.blade.php33
-rw-r--r--resources/views/pages/admin/guestbook.blade.php27
-rw-r--r--resources/views/pages/admin/index.blade.php9
8 files changed, 128 insertions, 1 deletions
diff --git a/resources/views/errors/generic-error.blade.php b/resources/views/errors/generic-error.blade.php
new file mode 100644
index 0000000..9764a02
--- /dev/null
+++ b/resources/views/errors/generic-error.blade.php
@@ -0,0 +1,9 @@
+@extends('layouts.minimal')
+@section('title', 'Error 401: Unauthorized User!')
+@section('content')
+ <h1>{{ $error }}</h1>
+ <hr/>
+ @if(isset($description))
+ <p>{{ $description }}</p>
+ @endif
+@stop
diff --git a/resources/views/errors/no-auth.blade.php b/resources/views/errors/no-auth.blade.php
new file mode 100644
index 0000000..8682010
--- /dev/null
+++ b/resources/views/errors/no-auth.blade.php
@@ -0,0 +1,8 @@
+@extends('layouts.minimal')
+@section('title', 'Error 401: Unauthorized User!')
+@section('content')
+ <h1>Error 401: Unauthorized User!</h1>
+ <hr/>
+ <p>Woah there! Only authorized users can access this page. Please <a href="/login">log in</a> to proceed.</p>
+ <p>Ended up here on accident? Click <a href="/">here</a> to return to the homepage</u>!</p>
+@stop
diff --git a/resources/views/includes/admin/header.blade.php b/resources/views/includes/admin/header.blade.php
new file mode 100644
index 0000000..edb2fd7
--- /dev/null
+++ b/resources/views/includes/admin/header.blade.php
@@ -0,0 +1,12 @@
+ <nav>
+ <div>
+ <a href="/">public home</a> |
+ <a href="/admin">admin home</a> |
+ <a href="/admin/guestbook">guestbook</a>
+ @if (auth()->check())
+ | ({{ auth()->user()->name }}) <a href="/logout">logout</a>
+ @else
+ | <a href="/login">login</a>
+ @endif
+ </div>
+ </nav>
diff --git a/resources/views/includes/header.blade.php b/resources/views/includes/header.blade.php
index 53d44e2..01de256 100644
--- a/resources/views/includes/header.blade.php
+++ b/resources/views/includes/header.blade.php
@@ -1,12 +1,18 @@
<nav>
<div>
<a href="/">home</a> |
- <a href="//git.diskfloppy.me/">cgit</a> |
+ <a href="//git.diskfloppy.me/">cgit</a> |
<a href="//wiki.diskfloppy.me/">wiki</a> |
<a href="/projects/">projects</a> |
<a href="/calculators/">calculators</a> |
<a href="/computers/">computers</a> |
<a href="/bookmarks/">bookmarks</a> |
<a href="/guestbook/">guestbook</a>
+ @if (auth()->check())
+ | <a href="/admin/">admin</a>
+ | ({{ auth()->user()->name }}) <a href="/logout">logout</a>
+ @else
+ | <a href="/login">login</a>
+ @endif
</div>
</nav>
diff --git a/resources/views/layouts/default-admin.blade.php b/resources/views/layouts/default-admin.blade.php
new file mode 100644
index 0000000..5a16524
--- /dev/null
+++ b/resources/views/layouts/default-admin.blade.php
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ @include('includes.head')
+</head>
+
+<body>
+<div class="page">
+<div class="header">
+ @include('includes.admin.header')
+</div> <!-- header -->
+
+<div id="pagebody">
+ <div id="content">
+@yield('content')
+ </div> <!-- content -->
+ <div id="footer" class="pagefooter">
+ @include('includes.footer')
+ </div> <!-- footer -->
+</div> <!-- pagebody -->
+</div> <!-- page -->
+</body>
+</html>
diff --git a/resources/views/pages/admin/guestbook-del-confirm.blade.php b/resources/views/pages/admin/guestbook-del-confirm.blade.php
new file mode 100644
index 0000000..99d2a4c
--- /dev/null
+++ b/resources/views/pages/admin/guestbook-del-confirm.blade.php
@@ -0,0 +1,33 @@
+@extends('layouts.minimal')
+@section('title', 'Delete confirm')
+@section('content')
+ <h1>Delete Confirmation</h1>
+ <hr/>
+ <p>Are you sure you want to delete this entry?</p>
+
+ <h3>Entry Details:</h3>
+ <table class="gb_entry_details">
+ <tr>
+ <td><b>ID:</b></td>
+ <td>{{ $entry->id }}</td>
+ </tr>
+ <tr>
+ <td><b>Name:</b></td>
+ <td>{{ $entry->name }}</td>
+ </tr>
+ <tr>
+ <td><b>Date:</b></td>
+ <td>{{ gmdate("H:i:s - Y-m-d", $entry->timestamp) }}</td>
+ </tr>
+ <tr>
+ <td><b>Message:</b></td>
+ <td>{{ $entry->message }}</td>
+ </tr>
+ </table>
+
+ <form action="/admin/guestbook/delete" method="POST">
+ @csrf
+ <input type="hidden" name="id" value="{{ $entry->id }}">
+ <button type="submit">Confirm Delete</button>
+ </form>
+@stop
diff --git a/resources/views/pages/admin/guestbook.blade.php b/resources/views/pages/admin/guestbook.blade.php
new file mode 100644
index 0000000..56323ef
--- /dev/null
+++ b/resources/views/pages/admin/guestbook.blade.php
@@ -0,0 +1,27 @@
+@extends('layouts.default-admin')
+@section('title', 'guestbook')
+@section('content')
+ @php
+ $entries = DB::select('SELECT id, name, timestamp, message FROM guestbook_entries ORDER BY id DESC');
+ @endphp
+ <h1>Entries <small>({{ count($entries) }} total)</small></h1>
+ @foreach ($entries as $entry)
+ <table class="gb_admin">
+ <tr>
+ <td>
+ Name:&nbsp;{{ $entry->name }}<br/>
+ Date:&nbsp;{{ gmdate("H:i:s - Y-m-d", $entry->timestamp) }}
+ </td>
+ <td class="gb_del">
+ <a href="/admin/guestbook/delete?id={{ $entry->id }}">del</a>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2" class="gb_message">
+ <br/>
+ {{ htmlspecialchars($entry->message) }}
+ </td>
+ </tr></table>
+ @endforeach
+@stop
+
diff --git a/resources/views/pages/admin/index.blade.php b/resources/views/pages/admin/index.blade.php
new file mode 100644
index 0000000..fd34313
--- /dev/null
+++ b/resources/views/pages/admin/index.blade.php
@@ -0,0 +1,9 @@
+@extends('layouts.default-admin')
+@section('title', 'Page Title')
+@section('description', 'Page description goes here')
+@php
+ $user = auth()->user();
+@endphp
+@section('content')
+ <p>You are logged in as {{ $user->name }} ({{ $user->email }})</p>
+@stop