From 4e11fb7db04589548237d9ac51f44d0fdfd50791 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 22:19:03 -0600
Subject: [PATCH 1/8] chore: bump mariadb from 10.11 to 11.1
---
CHANGELOG.md | 4 ++++
docker-compose-prod.yml | 2 +-
docker-compose.yml | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1419bdf..c98f335 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+## Next Release
+
+- Updates MariaDB from 10.11 to 11.1
+
## v1.0.1 (2023-09-06)
- Fixes long-string line wrapping on the posts page when viewing on mobile
diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml
index 02f4f28..8fd7b40 100644
--- a/docker-compose-prod.yml
+++ b/docker-compose-prod.yml
@@ -34,7 +34,7 @@ services:
cpus: '0.25'
memory: '128M'
healthcheck:
- test: ['CMD', 'mysql', '-u${MARIADB_USER}', '-p${MARIADB_PASSWORD}', '-e', 'show databases;']
+ test: ['CMD', 'mariadb', '-u${MARIADB_USER}', '-p${MARIADB_PASSWORD}', '-e', 'show databases;']
interval: 10s
timeout: 10s
retries: 3
diff --git a/docker-compose.yml b/docker-compose.yml
index 879e4f1..e098539 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -12,7 +12,7 @@ services:
depends_on:
- glass-db
glass-db:
- image: 'mariadb:10.11.4'
+ image: 'mariadb:11.1.2'
restart: always
volumes:
- database-data:/var/lib/mysql
From f2ea5197cd942ee15524052a04ce14e1fc994672 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 22:19:15 -0600
Subject: [PATCH 2/8] fix: bootstrap deprecation warning
---
src/package-lock.json | 8 ++++----
src/package.json | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/package-lock.json b/src/package-lock.json
index 3b03662..809284e 100644
--- a/src/package-lock.json
+++ b/src/package-lock.json
@@ -7,7 +7,7 @@
"dependencies": {
"@sindresorhus/slugify": "^1.1",
"axios": "^1.3",
- "bootstrap": "^5.2",
+ "bootstrap": "^5.3.2",
"highlight.js": "^11.8",
"laravel-vite-plugin": "^0.7.4",
"pineapple-library": "^3.2",
@@ -680,9 +680,9 @@
}
},
"node_modules/bootstrap": {
- "version": "5.3.1",
- "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.1.tgz",
- "integrity": "sha512-jzwza3Yagduci2x0rr9MeFSORjcHpt0lRZukZPZQJT1Dth5qzV7XcgGqYzi39KGAVYR8QEDVoO0ubFKOxzMG+g==",
+ "version": "5.3.2",
+ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.2.tgz",
+ "integrity": "sha512-D32nmNWiQHo94BKHLmOrdjlL05q1c8oxbtBphQFb9Z5to6eGRDCm0QgeaZ4zFBHzfg2++rqa2JkqCcxDy0sH0g==",
"funding": [
{
"type": "github",
diff --git a/src/package.json b/src/package.json
index 22fcd17..cbf802c 100644
--- a/src/package.json
+++ b/src/package.json
@@ -9,7 +9,7 @@
"dependencies": {
"@sindresorhus/slugify": "^1.1",
"axios": "^1.3",
- "bootstrap": "^5.2",
+ "bootstrap": "^5.3.2",
"laravel-vite-plugin": "^0.7.4",
"highlight.js": "^11.8",
"pineapple-library": "^3.2",
From 045a3c4082327cdd4d70283b237485c6570ff739 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 22:24:46 -0600
Subject: [PATCH 3/8] feat: unique and indexed categories
---
CHANGELOG.md | 2 ++
.../Http/Controllers/CategoryController.php | 2 +-
.../2023_09_20_040645_add_indexes.php | 30 +++++++++++++++++++
src/resources/views/create-post.blade.php | 4 +--
4 files changed, 35 insertions(+), 3 deletions(-)
create mode 100644 src/database/migrations/2023_09_20_040645_add_indexes.php
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c98f335..beac0a1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Next Release
+- Categories are now unique, enforced at the database level, and are indexed for quick retrieval
+- Fixed a bug that didn't show the dropdown chevrons for form-select fields when creating a post
- Updates MariaDB from 10.11 to 11.1
## v1.0.1 (2023-09-06)
diff --git a/src/app/Http/Controllers/CategoryController.php b/src/app/Http/Controllers/CategoryController.php
index af5afd3..76b4432 100644
--- a/src/app/Http/Controllers/CategoryController.php
+++ b/src/app/Http/Controllers/CategoryController.php
@@ -21,7 +21,7 @@ public function create(Request $request): RedirectResponse
->first() ?: new Category();
$request->validate([
- 'category' => 'required|string|unique:categories,category' . $category->id,
+ 'category' => 'required|string',
]);
if ($category->trashed()) {
diff --git a/src/database/migrations/2023_09_20_040645_add_indexes.php b/src/database/migrations/2023_09_20_040645_add_indexes.php
new file mode 100644
index 0000000..3d3e56f
--- /dev/null
+++ b/src/database/migrations/2023_09_20_040645_add_indexes.php
@@ -0,0 +1,30 @@
+string('category')->nullable(false)->change();
+ $table->unique('category');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('categories', function (Blueprint $table) {
+ $table->dropUnique(['category']);
+ $table->string('category')->nullable(true)->change();
+ });
+ }
+};
diff --git a/src/resources/views/create-post.blade.php b/src/resources/views/create-post.blade.php
index fbb3e61..7b74266 100644
--- a/src/resources/views/create-post.blade.php
+++ b/src/resources/views/create-post.blade.php
@@ -15,7 +15,7 @@
-
@if (isset($post->banner_image_url) &&
diff --git a/src/resources/views/posts.blade.php b/src/resources/views/posts.blade.php
index 0b77887..8cf13f8 100644
--- a/src/resources/views/posts.blade.php
+++ b/src/resources/views/posts.blade.php
@@ -31,11 +31,7 @@ class="banner-image">
{{ \App\Http\Controllers\PostController::generateReadingTime($post) }} minutes
- @if (isset($post->category->category))
- {{ $post->category->category }}
- @else
- {{ 'Uncategorized' }}
- @endif
+ {{ $post->category->category }}
post); ?>
From f2bfcb647bf3391e76a661f9a6c22209dabc9b3d Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 23:21:06 -0600
Subject: [PATCH 5/8] feat: adds indexes to user and category id on posts table
---
.../migrations/2023_09_20_040645_add_indexes.php | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/database/migrations/2023_09_20_040645_add_indexes.php b/src/database/migrations/2023_09_20_040645_add_indexes.php
index 51d5e59..ae324c3 100644
--- a/src/database/migrations/2023_09_20_040645_add_indexes.php
+++ b/src/database/migrations/2023_09_20_040645_add_indexes.php
@@ -19,6 +19,11 @@ public function up(): void
Schema::table('comments', function (Blueprint $table) {
$table->index(['post_id']);
});
+
+ Schema::table('posts', function (Blueprint $table) {
+ $table->index(['category_id']);
+ $table->index(['user_id']);
+ });
}
/**
@@ -34,5 +39,10 @@ public function down(): void
Schema::table('comments', function (Blueprint $table) {
$table->dropIndex('comments_post_id_index');
});
+
+ Schema::table('posts', function (Blueprint $table) {
+ $table->dropIndex('posts_category_id_index');
+ $table->dropIndex('posts_user_id_index');
+ });
}
};
From bf970068c02727b3e0b1f02db7efab692e481a92 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 23:21:46 -0600
Subject: [PATCH 6/8] feat: add index on user name field
---
src/database/migrations/2023_09_20_040645_add_indexes.php | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/database/migrations/2023_09_20_040645_add_indexes.php b/src/database/migrations/2023_09_20_040645_add_indexes.php
index ae324c3..9f211ef 100644
--- a/src/database/migrations/2023_09_20_040645_add_indexes.php
+++ b/src/database/migrations/2023_09_20_040645_add_indexes.php
@@ -24,6 +24,10 @@ public function up(): void
$table->index(['category_id']);
$table->index(['user_id']);
});
+
+ Schema::table('users', function (Blueprint $table) {
+ $table->index(['name']);
+ });
}
/**
@@ -44,5 +48,9 @@ public function down(): void
$table->dropIndex('posts_category_id_index');
$table->dropIndex('posts_user_id_index');
});
+
+ Schema::table('users', function (Blueprint $table) {
+ $table->dropIndex('users_name_index');
+ });
}
};
From 43791aa8945615a7d2f180b8fc4822c48436e0c3 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 23:44:33 -0600
Subject: [PATCH 7/8] fix: unique category in factory
---
CHANGELOG.md | 6 ++++--
src/database/factories/CategoryFactory.php | 2 +-
src/justfile | 2 +-
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index beac0a1..6026f3e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,8 +2,10 @@
## Next Release
-- Categories are now unique, enforced at the database level, and are indexed for quick retrieval
-- Fixed a bug that didn't show the dropdown chevrons for form-select fields when creating a post
+- Categories are now unique and required, enforced at the database level
+- Various database indexes were added for common lookup patterns for quick retrieval
+- Fixes a bug that didn't show the dropdown chevrons for form-select fields when creating a post
+- Fixes a Bootstrap deprecation warning
- Updates MariaDB from 10.11 to 11.1
## v1.0.1 (2023-09-06)
diff --git a/src/database/factories/CategoryFactory.php b/src/database/factories/CategoryFactory.php
index 9ad2d77..89929eb 100644
--- a/src/database/factories/CategoryFactory.php
+++ b/src/database/factories/CategoryFactory.php
@@ -17,7 +17,7 @@ class CategoryFactory extends Factory
public function definition()
{
return [
- 'category' => $this->faker->word(),
+ 'category' => $this->faker->unique()->word(),
];
}
}
diff --git a/src/justfile b/src/justfile
index e325004..065e0ea 100644
--- a/src/justfile
+++ b/src/justfile
@@ -73,7 +73,7 @@ seed:
# Sets up and spins up the project for the first time
setup:
#!/usr/bin/env bash
- bash <(curl -s https://gist.githubusercontent.com/Justintime50/2de9303a491c22627ee502aaa7b1f289/raw/) glass glass has_database
+ bash <(curl -s https://gist.githubusercontent.com/Justintime50/2de9303a491c22627ee502aaa7b1f289/raw) glass glass has_database
# Tests the project
test:
From 273571ecaadee8a4681cefedd29c8aab37540862 Mon Sep 17 00:00:00 2001
From: Justintime50 <39606064+Justintime50@users.noreply.github.com>
Date: Tue, 19 Sep 2023 23:48:14 -0600
Subject: [PATCH 8/8] fix: feed category
---
src/resources/views/rss/feed.blade.php | 33 +++++++++++++++++---------
1 file changed, 22 insertions(+), 11 deletions(-)
diff --git a/src/resources/views/rss/feed.blade.php b/src/resources/views/rss/feed.blade.php
index 1b93868..ad16571 100644
--- a/src/resources/views/rss/feed.blade.php
+++ b/src/resources/views/rss/feed.blade.php
@@ -1,21 +1,32 @@
=
-'' . PHP_EOL
-?>
+'' . PHP_EOL ?>
-
-
-
+
+
+
+
+
+
+
+
+
en
{{ now() }}
- @foreach($posts as $post)
+ @foreach ($posts as $post)
-
- title }}]]>
- {{ url('/'.str_replace(' ','-',$post->user->name).'/'.$post->slug) }}
- post !!}]]>
- @if (isset($post->category->category)) {{ $post->category->category }} @else {{ 'Uncategorized' }} @endif
- user->name }}]]>
+
+ title }}]]>
+
+ {{ url('/' . str_replace(' ', '-', $post->user->name) . '/' . $post->slug) }}
+
+ post !!}]]>
+
+ {{ $post->category->category }}
+
+ user->name }}]]>
+
{{ $post->created_at->toRssString() }}
@endforeach