From c00a2b102fdcd85828e14d879a1ed9dff55a6433 Mon Sep 17 00:00:00 2001 From: grothedev Date: Fri, 8 May 2026 12:19:06 -0500 Subject: a little todo list. fix url color --- app/Http/Controllers/SiteController.php | 48 +++++++++++++++++++++++++++++++++ resources/css/home.css | 4 +-- resources/views/do.blade.php | 48 +++++++++++++++++++++++++++++++++ resources/views/home.blade.php | 4 +-- resources/views/matrix.blade.php | 8 +++--- routes/web.php | 29 +++++++------------- 6 files changed, 114 insertions(+), 27 deletions(-) create mode 100755 resources/views/do.blade.php diff --git a/app/Http/Controllers/SiteController.php b/app/Http/Controllers/SiteController.php index 301e101..3ef641a 100644 --- a/app/Http/Controllers/SiteController.php +++ b/app/Http/Controllers/SiteController.php @@ -198,4 +198,52 @@ class SiteController extends Controller } } + public function updateTodo(Request $req){ + $file = storage_path('app/todo.json'); + $items = file_exists($file) ? json_decode(file_get_contents($file), true) ?? [] : []; + $op = $req->input('op', 'append'); + + if ($op === 'overwrite') { + $lines = array_filter(array_map('trim', explode("\n", $req->input('content', '')))); + $items = array_values($lines); + } elseif ($op === 'delete') { + $index = (int) $req->input('index'); + array_splice($items, $index, 1); + } else { + // append (default) + $lines = array_filter(array_map('trim', explode("\n", $req->input('content', '')))); + $items = array_merge($items, $lines); + } + + file_put_contents($file, json_encode(array_values($items), JSON_PRETTY_PRINT)); + return redirect('/do')->with('status', 'List updated.'); + } + + public function updateTodoWithToken(Request $req){ + $token = $req->input('token', $req->header('X-Token')); + if (!$token || $token !== env('TODO_TOKEN')) { + abort(403, 'Invalid token.'); + } + + $file = storage_path('app/todo.json'); + $items = file_exists($file) ? json_decode(file_get_contents($file), true) ?? [] : []; + $op = $req->input('op', 'append'); + + if ($op === 'overwrite') { + $lines = array_filter(array_map('trim', explode("\n", $req->input('content', '')))); + $items = array_values($lines); + } elseif ($op === 'delete') { + $index = (int) $req->input('index'); + array_splice($items, $index, 1); + } elseif ($op === 'list') { + return response()->json($items); + } else { + $lines = array_filter(array_map('trim', explode("\n", $req->input('content', '')))); + $items = array_merge($items, $lines); + } + + file_put_contents($file, json_encode(array_values($items), JSON_PRETTY_PRINT)); + return response()->json(['status' => 'ok', 'count' => count($items), 'items' => $items]); + } + } diff --git a/resources/css/home.css b/resources/css/home.css index 3223a44..9977bd6 100644 --- a/resources/css/home.css +++ b/resources/css/home.css @@ -38,12 +38,12 @@ p .light { color: #787878; } section h3 { - color: #3f6d87; + color: #454545; text-decoration: none; } a { font-weight: bold; - color: #548226; + color: #676767; text-decoration: none; padding-bottom: .1rem; border-bottom: 1px dashed gray; diff --git a/resources/views/do.blade.php b/resources/views/do.blade.php new file mode 100755 index 0000000..246c522 --- /dev/null +++ b/resources/views/do.blade.php @@ -0,0 +1,48 @@ +@extends('template') +@section('content') +
+
+
+

To Do

+
+
+ +
+ @if(Auth::check() && Auth::user()->isAdmin()) +
+ @csrf + +
+ + +
+
+ @endif + + @if(session('status')) +

{{ session('status') }}

+ @endif +
+ +
+

Current List

+ @if(count($items ?? []) === 0) +

Nothing here yet.

+ @else +
    + @foreach($items as $i => $item) +
  • +
    + @csrf + + + +
    + {{ $item }} +
  • + @endforeach +
+ @endif +
+
+@endsection \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index d6ac6ec..4bd4b74 100755 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -11,7 +11,6 @@

Welcome

. . .
-UNDER CONSTRUCTION; APOLOGIES FOR LACKING FUNCTIONALITY.

File upload capability temporarily disabled

@@ -32,6 +31,7 @@ UNDER CONSTRUCTION; APOLOGIES FOR LACKING FUNCTIONALITY.
40912129 ( goob )
+

Dune pre-chapter quotes:

diff --git a/resources/views/matrix.blade.php b/resources/views/matrix.blade.php index b5deb92..95b10c1 100755 --- a/resources/views/matrix.blade.php +++ b/resources/views/matrix.blade.php @@ -3,8 +3,8 @@
-

Matrix Communications System

-

An open network for secure, decentralised communication

+

Matrix Communications System

+

An open network for secure, decentralised communication

@@ -19,13 +19,13 @@

What is Matrix?

Matrix is an open standard and communication protocol for real-time messaging, voice, and video. - Think of it like email — but for instant messaging. Just like you can send an email from Gmail to + Think of it like email, but for instant messaging. Just like you can send an email from Gmail to a Yahoo address without either party needing to use the same service, Matrix lets you chat with anyone on any Matrix server, from your own account which exists on some server.

You don't need to trust a corporation with your conversations. There's no single company running - Matrix — it's a federated, decentralized network. Thousands of servers run + Matrix. It's a federated, decentralized network. Thousands of servers run independently and talk to each other. My server (belthelziquor.com) is one of them.

diff --git a/routes/web.php b/routes/web.php index d98ed5d..6c44689 100755 --- a/routes/web.php +++ b/routes/web.php @@ -144,30 +144,21 @@ Route::get('/newtab', function() { return view('newtab'); }); -//Route::post('/do', function(Request $req) { +Route::get('/do', function(){ + $data = []; $file = storage_path('app/todo.json'); - $items = file_exists($file) ? json_decode(file_get_contents($file), true) ?? [] : []; - $op = $req->input('op', 'append'); - - if ($op === 'overwrite') { - $lines = array_filter(array_map('trim', explode("\n", $req->input('content', '')))); - $items = array_values($lines); - } elseif ($op === 'delete') { - $index = (int) $req->input('index'); - array_splice($items, $index, 1); - } else { - // append (default) - $lines = array_filter(array_map('trim', explode("\n", $req->input('content', '')))); - $items = array_merge($items, $lines); - } + $data['items'] = file_exists($file) ? json_decode(file_get_contents($file), true) ?? [] : []; + return view('do', $data); +}); - file_put_contents($file, json_encode(array_values($items), JSON_PRETTY_PRINT)); - return redirect('/do')->with('status', 'List updated.'); -})->middleware('auth'); +Route::post('/do', [SiteController::class, 'updateTodo'])->middleware('auth'); + +// API-style todo endpoint — token auth, no CSRF needed +Route::post('/api/do', [SiteController::class, 'updateTodoWithToken'])->middleware('throttle:public'); // Catch-all: only allow specific whitelisted views Route::get('/{v}', function($v){ - $allowed = ['notes', 'kyanite', 'marked', 'v', '4', 'matrix', 'psql', 'do']; + $allowed = ['notes', 'kyanite', 'marked', 'v', '4', 'matrix', 'psql']; if (!in_array($v, $allowed)) { abort(404); } -- cgit v1.2.3