From 1ac836f88a60cbae129e3a6427cbe5310f239a12 Mon Sep 17 00:00:00 2001 From: thomasg Date: Wed, 14 May 2025 19:46:13 -0400 Subject: pushing to move to server --- README.md | 5 +- app/Models/User.php | 4 + database/migrations/2024_12_21_021128_files.php | 4 +- docs/thoughts.md | 11 ++ resources/js/writing_index.js | 24 ++++- resources/views/f_cursor_0221.blade.php | 136 ++++++++++++++++++++++++ resources/views/f_v1.blade.php | 79 ++++++++++++++ resources/views/home.blade.php | 8 +- resources/views/template.blade.php | 2 + resources/views/writings/index.blade.php | 5 +- vite.config.js | 3 +- 11 files changed, 272 insertions(+), 9 deletions(-) create mode 100644 docs/thoughts.md create mode 100644 resources/views/f_cursor_0221.blade.php create mode 100644 resources/views/f_v1.blade.php diff --git a/README.md b/README.md index 2538804..08d091c 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,9 @@ https://laravel.com/docs/11.x/blade - quickbuttons, for adding in snippets of things like embedding an image - update markup on a timer instead of every character (and/or see if i can prevent it from making unnecessary network requests like loading embedded files) +- tests + - test the return code and body of every route to make sure no error introduced + - general - import any model via json - links @@ -22,4 +25,4 @@ https://laravel.com/docs/11.x/blade - homepage image - user dashboard system - \ No newline at end of file + diff --git a/app/Models/User.php b/app/Models/User.php index 3c5e429..33861eb 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -75,4 +75,8 @@ class User extends Authenticatable public function getStorageUsed(){ } + + public function files(){ + return $this->hasMany(File::class); + } } diff --git a/database/migrations/2024_12_21_021128_files.php b/database/migrations/2024_12_21_021128_files.php index f76ab53..0c485f0 100644 --- a/database/migrations/2024_12_21_021128_files.php +++ b/database/migrations/2024_12_21_021128_files.php @@ -18,7 +18,9 @@ return new class extends Migration $table->string('path')->unique(); $table->string('source'); $table->string('description'); - $table->string('md5')->required(); + $table->integer('user_id')->unsigned()->index(); + $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); + $table->string('md5')->required(); }); } diff --git a/docs/thoughts.md b/docs/thoughts.md new file mode 100644 index 0000000..8aa159a --- /dev/null +++ b/docs/thoughts.md @@ -0,0 +1,11 @@ +allow to write without having accound + + +firstly, i'm not going to worry about models.txt at this point. i can just write migrations directly. no need to generalize into the lapigen stuff yet. + +when to use softdeletes? + + +non-database mode. site is aware that it currently doesn't have access to a database, and has alternate behavior that still provides utility. + + diff --git a/resources/js/writing_index.js b/resources/js/writing_index.js index b8a2ed1..d46bf77 100644 --- a/resources/js/writing_index.js +++ b/resources/js/writing_index.js @@ -37,7 +37,8 @@ $(function() { function initDOM(){ dom.filterMethod = $('#filter_method')[0]; dom.sortMethod = $('#sort_method')[0]; - + dom.sortMethod.onchange = sortContentList; + dom.filterMethod.onchange = filterContentList; } function performReplace(){ @@ -56,4 +57,23 @@ function performReplace(){ dom.inputText.value = dom.inputText.value.replace(regex, dom.replaceStr.value); dom.contentPreview.innerHTML = marked.parse(dom.inputText.value); -}; \ No newline at end of file +}; + +function sortContentList(){ + const sortMethod = dom.sortMethod.value; + console.log(sortMethod); + switch (sorthMethod){ + case 'date': + break; + case 'title': + break; + case 'author': + break; + case 'category': + break; + default: + break; + } +} + +function filterContentList(){} \ No newline at end of file diff --git a/resources/views/f_cursor_0221.blade.php b/resources/views/f_cursor_0221.blade.php new file mode 100644 index 0000000..fe9c9f0 --- /dev/null +++ b/resources/views/f_cursor_0221.blade.php @@ -0,0 +1,136 @@ +@extends('template') + + @foreach ($contents as $item) + @if ($item !== "." && $item !== "..") + @php + $filePath = $currentDir . '/' . $item; + $fileInfo = [ + 'name' => htmlspecialchars($item), + 'size' => is_file($filePath) ? filesize($filePath) : 0, + 'date' => is_file($filePath) ? date("F d Y H:i:s.", filemtime($filePath)) : '', + 'is_dir' => is_dir($filePath) + ]; + $files[] = $fileInfo; // Add file info to the array + @endphp +
  • + @if ($fileInfo['is_dir']) + Directory: {{ $fileInfo['name'] }} + @else + {{ $fileInfo['name'] }} + (Size: {{ $fileInfo['size'] }} bytes, Date: {{ $fileInfo['date'] }}) + @endif +
  • + @endif + @endforeach + + // Add sorting functionality + @if (isset($_GET['sort'])) + @php + $sort = $_GET['sort']; + usort($files, function($a, $b) use ($sort) { + if ($sort === 'size') { + return $a['size'] <=> $b['size']; + } elseif ($sort === 'date') { + return $a['date'] <=> $b['date']; + } else { // Default to sorting by name + return strcmp($a['name'], $b['name']); + } + }); + @endphp + @endif + + + +@section('body') +
    + +

    {{ htmlspecialchars(ucfirst($currentDirName)) }}

    + +
    +@endsection \ No newline at end of file diff --git a/resources/views/f_v1.blade.php b/resources/views/f_v1.blade.php new file mode 100644 index 0000000..cff2a4f --- /dev/null +++ b/resources/views/f_v1.blade.php @@ -0,0 +1,79 @@ +@extends('template') + +@section('body') +
    + +

    {{ htmlspecialchars(ucfirst($currentDirName)) }}

    +
    +@endsection \ No newline at end of file diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 7598045..dcfe2de 100755 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -6,11 +6,13 @@

    A friendly webserver

    -

    in Iowa

    +

    Welcome

    -