Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5fc9515c0a | ||
|
|
2d945f6015 | ||
|
|
20321ece21 | ||
|
|
c116b545fe | ||
|
|
d05f58b67c | ||
|
|
02d1c4b784 | ||
|
|
3e24c3936a |
No files matched your search
@@ -1,40 +0,0 @@
|
|||||||
name: Update flake lock
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# Gitea cron schedules use UTC. 07:00 UTC is 03:00 EDT.
|
|
||||||
- cron: "0 7 * * 0"
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
update-flake-lock:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Check out repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Install upstream Nix
|
|
||||||
uses: cachix/install-nix-action@v31
|
|
||||||
|
|
||||||
- name: Update flake lock
|
|
||||||
run: nix flake update
|
|
||||||
|
|
||||||
- name: Commit and push changes
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
if git diff --quiet -- flake.lock; then
|
|
||||||
echo "flake.lock is already up to date"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
git config user.name "gitea-actions[bot]"
|
|
||||||
git config user.email "gitea-actions[bot]@noreply.localhost"
|
|
||||||
git add flake.lock
|
|
||||||
git commit -m "chore: update flake lock"
|
|
||||||
git push
|
|
||||||
+3
-9
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.view_count DESC LIMIT 3",
|
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.created_at DESC LIMIT 10",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -35,16 +35,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 7,
|
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 7,
|
||||||
"name": "publish_date",
|
"name": "publish_date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
}
|
}
|
||||||
@@ -60,9 +55,8 @@
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "7998c2354eacb1cfbeece7dc001f57e0ce4d3ca15b28940a631cd249b72d6dc3"
|
"hash": "053f5b53a743065aa0105903cdd0ec803861a2477c38a02754d2d350a34aaa68"
|
||||||
}
|
}
|
||||||
+4
-10
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date, p.is_featured FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.post_id = $1 ORDER BY p.created_at DESC",
|
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date, p.is_featured FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.post_id = $1 ORDER BY p.created_at DESC",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -35,21 +35,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 7,
|
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 7,
|
||||||
"name": "publish_date",
|
"name": "publish_date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 9,
|
"ordinal": 8,
|
||||||
"name": "is_featured",
|
"name": "is_featured",
|
||||||
"type_info": "Bool"
|
"type_info": "Bool"
|
||||||
}
|
}
|
||||||
@@ -68,9 +63,8 @@
|
|||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "fb4bcc2eb710ceb4bb50ec1c62326b7d709cd53d44944acc2da2e371642bfe1a"
|
"hash": "0891ec97ff1d5d5ab7fbc848ceb4e7ea4f46e2f6282170dfdf90ebc6ab6d5fd9"
|
||||||
}
|
}
|
||||||
+3
-9
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.created_at DESC LIMIT 10",
|
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -35,16 +35,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 7,
|
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 7,
|
||||||
"name": "publish_date",
|
"name": "publish_date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
}
|
}
|
||||||
@@ -60,9 +55,8 @@
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "9cc954af48cf92abaa30a8d26499fded1ce30609c29b34d10cf98573d40bdbb6"
|
"hash": "0ec6c9d94fceba56112e78c82acc56ae01bc3c641e28ee21e331c06e2fd9e551"
|
||||||
}
|
}
|
||||||
+4
-10
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT p.post_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date, a.author_id FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.author_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3",
|
"query": "SELECT p.post_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date, a.author_id FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.author_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -30,21 +30,16 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 5,
|
"ordinal": 5,
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 6,
|
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 7,
|
"ordinal": 6,
|
||||||
"name": "publish_date",
|
"name": "publish_date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 7,
|
||||||
"name": "author_id",
|
"name": "author_id",
|
||||||
"type_info": "Int4"
|
"type_info": "Int4"
|
||||||
}
|
}
|
||||||
@@ -64,9 +59,8 @@
|
|||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
false
|
false
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "1ae4bbbfd835587ea4389b3b4500d1b0f549d682f892a10586815014519bb8c4"
|
"hash": "3831b52c2db3d1114c4b01a761c74168b66904bacff847844d463454b7fcde43"
|
||||||
}
|
}
|
||||||
Generated
-68
@@ -1,68 +0,0 @@
|
|||||||
{
|
|
||||||
"db_name": "PostgreSQL",
|
|
||||||
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id LEFT JOIN comments c ON p.post_id = c.post_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY COUNT(c.comment_id) DESC LIMIT 3",
|
|
||||||
"describe": {
|
|
||||||
"columns": [
|
|
||||||
{
|
|
||||||
"ordinal": 0,
|
|
||||||
"name": "post_id",
|
|
||||||
"type_info": "Int4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 1,
|
|
||||||
"name": "author_id",
|
|
||||||
"type_info": "Int4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 2,
|
|
||||||
"name": "first_name",
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 3,
|
|
||||||
"name": "last_name",
|
|
||||||
"type_info": "Varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 4,
|
|
||||||
"name": "title",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 5,
|
|
||||||
"name": "body",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 6,
|
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 7,
|
|
||||||
"name": "created_at",
|
|
||||||
"type_info": "Timestamptz"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 8,
|
|
||||||
"name": "publish_date",
|
|
||||||
"type_info": "Timestamptz"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"parameters": {
|
|
||||||
"Left": []
|
|
||||||
},
|
|
||||||
"nullable": [
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
true,
|
|
||||||
true
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"hash": "464d1fdbed6800f3b09e3abca989d79dfcca8a6680cb0ee324ba0790e4ec3484"
|
|
||||||
}
|
|
||||||
+3
-9
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3",
|
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id LEFT JOIN comments c ON p.post_id = c.post_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY COUNT(c.comment_id) DESC LIMIT 3",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -35,16 +35,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 7,
|
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 7,
|
||||||
"name": "publish_date",
|
"name": "publish_date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
}
|
}
|
||||||
@@ -60,9 +55,8 @@
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "4557c49e323c6b7c3246903e63e1c61c0f008e80308f65066bff7f4b70a8c7dd"
|
"hash": "49768c8b986078bdfaad191b3ea1f07ca033b2a734162a3f8fcf0ef0a44c1e7f"
|
||||||
}
|
}
|
||||||
+3
-9
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"db_name": "PostgreSQL",
|
"db_name": "PostgreSQL",
|
||||||
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.is_featured IS true GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3",
|
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.is_featured IS true GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3",
|
||||||
"describe": {
|
"describe": {
|
||||||
"columns": [
|
"columns": [
|
||||||
{
|
{
|
||||||
@@ -35,16 +35,11 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 6,
|
"ordinal": 6,
|
||||||
"name": "body_gemtext",
|
|
||||||
"type_info": "Text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ordinal": 7,
|
|
||||||
"name": "created_at",
|
"name": "created_at",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ordinal": 8,
|
"ordinal": 7,
|
||||||
"name": "publish_date",
|
"name": "publish_date",
|
||||||
"type_info": "Timestamptz"
|
"type_info": "Timestamptz"
|
||||||
}
|
}
|
||||||
@@ -60,9 +55,8 @@
|
|||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
true,
|
|
||||||
true
|
true
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"hash": "24f4b8dd651c57a8cab3ffc2fae9bfe4cb276521854b2a0a0fba2e7081093421"
|
"hash": "9d93a8a7c0a2442a511108af36d4adfb1ef8a2fac82448205654742f43dc4e75"
|
||||||
}
|
}
|
||||||
Generated
+62
@@ -0,0 +1,62 @@
|
|||||||
|
{
|
||||||
|
"db_name": "PostgreSQL",
|
||||||
|
"query": "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.view_count DESC LIMIT 3",
|
||||||
|
"describe": {
|
||||||
|
"columns": [
|
||||||
|
{
|
||||||
|
"ordinal": 0,
|
||||||
|
"name": "post_id",
|
||||||
|
"type_info": "Int4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 1,
|
||||||
|
"name": "author_id",
|
||||||
|
"type_info": "Int4"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 2,
|
||||||
|
"name": "first_name",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 3,
|
||||||
|
"name": "last_name",
|
||||||
|
"type_info": "Varchar"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 4,
|
||||||
|
"name": "title",
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 5,
|
||||||
|
"name": "body",
|
||||||
|
"type_info": "Text"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 6,
|
||||||
|
"name": "created_at",
|
||||||
|
"type_info": "Timestamptz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"ordinal": 7,
|
||||||
|
"name": "publish_date",
|
||||||
|
"type_info": "Timestamptz"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"parameters": {
|
||||||
|
"Left": []
|
||||||
|
},
|
||||||
|
"nullable": [
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"hash": "ad39df8c37105f13b620f8898e570cdbc54d4bd4e402aac65a28c9aa81803831"
|
||||||
|
}
|
||||||
Generated
+137
-377
@@ -2,6 +2,21 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "addr2line"
|
||||||
|
version = "0.24.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
|
||||||
|
dependencies = [
|
||||||
|
"gimli",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler2"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "1.1.3"
|
version = "1.1.3"
|
||||||
@@ -38,45 +53,6 @@ version = "1.7.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "asn1-rs"
|
|
||||||
version = "0.7.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b7f43a50ac4fdca5df8e885c21b835997f0a1cdee65494a6847694a98652d9d8"
|
|
||||||
dependencies = [
|
|
||||||
"asn1-rs-derive",
|
|
||||||
"asn1-rs-impl",
|
|
||||||
"displaydoc",
|
|
||||||
"nom",
|
|
||||||
"num-traits",
|
|
||||||
"rusticata-macros",
|
|
||||||
"thiserror 2.0.21",
|
|
||||||
"time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "asn1-rs-derive"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
"synstructure",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "asn1-rs-impl"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.104",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-trait"
|
name = "async-trait"
|
||||||
version = "0.1.88"
|
version = "0.1.88"
|
||||||
@@ -85,7 +61,7 @@ checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -109,29 +85,6 @@ version = "1.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aws-lc-rs"
|
|
||||||
version = "1.19.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "048006790404103c488e6c5616b3e7e702a71292aadda08e8f7698a9e0d2eb53"
|
|
||||||
dependencies = [
|
|
||||||
"aws-lc-sys",
|
|
||||||
"zeroize",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "aws-lc-sys"
|
|
||||||
version = "0.47.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8bfbe32ac36b3c428696ce315464181bc4029d689fd58e3f2a4e58c252242f52"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
"cmake",
|
|
||||||
"dunce",
|
|
||||||
"fs_extra",
|
|
||||||
"pkg-config",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "axum"
|
name = "axum"
|
||||||
version = "0.7.9"
|
version = "0.7.9"
|
||||||
@@ -241,6 +194,21 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "backtrace"
|
||||||
|
version = "0.3.75"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002"
|
||||||
|
dependencies = [
|
||||||
|
"addr2line",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
|
"object",
|
||||||
|
"rustc-demangle",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
@@ -310,13 +278,10 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.11.0"
|
version = "1.2.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "375989decec1a0fa424442bed520fa12ede43a48475ce8c7417d2c69b32b5f6b"
|
checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"find-msvc-tools",
|
|
||||||
"jobserver",
|
|
||||||
"libc",
|
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -337,16 +302,7 @@ dependencies = [
|
|||||||
"js-sys",
|
"js-sys",
|
||||||
"num-traits",
|
"num-traits",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"windows-link 0.1.3",
|
"windows-link",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cmake"
|
|
||||||
version = "0.1.58"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c0f78a02292a74a88ac736019ab962ece0bc380e3f977bf72e376c5d78ff0678"
|
|
||||||
dependencies = [
|
|
||||||
"cc",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -444,12 +400,6 @@ dependencies = [
|
|||||||
"parking_lot_core",
|
"parking_lot_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "data-encoding"
|
|
||||||
version = "2.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "der"
|
name = "der"
|
||||||
version = "0.7.10"
|
version = "0.7.10"
|
||||||
@@ -461,29 +411,6 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "der-parser"
|
|
||||||
version = "10.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6"
|
|
||||||
dependencies = [
|
|
||||||
"asn1-rs",
|
|
||||||
"displaydoc",
|
|
||||||
"nom",
|
|
||||||
"num-bigint",
|
|
||||||
"num-traits",
|
|
||||||
"rusticata-macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "deranged"
|
|
||||||
version = "0.5.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e"
|
|
||||||
dependencies = [
|
|
||||||
"powerfmt",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "digest"
|
name = "digest"
|
||||||
version = "0.10.7"
|
version = "0.10.7"
|
||||||
@@ -504,7 +431,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -513,12 +440,6 @@ version = "0.15.7"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dunce"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.15.0"
|
version = "1.15.0"
|
||||||
@@ -556,12 +477,6 @@ dependencies = [
|
|||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "find-msvc-tools"
|
|
||||||
version = "0.1.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "float-cmp"
|
name = "float-cmp"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
@@ -596,9 +511,9 @@ checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.2.2"
|
version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
|
checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
@@ -631,7 +546,7 @@ dependencies = [
|
|||||||
"rand",
|
"rand",
|
||||||
"redis-protocol",
|
"redis-protocol",
|
||||||
"semver",
|
"semver",
|
||||||
"socket2 0.5.10",
|
"socket2",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-util",
|
"tokio-util",
|
||||||
@@ -647,15 +562,9 @@ checksum = "1458c6e22d36d61507034d5afecc64f105c1d39712b7ac6ec3b352c423f715cc"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fs_extra"
|
|
||||||
version = "1.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures"
|
name = "futures"
|
||||||
version = "0.3.31"
|
version = "0.3.31"
|
||||||
@@ -723,7 +632,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -762,26 +671,6 @@ dependencies = [
|
|||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gemi"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "48c58101caf24da682290251734dde61f7f0a7fcabb996660008d8e2b960a9ff"
|
|
||||||
dependencies = [
|
|
||||||
"matchit 0.9.2",
|
|
||||||
"ring",
|
|
||||||
"rustls",
|
|
||||||
"rustls-pki-types",
|
|
||||||
"sha2",
|
|
||||||
"thiserror 2.0.21",
|
|
||||||
"tokio",
|
|
||||||
"tokio-rustls",
|
|
||||||
"tracing",
|
|
||||||
"url",
|
|
||||||
"urlencoding",
|
|
||||||
"x509-parser",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.7"
|
version = "0.14.7"
|
||||||
@@ -804,15 +693,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "gimli"
|
||||||
version = "0.4.3"
|
version = "0.31.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"r-efi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "governor"
|
name = "governor"
|
||||||
@@ -1112,9 +996,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "idna"
|
name = "idna"
|
||||||
version = "1.1.0"
|
version = "1.0.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
|
checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"idna_adapter",
|
"idna_adapter",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@@ -1141,22 +1025,23 @@ dependencies = [
|
|||||||
"hashbrown 0.15.4",
|
"hashbrown 0.15.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "io-uring"
|
||||||
|
version = "0.7.8"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itoa"
|
name = "itoa"
|
||||||
version = "1.0.15"
|
version = "1.0.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "jobserver"
|
|
||||||
version = "0.1.35"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"
|
|
||||||
dependencies = [
|
|
||||||
"getrandom 0.4.3",
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "js-sys"
|
name = "js-sys"
|
||||||
version = "0.3.77"
|
version = "0.3.77"
|
||||||
@@ -1178,9 +1063,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.191"
|
version = "0.2.174"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libm"
|
name = "libm"
|
||||||
@@ -1241,12 +1126,6 @@ version = "0.8.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "matchit"
|
|
||||||
version = "0.9.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "8863b587001c1b9a8a4e36008cebc6b3612cb1226fe2de94858e06092687b608"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "md-5"
|
name = "md-5"
|
||||||
version = "0.10.6"
|
version = "0.10.6"
|
||||||
@@ -1276,14 +1155,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "miniz_oxide"
|
||||||
version = "1.2.4"
|
version = "0.8.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
|
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||||
|
dependencies = [
|
||||||
|
"adler2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "mio"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi",
|
"wasi",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1324,16 +1212,6 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-bigint"
|
|
||||||
version = "0.4.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"
|
|
||||||
dependencies = [
|
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-bigint-dig"
|
name = "num-bigint-dig"
|
||||||
version = "0.8.4"
|
version = "0.8.4"
|
||||||
@@ -1351,12 +1229,6 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-conv"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-integer"
|
name = "num-integer"
|
||||||
version = "0.1.46"
|
version = "0.1.46"
|
||||||
@@ -1388,12 +1260,12 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "oid-registry"
|
name = "object"
|
||||||
version = "0.8.1"
|
version = "0.36.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7"
|
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"asn1-rs",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1448,9 +1320,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.3.2"
|
version = "2.3.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project"
|
name = "pin-project"
|
||||||
@@ -1469,7 +1341,7 @@ checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1526,12 +1398,6 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "powerfmt"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.21"
|
version = "0.2.21"
|
||||||
@@ -1552,15 +1418,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "public"
|
name = "public"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum 0.8.4",
|
"axum 0.8.4",
|
||||||
"cache",
|
"cache",
|
||||||
"chrono",
|
"chrono",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"fred",
|
"fred",
|
||||||
"gemi",
|
|
||||||
"rustls",
|
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
@@ -1596,12 +1460,6 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "r-efi"
|
|
||||||
version = "6.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
@@ -1629,7 +1487,7 @@ version = "0.6.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.2.16",
|
"getrandom",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1716,7 +1574,7 @@ checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"getrandom 0.2.16",
|
"getrandom",
|
||||||
"libc",
|
"libc",
|
||||||
"untrusted",
|
"untrusted",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
@@ -1743,22 +1601,17 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusticata-macros"
|
name = "rustc-demangle"
|
||||||
version = "4.1.0"
|
version = "0.1.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632"
|
checksum = "989e6739f80c4ad5b13e0fd7fe89531180375b18520cc8c82080e4dc4035b84f"
|
||||||
dependencies = [
|
|
||||||
"nom",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.46"
|
version = "0.23.29"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf"
|
checksum = "2491382039b29b9b11ff08b76ff6c97cf287671dbb74f0be44bda389fffe9bd1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
|
||||||
"log",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"ring",
|
"ring",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
@@ -1769,20 +1622,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-pki-types"
|
name = "rustls-pki-types"
|
||||||
version = "1.15.1"
|
version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"
|
checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls-webpki"
|
name = "rustls-webpki"
|
||||||
version = "0.103.16"
|
version = "0.103.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281"
|
checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aws-lc-rs",
|
|
||||||
"ring",
|
"ring",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
"untrusted",
|
"untrusted",
|
||||||
@@ -1829,7 +1681,7 @@ checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1899,9 +1751,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "shlex"
|
name = "shlex"
|
||||||
version = "2.0.1"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "signal-hook-registry"
|
name = "signal-hook-registry"
|
||||||
@@ -1947,16 +1799,6 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "socket2"
|
|
||||||
version = "0.6.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"windows-sys 0.61.2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "spin"
|
name = "spin"
|
||||||
version = "0.9.8"
|
version = "0.9.8"
|
||||||
@@ -2027,7 +1869,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"sha2",
|
"sha2",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thiserror 2.0.21",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -2045,7 +1887,7 @@ dependencies = [
|
|||||||
"quote",
|
"quote",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"sqlx-macros-core",
|
"sqlx-macros-core",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2068,7 +1910,7 @@ dependencies = [
|
|||||||
"sqlx-mysql",
|
"sqlx-mysql",
|
||||||
"sqlx-postgres",
|
"sqlx-postgres",
|
||||||
"sqlx-sqlite",
|
"sqlx-sqlite",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"tokio",
|
"tokio",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
@@ -2111,7 +1953,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"stringprep",
|
"stringprep",
|
||||||
"thiserror 2.0.21",
|
"thiserror 2.0.12",
|
||||||
"tracing",
|
"tracing",
|
||||||
"whoami",
|
"whoami",
|
||||||
]
|
]
|
||||||
@@ -2149,7 +1991,7 @@ dependencies = [
|
|||||||
"smallvec",
|
"smallvec",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"stringprep",
|
"stringprep",
|
||||||
"thiserror 2.0.21",
|
"thiserror 2.0.12",
|
||||||
"tracing",
|
"tracing",
|
||||||
"whoami",
|
"whoami",
|
||||||
]
|
]
|
||||||
@@ -2174,7 +2016,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"sqlx-core",
|
"sqlx-core",
|
||||||
"thiserror 2.0.21",
|
"thiserror 2.0.12",
|
||||||
"tracing",
|
"tracing",
|
||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
@@ -2213,17 +2055,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "3.0.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sync_wrapper"
|
name = "sync_wrapper"
|
||||||
version = "1.0.2"
|
version = "1.0.2"
|
||||||
@@ -2238,7 +2069,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2252,11 +2083,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "2.0.21"
|
version = "2.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl 2.0.21",
|
"thiserror-impl 2.0.12",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2267,18 +2098,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "2.0.21"
|
version = "2.0.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 3.0.9",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2290,37 +2121,6 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time"
|
|
||||||
version = "0.3.44"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d"
|
|
||||||
dependencies = [
|
|
||||||
"deranged",
|
|
||||||
"itoa",
|
|
||||||
"num-conv",
|
|
||||||
"powerfmt",
|
|
||||||
"serde",
|
|
||||||
"time-core",
|
|
||||||
"time-macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time-core"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time-macros"
|
|
||||||
version = "0.2.24"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
|
|
||||||
dependencies = [
|
|
||||||
"num-conv",
|
|
||||||
"time-core",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinystr"
|
name = "tinystr"
|
||||||
version = "0.8.1"
|
version = "0.8.1"
|
||||||
@@ -2348,40 +2148,33 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.54.1"
|
version = "1.46.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3"
|
checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"io-uring",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2 0.6.5",
|
"slab",
|
||||||
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-macros"
|
name = "tokio-macros"
|
||||||
version = "2.7.2"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
|
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 3.0.9",
|
"syn",
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "tokio-rustls"
|
|
||||||
version = "0.26.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db"
|
|
||||||
dependencies = [
|
|
||||||
"rustls",
|
|
||||||
"tokio",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2470,9 +2263,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing"
|
name = "tracing"
|
||||||
version = "0.1.44"
|
version = "0.1.41"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
@@ -2482,20 +2275,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-attributes"
|
name = "tracing-attributes"
|
||||||
version = "0.1.31"
|
version = "0.1.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
|
checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-core"
|
name = "tracing-core"
|
||||||
version = "0.1.36"
|
version = "0.1.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
|
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"valuable",
|
"valuable",
|
||||||
@@ -2571,14 +2364,13 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "url"
|
name = "url"
|
||||||
version = "2.5.8"
|
version = "2.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
|
checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"form_urlencoded",
|
"form_urlencoded",
|
||||||
"idna",
|
"idna",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"serde",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2645,7 +2437,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2667,7 +2459,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
@@ -2749,7 +2541,7 @@ checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement",
|
||||||
"windows-interface",
|
"windows-interface",
|
||||||
"windows-link 0.1.3",
|
"windows-link",
|
||||||
"windows-result",
|
"windows-result",
|
||||||
"windows-strings",
|
"windows-strings",
|
||||||
]
|
]
|
||||||
@@ -2762,7 +2554,7 @@ checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2773,7 +2565,7 @@ checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2782,19 +2574,13 @@ version = "0.1.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-link"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-result"
|
name = "windows-result"
|
||||||
version = "0.3.4"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
|
checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-link 0.1.3",
|
"windows-link",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2803,7 +2589,7 @@ version = "0.4.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
|
checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-link 0.1.3",
|
"windows-link",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2833,15 +2619,6 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows-sys"
|
|
||||||
version = "0.61.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
|
||||||
dependencies = [
|
|
||||||
"windows-link 0.2.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.48.5"
|
version = "0.48.5"
|
||||||
@@ -2969,23 +2746,6 @@ version = "0.6.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
|
checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "x509-parser"
|
|
||||||
version = "0.18.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d43b0f71ce057da06bc0851b23ee24f3f86190b07203dd8f567d0b706a185202"
|
|
||||||
dependencies = [
|
|
||||||
"asn1-rs",
|
|
||||||
"data-encoding",
|
|
||||||
"der-parser",
|
|
||||||
"lazy_static",
|
|
||||||
"nom",
|
|
||||||
"oid-registry",
|
|
||||||
"rusticata-macros",
|
|
||||||
"thiserror 2.0.21",
|
|
||||||
"time",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml"
|
name = "xml"
|
||||||
version = "0.8.20"
|
version = "0.8.20"
|
||||||
@@ -3021,7 +2781,7 @@ checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3042,7 +2802,7 @@ checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -3062,7 +2822,7 @@ checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
"synstructure",
|
"synstructure",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3102,5 +2862,5 @@ checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.104",
|
"syn",
|
||||||
]
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "public"
|
name = "public"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Wyatt J. Miller <wyatt@wyattjmiller.com"]
|
authors = ["Wyatt J. Miller <wyatt@wyattjmiller.com"]
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ authors = ["Wyatt J. Miller <wyatt@wyattjmiller.com"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = { version = "0.8.4", features = ["http2", "tokio"] }
|
axum = { version = "0.8.4", features = ["http2", "tokio"] }
|
||||||
gemi = "0.1.0"
|
|
||||||
tower-http = { version = "0.6.1", features = ["trace", "cors"] }
|
tower-http = { version = "0.6.1", features = ["trace", "cors"] }
|
||||||
tower_governor = "0.4.2"
|
tower_governor = "0.4.2"
|
||||||
tokio = { version = "1.40.0", features = ["full"] }
|
tokio = { version = "1.40.0", features = ["full"] }
|
||||||
@@ -18,7 +17,6 @@ sqlx = { version = "0.8.2", features = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"json",
|
"json",
|
||||||
] }
|
] }
|
||||||
rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] }
|
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
|
|||||||
@@ -18,25 +18,3 @@ For `public` to work properly, please make sure to first create the `.env` file,
|
|||||||
- `DATABASE_URL` - needed for connecting to Postgres
|
- `DATABASE_URL` - needed for connecting to Postgres
|
||||||
- `REDIS_URL` - needed for connecting to the cache (Redis or Valkey)
|
- `REDIS_URL` - needed for connecting to the cache (Redis or Valkey)
|
||||||
- `BASE_URI_WEB` - needed for connecting to the frontend user interface of the system to this service
|
- `BASE_URI_WEB` - needed for connecting to the frontend user interface of the system to this service
|
||||||
|
|
||||||
### Gemini
|
|
||||||
|
|
||||||
Set `SERVE_APP=gemini` to run the existing Gemini TLS server on port 1965.
|
|
||||||
It uses `dev-cert.der` and `dev-key.der` in the working directory; database and
|
|
||||||
cache configuration is shared with HTTP mode. `BASE_URI_WEB` supplies links back
|
|
||||||
to the web site for RSS, the sitemap, contact forms, and posts without Gemtext.
|
|
||||||
|
|
||||||
The capsule follows the web site's navigation and page sections:
|
|
||||||
|
|
||||||
- `/`, `/contact`, `/health`
|
|
||||||
- `/posts`, `/posts/all`, `/posts/{id}`
|
|
||||||
- `/posts/featured`, `/posts/recent`, `/posts/popular`, `/posts/hot`
|
|
||||||
- `/authors`, `/authors/{id}`, `/authors/{id}/posts`
|
|
||||||
- `/projects`
|
|
||||||
- `/comments/index`, `/comments/post/{id}`
|
|
||||||
|
|
||||||
Author and comment indexes accept `?page=1&limit=12` (maximum limit 100).
|
|
||||||
Author pages include a biography and paginated post links. Article pages render
|
|
||||||
`body_gemtext` as Gemtext, with author, publication date, and featured status;
|
|
||||||
articles without it link to the HTML version. Comments are read-only, with a
|
|
||||||
link to the web page for participation.
|
|
||||||
@@ -1,22 +1,5 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
pub enum ServeAppConfig {
|
|
||||||
Http,
|
|
||||||
Gemini,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl std::str::FromStr for ServeAppConfig {
|
|
||||||
type Err = &'static str;
|
|
||||||
|
|
||||||
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
|
||||||
match value {
|
|
||||||
"http" => Ok(Self::Http),
|
|
||||||
"gemini" => Ok(Self::Gemini),
|
|
||||||
_ => Err("expected \"http\" or \"gemini\""),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn config() -> Configuration {
|
pub fn config() -> Configuration {
|
||||||
Configuration {
|
Configuration {
|
||||||
env: dotenvy::dotenv(),
|
env: dotenvy::dotenv(),
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use sqlx::{Pool, Postgres};
|
use sqlx::{Pool, Postgres};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
models::{authors::Author, posts::Post},
|
routes::{authors::Author, posts::Post},
|
||||||
utils::pagination::Pagination,
|
utils::pagination::Pagination,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ impl AuthorsDatasource {
|
|||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Author,
|
Author,
|
||||||
"SELECT author_id, first_name, last_name, bio, image FROM authors ORDER BY created_at DESC LIMIT $1 OFFSET $2",
|
"SELECT author_id, first_name, last_name, bio, image FROM authors ORDER BY created_at DESC LIMIT $1 OFFSET $2",
|
||||||
pagination.limit,
|
pagination.page,
|
||||||
offset,
|
offset,
|
||||||
)
|
)
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
@@ -53,7 +53,7 @@ impl AuthorsDatasource {
|
|||||||
|
|
||||||
let posts_query = sqlx::query_as!(
|
let posts_query = sqlx::query_as!(
|
||||||
Post,
|
Post,
|
||||||
"SELECT p.post_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date, a.author_id FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.author_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3",
|
"SELECT p.post_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date, a.author_id FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.author_id = $1 ORDER BY created_at DESC LIMIT $2 OFFSET $3",
|
||||||
author_id,
|
author_id,
|
||||||
pagination.limit,
|
pagination.limit,
|
||||||
offset,
|
offset,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
models::comments::{Comment, CommentInputPayload},
|
routes::comments::{Comment, CommentInputPayload},
|
||||||
utils::pagination::Pagination,
|
utils::pagination::Pagination,
|
||||||
};
|
};
|
||||||
use sqlx::{Pool, Postgres};
|
use sqlx::{Pool, Postgres};
|
||||||
@@ -29,7 +29,7 @@ impl CommentsDatasource {
|
|||||||
pagination: Pagination,
|
pagination: Pagination,
|
||||||
) -> Result<Vec<Comment>, sqlx::Error> {
|
) -> Result<Vec<Comment>, sqlx::Error> {
|
||||||
let offset: i64 = (pagination.page - 1) * pagination.limit;
|
let offset: i64 = (pagination.page - 1) * pagination.limit;
|
||||||
sqlx::query_as!(Comment, "SELECT comment_id, name, body, created_at FROM comments ORDER BY created_at DESC LIMIT $1 OFFSET $2", pagination.limit, offset)
|
sqlx::query_as!(Comment, "SELECT comment_id, name, body, created_at FROM comments ORDER BY created_at DESC LIMIT $1 OFFSET $2", pagination.page, offset)
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
use sqlx::{Pool, Postgres};
|
use sqlx::{Pool, Postgres};
|
||||||
|
|
||||||
use crate::models::posts::{Post, PostFeaturedVariant};
|
use crate::routes::posts::{Post, PostFeaturedVariant};
|
||||||
|
|
||||||
pub struct PostsDatasource;
|
pub struct PostsDatasource;
|
||||||
impl PostsDatasource {
|
impl PostsDatasource {
|
||||||
pub async fn get_all(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
pub async fn get_all(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
||||||
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.created_at DESC LIMIT 10")
|
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.created_at DESC LIMIT 10")
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
@@ -19,31 +19,31 @@ impl PostsDatasource {
|
|||||||
.execute(pool)
|
.execute(pool)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
sqlx::query_as!(PostFeaturedVariant, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date, p.is_featured FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.post_id = $1 ORDER BY p.created_at DESC", post_id)
|
sqlx::query_as!(PostFeaturedVariant, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date, p.is_featured FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.post_id = $1 ORDER BY p.created_at DESC", post_id)
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_recent(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
pub async fn get_recent(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
||||||
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3")
|
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3")
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_popular(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
pub async fn get_popular(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
||||||
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id LEFT JOIN comments c ON p.post_id = c.post_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY COUNT(c.comment_id) DESC LIMIT 3")
|
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id LEFT JOIN comments c ON p.post_id = c.post_id WHERE p.deleted_at IS NULL GROUP BY p.post_id, a.first_name, a.last_name ORDER BY COUNT(c.comment_id) DESC LIMIT 3")
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_hot(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
pub async fn get_hot(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
||||||
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.view_count DESC LIMIT 3")
|
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL ORDER BY p.view_count DESC LIMIT 3")
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_featured(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
pub async fn get_featured(pool: &Pool<Postgres>) -> Result<Vec<Post>, sqlx::Error> {
|
||||||
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.body_gemtext, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.is_featured IS true GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3")
|
sqlx::query_as!(Post, "SELECT p.post_id, p.author_id, a.first_name, a.last_name, p.title, p.body, p.created_at, p.publish_date FROM posts p LEFT JOIN authors a ON a.author_id = p.author_id WHERE p.deleted_at IS NULL AND p.is_featured IS true GROUP BY p.post_id, a.first_name, a.last_name ORDER BY p.created_at DESC LIMIT 3")
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use sqlx::{Pool, Postgres};
|
use sqlx::{Pool, Postgres};
|
||||||
|
|
||||||
use crate::models::projects::Project;
|
use crate::routes::projects::Project;
|
||||||
|
|
||||||
pub struct ProjectsDatasource;
|
pub struct ProjectsDatasource;
|
||||||
impl ProjectsDatasource {
|
impl ProjectsDatasource {
|
||||||
pub async fn get_all(pool: &Pool<Postgres>) -> Result<Vec<Project>, sqlx::Error> {
|
pub async fn get_all(pool: &Pool<Postgres>) -> Result<Vec<Project>, sqlx::Error> {
|
||||||
sqlx::query_as!(
|
sqlx::query_as!(
|
||||||
Project,
|
Project,
|
||||||
"SELECT project_id, title, repo, summary, tech, wip, created_at FROM projects p WHERE deleted_at IS NULL ORDER BY p.created_at DESC"
|
"SELECT p.project_id, title, repo, summary, description, tech, wip, p.created_at, COALESCE(array_agg(pi.url) FILTER (WHERE pi.url IS NOT NULL), '{}') as images FROM projects p LEFT JOIN project_images pi ON p.project_id = pi.project_id AND pi.deleted_at IS NULL WHERE p.deleted_at IS NULL GROUP BY p.project_id, p.title, p.repo, p.summary, p.description, p.tech, p.wip, p.created_at ORDER BY p.created_at DESC"
|
||||||
)
|
)
|
||||||
.fetch_all(pool)
|
.fetch_all(pool)
|
||||||
.await
|
.await
|
||||||
|
|||||||
+23
-49
@@ -1,5 +1,4 @@
|
|||||||
use axum::Router;
|
use axum::Router;
|
||||||
use gemi::{EndpointExt, GeminiConfig, GeminiServer};
|
|
||||||
use cache::ClientLike;
|
use cache::ClientLike;
|
||||||
use config::config;
|
use config::config;
|
||||||
use sqlx::postgres::PgPoolOptions;
|
use sqlx::postgres::PgPoolOptions;
|
||||||
@@ -18,9 +17,7 @@ use tracing_subscriber::{filter, layer::SubscriberExt, prelude::*, util::Subscri
|
|||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod datasources;
|
mod datasources;
|
||||||
mod models;
|
|
||||||
mod routes;
|
mod routes;
|
||||||
mod services;
|
|
||||||
mod state;
|
mod state;
|
||||||
mod utils;
|
mod utils;
|
||||||
|
|
||||||
@@ -118,53 +115,30 @@ async fn main() {
|
|||||||
let app_state = Arc::new(Mutex::new(state::AppInternalState::new(pool, redis_pool)));
|
let app_state = Arc::new(Mutex::new(state::AppInternalState::new(pool, redis_pool)));
|
||||||
|
|
||||||
// build our application with some routes
|
// build our application with some routes
|
||||||
let app_env = std::env::var("SERVE_APP")
|
let app = Router::new()
|
||||||
.unwrap_or_else(|_| "http".to_string())
|
.merge(routes::root::RootRoute::routes())
|
||||||
.parse::<config::ServeAppConfig>()
|
.merge(routes::posts::PostsRoute::routes(&app_state))
|
||||||
.expect("Invalid SERVE_APP value");
|
.merge(routes::comments::CommentsRoute::routes(&app_state))
|
||||||
|
.merge(routes::authors::AuthorsRoute::routes(&app_state))
|
||||||
match app_env {
|
.merge(routes::projects::ProjectsRoute::routes(&app_state))
|
||||||
config::ServeAppConfig::Http => {
|
.layer(CorsLayer::permissive())
|
||||||
let state = app_state.clone();
|
.layer(
|
||||||
let app = Router::new()
|
TraceLayer::new_for_http()
|
||||||
.merge(routes::http::root::RootRoute::routes())
|
.make_span_with(trace::DefaultMakeSpan::new().level(tracing::Level::INFO))
|
||||||
.merge(routes::http::posts::PostsRoute::routes(&state))
|
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)),
|
||||||
.merge(routes::http::comments::CommentsRoute::routes(&state))
|
)
|
||||||
.merge(routes::http::authors::AuthorsRoute::routes(&state))
|
.fallback(routes::root::RootRoute::not_found);
|
||||||
.merge(routes::http::projects::ProjectsRoute::routes(&state))
|
//.layer(GovernorLayer {
|
||||||
.layer(CorsLayer::permissive())
|
// config: governor_conf,
|
||||||
.layer(
|
//});
|
||||||
TraceLayer::new_for_http()
|
|
||||||
.make_span_with(trace::DefaultMakeSpan::new().level(tracing::Level::INFO))
|
|
||||||
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)),
|
|
||||||
)
|
|
||||||
.fallback(routes::http::root::RootRoute::not_found);
|
|
||||||
|
|
||||||
// run it with hyper
|
|
||||||
let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
|
||||||
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
|
||||||
axum::serve(listener, app)
|
|
||||||
.with_graceful_shutdown(shutdown_signal())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
config::ServeAppConfig::Gemini => {
|
|
||||||
rustls::crypto::ring::default_provider()
|
|
||||||
.install_default()
|
|
||||||
.expect("failed to install Rustls crypto provider");
|
|
||||||
|
|
||||||
let gemini_state = app_state.clone();
|
|
||||||
let router = routes::gemini::routes().expect("Failed to construct Gemini routes");
|
|
||||||
let config = GeminiConfig::new("localhost");
|
|
||||||
let app = router.with_state(gemini_state);
|
|
||||||
let server = GeminiServer::new(app, "dev-cert.der", "dev-key.der", config).unwrap();
|
|
||||||
server
|
|
||||||
.serve_with_shutdown(shutdown_signal())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// run it with hyper
|
||||||
|
let listener = TcpListener::bind("0.0.0.0:3000").await.unwrap();
|
||||||
|
tracing::debug!("listening on {}", listener.local_addr().unwrap());
|
||||||
|
axum::serve(listener, app)
|
||||||
|
.with_graceful_shutdown(shutdown_signal())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn shutdown_signal() {
|
async fn shutdown_signal() {
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone)]
|
|
||||||
pub struct Author {
|
|
||||||
pub author_id: i32,
|
|
||||||
pub first_name: String,
|
|
||||||
pub last_name: String,
|
|
||||||
pub bio: Option<String>,
|
|
||||||
pub image: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone)]
|
|
||||||
pub struct AuthorGetOneParams {
|
|
||||||
pub id: i32,
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use chrono::Utc;
|
|
||||||
|
|
||||||
use crate::utils::datetime::*;
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
|
||||||
pub struct CommentPathParams {
|
|
||||||
pub id: i32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
|
||||||
pub struct Comment {
|
|
||||||
pub comment_id: i32,
|
|
||||||
pub name: String,
|
|
||||||
pub body: String,
|
|
||||||
#[serde(serialize_with = "serialize_datetime")]
|
|
||||||
#[serde(deserialize_with = "deserialize_datetime")]
|
|
||||||
pub created_at: Option<chrono::DateTime<Utc>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
|
||||||
pub struct CommentInputPayload {
|
|
||||||
pub name: String,
|
|
||||||
pub body: String,
|
|
||||||
pub post_id: i32,
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
pub mod authors;
|
|
||||||
pub mod posts;
|
|
||||||
pub mod projects;
|
|
||||||
pub mod comments;
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use chrono::Utc;
|
|
||||||
|
|
||||||
use crate::utils::datetime::*;
|
|
||||||
|
|
||||||
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
|
||||||
pub struct Post {
|
|
||||||
pub post_id: i32,
|
|
||||||
pub author_id: Option<i32>,
|
|
||||||
pub first_name: Option<String>,
|
|
||||||
pub last_name: Option<String>,
|
|
||||||
pub title: String,
|
|
||||||
pub body: String,
|
|
||||||
pub body_gemtext: Option<String>,
|
|
||||||
#[serde(serialize_with = "serialize_datetime")]
|
|
||||||
#[serde(deserialize_with = "deserialize_datetime")]
|
|
||||||
pub created_at: Option<chrono::DateTime<Utc>>,
|
|
||||||
#[serde(serialize_with = "serialize_datetime")]
|
|
||||||
#[serde(deserialize_with = "deserialize_datetime")]
|
|
||||||
pub publish_date: Option<chrono::DateTime<Utc>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
|
||||||
pub struct PostFeaturedVariant {
|
|
||||||
pub post_id: i32,
|
|
||||||
pub author_id: Option<i32>,
|
|
||||||
pub first_name: Option<String>,
|
|
||||||
pub last_name: Option<String>,
|
|
||||||
pub title: String,
|
|
||||||
pub body: String,
|
|
||||||
pub body_gemtext: Option<String>,
|
|
||||||
#[serde(serialize_with = "serialize_datetime")]
|
|
||||||
#[serde(deserialize_with = "deserialize_datetime")]
|
|
||||||
pub created_at: Option<chrono::DateTime<Utc>>,
|
|
||||||
#[serde(serialize_with = "serialize_datetime")]
|
|
||||||
#[serde(deserialize_with = "deserialize_datetime")]
|
|
||||||
pub publish_date: Option<chrono::DateTime<Utc>>,
|
|
||||||
pub is_featured: Option<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
pub struct PostGetOneParams {
|
|
||||||
pub id: i32,
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
use serde::{Serialize, Deserialize};
|
|
||||||
|
|
||||||
use crate::utils::datetime::*;
|
|
||||||
|
|
||||||
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
|
||||||
pub struct Project {
|
|
||||||
pub project_id: i32,
|
|
||||||
pub title: String,
|
|
||||||
pub repo: Option<String>,
|
|
||||||
pub summary: String,
|
|
||||||
pub tech: String,
|
|
||||||
pub wip: Option<bool>,
|
|
||||||
#[serde(serialize_with = "serialize_datetime")]
|
|
||||||
#[serde(deserialize_with = "deserialize_datetime")]
|
|
||||||
pub created_at: Option<chrono::DateTime<chrono::Utc>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -10,18 +10,24 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
datasources::authors::AuthorsDatasource,
|
datasources::authors::AuthorsDatasource,
|
||||||
models::{
|
routes::posts::Post,
|
||||||
posts::Post,
|
|
||||||
authors::{
|
|
||||||
Author,
|
|
||||||
AuthorGetOneParams,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
services::authors::*,
|
|
||||||
state::AppState,
|
state::AppState,
|
||||||
utils::pagination::{Pagination, PaginationQuery},
|
utils::pagination::{Pagination, PaginationQuery},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Clone)]
|
||||||
|
pub struct Author {
|
||||||
|
pub author_id: i32,
|
||||||
|
pub first_name: String,
|
||||||
|
pub last_name: String,
|
||||||
|
pub bio: Option<String>,
|
||||||
|
pub image: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Clone)]
|
||||||
|
pub struct AuthorGetOneParams {
|
||||||
|
pub id: i32,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct AuthorPostsResponse {
|
pub struct AuthorPostsResponse {
|
||||||
@@ -49,19 +55,39 @@ impl AuthorsRoute {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut state = app_state.lock().await;
|
let mut state = app_state.lock().await;
|
||||||
let cached = authors_cache::<Vec<Author>>(&mut state, String::from("all")).await;
|
let cached: Option<Vec<Author>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("authors:all"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
if let Some(authors) = cached {
|
if let Some(authors) = cached {
|
||||||
|
tracing::info!("grabbing all authors from cache");
|
||||||
return Ok(Json(authors));
|
return Ok(Json(authors));
|
||||||
}
|
}
|
||||||
|
|
||||||
match AuthorsDatasource::get_all(&state.database, pagination).await {
|
match AuthorsDatasource::get_all(&state.database, pagination).await {
|
||||||
Ok(authors) => {
|
Ok(authors) => {
|
||||||
set_authors_cache(
|
tracing::info!("grabbing all authors from the database");
|
||||||
&app_state,
|
if let a = &authors {
|
||||||
String::from("all"),
|
let author_cloned = a.clone();
|
||||||
authors.clone(),
|
let state = app_state.clone();
|
||||||
Expiration::EX(5),
|
|
||||||
);
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("authors:all"),
|
||||||
|
&author_cloned,
|
||||||
|
Some(Expiration::EX(5)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
}
|
||||||
Ok(Json(authors))
|
Ok(Json(authors))
|
||||||
}
|
}
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
@@ -73,21 +99,40 @@ impl AuthorsRoute {
|
|||||||
Path(params): Path<AuthorGetOneParams>,
|
Path(params): Path<AuthorGetOneParams>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let mut state = app_state.lock().await;
|
let mut state = app_state.lock().await;
|
||||||
let cached = authors_cache::<Author>(&mut state, params.id.to_string()).await;
|
let cached: Option<Author> = state
|
||||||
|
.cache
|
||||||
|
.get(format!("authors:{}", params.id))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
if let Some(author) = cached {
|
if let Some(author) = cached {
|
||||||
|
tracing::info!("grabbing one author from cache");
|
||||||
return Ok(Json(author));
|
return Ok(Json(author));
|
||||||
}
|
}
|
||||||
|
|
||||||
match AuthorsDatasource::get_one(&state.database, params.id).await {
|
match AuthorsDatasource::get_one(&state.database, params.id).await {
|
||||||
Ok(author) => {
|
Ok(author) => {
|
||||||
set_authors_cache(
|
tracing::info!("grabbing all authors from the database");
|
||||||
&app_state,
|
if let a = &author {
|
||||||
author.author_id.to_string(),
|
let author_cloned = a.clone();
|
||||||
author.clone(),
|
let state = app_state.clone();
|
||||||
Expiration::EX(5),
|
|
||||||
);
|
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
format!("authors:{}", author_cloned.author_id),
|
||||||
|
&author_cloned,
|
||||||
|
Some(Expiration::EX(5)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
}
|
||||||
Ok(Json(author))
|
Ok(Json(author))
|
||||||
}
|
}
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
datasources::comments::CommentsDatasource,
|
datasources::comments::CommentsDatasource,
|
||||||
models::comments::*,
|
|
||||||
state::AppState,
|
state::AppState,
|
||||||
utils::{
|
utils::{
|
||||||
|
datetime::*,
|
||||||
pagination::{Pagination, PaginationQuery},
|
pagination::{Pagination, PaginationQuery},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -14,6 +14,29 @@ use axum::{
|
|||||||
Json,
|
Json,
|
||||||
};
|
};
|
||||||
use cache::{Expiration, SetOptions};
|
use cache::{Expiration, SetOptions};
|
||||||
|
use chrono::Utc;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
|
pub struct CommentInputPayload {
|
||||||
|
pub name: String,
|
||||||
|
pub body: String,
|
||||||
|
pub post_id: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct CommentPathParams {
|
||||||
|
id: i32,
|
||||||
|
}
|
||||||
|
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
||||||
|
pub struct Comment {
|
||||||
|
pub comment_id: i32,
|
||||||
|
pub name: String,
|
||||||
|
pub body: String,
|
||||||
|
#[serde(serialize_with = "serialize_datetime")]
|
||||||
|
#[serde(deserialize_with = "deserialize_datetime")]
|
||||||
|
pub created_at: Option<chrono::DateTime<Utc>>,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct CommentsRoute;
|
pub struct CommentsRoute;
|
||||||
impl CommentsRoute {
|
impl CommentsRoute {
|
||||||
@@ -51,6 +74,7 @@ impl CommentsRoute {
|
|||||||
let state = app_state.clone();
|
let state = app_state.clone();
|
||||||
|
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
|
tracing::info!("update cache if key already exists!");
|
||||||
let mut s = state.lock().await;
|
let mut s = state.lock().await;
|
||||||
let _ = s
|
let _ = s
|
||||||
.cache
|
.cache
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
use super::format::{self, line, page};
|
|
||||||
use crate::{datasources::authors::AuthorsDatasource, state::AppState};
|
|
||||||
use gemi::{GeminiRequest, GeminiResponse, GeminiRouter, Params, State};
|
|
||||||
|
|
||||||
pub struct AuthorsGeminiRoutes;
|
|
||||||
impl AuthorsGeminiRoutes {
|
|
||||||
pub fn routes() -> gemi::Result<GeminiRouter<AppState>> {
|
|
||||||
let mut router = GeminiRouter::default();
|
|
||||||
router.add_route("/", Self::all)?;
|
|
||||||
router.add_route("/{id}", Self::one)?;
|
|
||||||
router.add_route("/{id}/posts", Self::one)?;
|
|
||||||
Ok(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn all(State(state): State<AppState>, request: GeminiRequest) -> GeminiResponse {
|
|
||||||
let p = match format::pagination(&request) {
|
|
||||||
Ok(p) => p,
|
|
||||||
Err(e) => return e,
|
|
||||||
};
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
let result = AuthorsDatasource::get_all(
|
|
||||||
&pool,
|
|
||||||
crate::utils::pagination::Pagination {
|
|
||||||
page: p.page,
|
|
||||||
limit: p.limit,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
match result {
|
|
||||||
Ok(authors) => {
|
|
||||||
let mut body = String::new();
|
|
||||||
for author in &authors {
|
|
||||||
body += &format!(
|
|
||||||
"=> /authors/{} {} {}\n",
|
|
||||||
author.author_id,
|
|
||||||
line(&author.first_name),
|
|
||||||
line(&author.last_name)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if authors.is_empty() {
|
|
||||||
body += "No authors found.\n";
|
|
||||||
}
|
|
||||||
body += &format::navigation("/authors", &p, authors.len() as i64 == p.limit);
|
|
||||||
page("Authors", &body)
|
|
||||||
}
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn one(
|
|
||||||
State(state): State<AppState>,
|
|
||||||
params: Params,
|
|
||||||
request: GeminiRequest,
|
|
||||||
) -> GeminiResponse {
|
|
||||||
let id = match format::id(¶ms) {
|
|
||||||
Ok(id) => id,
|
|
||||||
Err(e) => return e,
|
|
||||||
};
|
|
||||||
let p = match format::pagination(&request) {
|
|
||||||
Ok(p) => p,
|
|
||||||
Err(e) => return e,
|
|
||||||
};
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
let author = match AuthorsDatasource::get_one(&pool, id).await {
|
|
||||||
Ok(a) => a,
|
|
||||||
Err(e) => return format::error(e),
|
|
||||||
};
|
|
||||||
match AuthorsDatasource::get_authors_posts(
|
|
||||||
&pool,
|
|
||||||
id,
|
|
||||||
crate::utils::pagination::Pagination {
|
|
||||||
page: p.page,
|
|
||||||
limit: p.limit,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok((posts, total)) => {
|
|
||||||
let body = format!(
|
|
||||||
"{}\n\n## Posts\n{}{}",
|
|
||||||
line(author.bio.as_deref().unwrap_or("")),
|
|
||||||
format::posts(&posts),
|
|
||||||
format::navigation(&format!("/authors/{id}"), &p, p.page * p.limit < total)
|
|
||||||
);
|
|
||||||
page(
|
|
||||||
&format!("{} {}", author.first_name, author.last_name),
|
|
||||||
&body,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
use super::format::{self, line, page};
|
|
||||||
use crate::{
|
|
||||||
datasources::comments::CommentsDatasource, models::comments::Comment, state::AppState,
|
|
||||||
};
|
|
||||||
use gemi::{GeminiRequest, GeminiResponse, GeminiRouter, Params, State};
|
|
||||||
|
|
||||||
pub struct CommentsGeminiRoutes;
|
|
||||||
impl CommentsGeminiRoutes {
|
|
||||||
pub fn routes() -> gemi::Result<GeminiRouter<AppState>> {
|
|
||||||
let mut router = GeminiRouter::default();
|
|
||||||
router.add_route("/post/{id}", Self::post)?;
|
|
||||||
router.add_route("/index", Self::index)?;
|
|
||||||
Ok(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn post(State(state): State<AppState>, params: Params) -> GeminiResponse {
|
|
||||||
let id = match format::id(¶ms) {
|
|
||||||
Ok(id) => id,
|
|
||||||
Err(e) => return e,
|
|
||||||
};
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match CommentsDatasource::get_posts_comments(&pool, id).await {
|
|
||||||
Ok(comments) => page(
|
|
||||||
"Comments",
|
|
||||||
&format!(
|
|
||||||
"{}\n=> /posts/{id} Back to post\n=> {} Leave a comment on the web",
|
|
||||||
render(&comments),
|
|
||||||
format::web_url(&format!("/posts/{id}"))
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn index(State(state): State<AppState>, request: GeminiRequest) -> GeminiResponse {
|
|
||||||
let p = match format::pagination(&request) {
|
|
||||||
Ok(p) => p,
|
|
||||||
Err(e) => return e,
|
|
||||||
};
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
let result = CommentsDatasource::get_index_comments(
|
|
||||||
&pool,
|
|
||||||
crate::utils::pagination::Pagination {
|
|
||||||
page: p.page,
|
|
||||||
limit: p.limit,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
match result {
|
|
||||||
Ok(comments) => page(
|
|
||||||
"Recent comments",
|
|
||||||
&format!(
|
|
||||||
"{}{}",
|
|
||||||
render(&comments),
|
|
||||||
format::navigation("/comments/index", &p, comments.len() as i64 == p.limit)
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn render(comments: &[Comment]) -> String {
|
|
||||||
if comments.is_empty() {
|
|
||||||
return "No comments yet.\n".into();
|
|
||||||
}
|
|
||||||
comments
|
|
||||||
.iter()
|
|
||||||
.map(|c| {
|
|
||||||
format!(
|
|
||||||
"## {}\n{}\n{}\n\n",
|
|
||||||
line(&c.name),
|
|
||||||
c.created_at
|
|
||||||
.map(|d| d.format("%B %d, %Y").to_string())
|
|
||||||
.unwrap_or_default(),
|
|
||||||
line(&c.body)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
use crate::{models::posts::Post, utils::pagination::Pagination};
|
|
||||||
use gemi::{GeminiRequest, GeminiResponse, Params};
|
|
||||||
|
|
||||||
pub fn line(text: &str) -> String {
|
|
||||||
text.split_whitespace().collect::<Vec<_>>().join(" ")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn web_url(path: &str) -> String {
|
|
||||||
format!(
|
|
||||||
"{}{}",
|
|
||||||
std::env::var("BASE_URI_WEB")
|
|
||||||
.unwrap_or_else(|_| "https://wyattjmiller.com".into())
|
|
||||||
.trim_end_matches('/'),
|
|
||||||
path
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn page(title: &str, body: &str) -> GeminiResponse {
|
|
||||||
format!("# {}\n\n=> / Home\n=> /posts Blog\n=> /projects Projects\n=> /contact Contact\n\n{}\n\n## Elsewhere\n=> /authors Authors\n=> {} RSS\n=> {} Sitemap\n=> mailto:wjmiller2016@gmail.com Email me\n\n© {} Miller Web Solutions. All Rights Reserved. Hosted by Akamai.\n",
|
|
||||||
line(title), body, web_url("/rss"), web_url("/sitemap"), chrono::Utc::now().format("%Y")).into()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn posts(posts: &[Post]) -> String {
|
|
||||||
if posts.is_empty() {
|
|
||||||
return "No posts yet.\n".into();
|
|
||||||
}
|
|
||||||
posts
|
|
||||||
.iter()
|
|
||||||
.map(|p| {
|
|
||||||
let date = p
|
|
||||||
.publish_date
|
|
||||||
.or(p.created_at)
|
|
||||||
.map(|d| d.format("%B %d, %Y").to_string())
|
|
||||||
.unwrap_or_default();
|
|
||||||
format!(
|
|
||||||
"=> /posts/{} {}\n{} · {} {}\n\n",
|
|
||||||
p.post_id,
|
|
||||||
line(&p.title),
|
|
||||||
date,
|
|
||||||
line(p.first_name.as_deref().unwrap_or("")),
|
|
||||||
line(p.last_name.as_deref().unwrap_or(""))
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn id(params: &Params) -> Result<i32, GeminiResponse> {
|
|
||||||
params
|
|
||||||
.0
|
|
||||||
.get("id")
|
|
||||||
.and_then(|s| s.parse::<i32>().ok())
|
|
||||||
.filter(|id| *id > 0)
|
|
||||||
.ok_or_else(|| GeminiResponse::bad_request("Expected a positive numeric ID"))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pagination(request: &GeminiRequest) -> Result<Pagination, GeminiResponse> {
|
|
||||||
let mut result = Pagination { page: 1, limit: 12 };
|
|
||||||
for (key, value) in request.url.query_pairs() {
|
|
||||||
let target = match key.as_ref() {
|
|
||||||
"page" => &mut result.page,
|
|
||||||
"limit" => &mut result.limit,
|
|
||||||
_ => continue,
|
|
||||||
};
|
|
||||||
*target = value
|
|
||||||
.parse::<i64>()
|
|
||||||
.ok()
|
|
||||||
.filter(|n| *n > 0)
|
|
||||||
.ok_or_else(|| {
|
|
||||||
GeminiResponse::bad_request("page and limit must be positive integers")
|
|
||||||
})?;
|
|
||||||
}
|
|
||||||
if result.limit > 100 || result.page.checked_mul(result.limit).is_none() {
|
|
||||||
return Err(GeminiResponse::bad_request(
|
|
||||||
"Pagination out of range (maximum limit: 100)",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
Ok(result)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn navigation(path: &str, p: &Pagination, has_next: bool) -> String {
|
|
||||||
let mut result = format!("\nPage {}\n", p.page);
|
|
||||||
if p.page > 1 {
|
|
||||||
result += &format!(
|
|
||||||
"=> {path}?page={}&limit={} Previous page\n",
|
|
||||||
p.page - 1,
|
|
||||||
p.limit
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if has_next {
|
|
||||||
result += &format!(
|
|
||||||
"=> {path}?page={}&limit={} Next page\n",
|
|
||||||
p.page + 1,
|
|
||||||
p.limit
|
|
||||||
);
|
|
||||||
}
|
|
||||||
result
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn error(error: sqlx::Error) -> GeminiResponse {
|
|
||||||
match error {
|
|
||||||
sqlx::Error::RowNotFound => GeminiResponse::not_found("Not found"),
|
|
||||||
error => {
|
|
||||||
tracing::error!(%error, "Gemini database request failed");
|
|
||||||
GeminiResponse::temporary_failure("Unable to load this page. Please try again later.")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
use super::*;
|
|
||||||
|
|
||||||
fn request(query: &str) -> GeminiRequest {
|
|
||||||
let url = format!("gemini://localhost/authors?{query}")
|
|
||||||
.parse()
|
|
||||||
.unwrap();
|
|
||||||
GeminiRequest {
|
|
||||||
url,
|
|
||||||
path: "/authors".into(),
|
|
||||||
query: Some(query.into()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn pagination_rejects_invalid_and_overflowing_values() {
|
|
||||||
for query in [
|
|
||||||
"page=0",
|
|
||||||
"page=-1",
|
|
||||||
"limit=101",
|
|
||||||
"limit=no",
|
|
||||||
"page=9223372036854775807&limit=100",
|
|
||||||
] {
|
|
||||||
assert!(pagination(&request(query)).is_err(), "{query}");
|
|
||||||
}
|
|
||||||
let p = pagination(&request("page=2&limit=10")).ok().unwrap();
|
|
||||||
assert_eq!((p.page, p.limit), (2, 10));
|
|
||||||
let links = navigation("/authors/1", &p, true);
|
|
||||||
assert!(links.contains("/authors/1?page=1&limit=10"));
|
|
||||||
assert!(links.contains("/authors/1?page=3&limit=10"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn metadata_cannot_inject_gemtext_lines() {
|
|
||||||
assert_eq!(line("Title\r\n=> /evil link"), "Title => /evil link");
|
|
||||||
let response = page("Title\n# Injected", "Article body");
|
|
||||||
let body = String::from_utf8(response.body).unwrap();
|
|
||||||
assert!(body.starts_with("# Title # Injected\n"));
|
|
||||||
assert!(body.contains("=> /posts Blog\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn missing_rows_and_database_failures_have_distinct_statuses() {
|
|
||||||
assert_eq!(error(sqlx::Error::RowNotFound).status_code.to_u8(), 51);
|
|
||||||
assert_eq!(error(sqlx::Error::PoolClosed).status_code.to_u8(), 40);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
pub mod authors;
|
|
||||||
pub mod comments;
|
|
||||||
mod format;
|
|
||||||
pub mod posts;
|
|
||||||
pub mod projects;
|
|
||||||
pub mod root;
|
|
||||||
|
|
||||||
use crate::state::AppState;
|
|
||||||
use gemi::GeminiRouter;
|
|
||||||
|
|
||||||
pub fn routes() -> gemi::Result<GeminiRouter<AppState>> {
|
|
||||||
let mut router = GeminiRouter::default();
|
|
||||||
router.nest("/", root::RootGeminiRoutes::routes()?)?;
|
|
||||||
router.nest("/posts", posts::PostsGeminiRoutes::routes()?)?;
|
|
||||||
router.nest("/authors", authors::AuthorsGeminiRoutes::routes()?)?;
|
|
||||||
router.nest("/projects", projects::ProjectsGeminiRoutes::routes()?)?;
|
|
||||||
router.nest("/comments", comments::CommentsGeminiRoutes::routes()?)?;
|
|
||||||
Ok(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests {
|
|
||||||
#[test]
|
|
||||||
fn routers_compose_without_conflicts() {
|
|
||||||
assert!(super::routes().is_ok());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
use super::format::{self, page, posts};
|
|
||||||
use crate::{datasources::posts::PostsDatasource, state::AppState};
|
|
||||||
use gemi::{GeminiResponse, GeminiRouter, Params, State};
|
|
||||||
|
|
||||||
pub struct PostsGeminiRoutes;
|
|
||||||
impl PostsGeminiRoutes {
|
|
||||||
pub fn routes() -> gemi::Result<GeminiRouter<AppState>> {
|
|
||||||
let mut router = GeminiRouter::default();
|
|
||||||
router.add_route("/", Self::index)?;
|
|
||||||
router.add_route("/{id}", Self::get_one)?;
|
|
||||||
router.add_route("/all", Self::all)?;
|
|
||||||
router.add_route("/recent", Self::recent)?;
|
|
||||||
router.add_route("/featured", Self::featured)?;
|
|
||||||
router.add_route("/popular", Self::popular)?;
|
|
||||||
router.add_route("/hot", Self::hot)?;
|
|
||||||
Ok(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn index(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
let result = tokio::try_join!(
|
|
||||||
PostsDatasource::get_featured(&pool),
|
|
||||||
PostsDatasource::get_recent(&pool),
|
|
||||||
PostsDatasource::get_popular(&pool)
|
|
||||||
);
|
|
||||||
match result {
|
|
||||||
Ok((featured, recent, popular)) => page("Blog", &format!("## Featured Posts\nIgnite the impossible\n\n{}## Recent Posts\nNow with 100% fresh perspective\n\n{}## Popular Posts\nContent may cause uncontrollable reading\n\n{}=> /posts/all All posts\n=> /posts/hot Hot posts", posts(&featured), posts(&recent), posts(&popular))),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_one(State(state): State<AppState>, params: Params) -> GeminiResponse {
|
|
||||||
let id = match format::id(¶ms) {
|
|
||||||
Ok(id) => id,
|
|
||||||
Err(e) => return e,
|
|
||||||
};
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match PostsDatasource::get_one(&pool, id).await {
|
|
||||||
Ok(post) => {
|
|
||||||
let name = format::line(&format!(
|
|
||||||
"{} {}",
|
|
||||||
post.first_name.as_deref().unwrap_or(""),
|
|
||||||
post.last_name.as_deref().unwrap_or("")
|
|
||||||
));
|
|
||||||
let mut body = String::new();
|
|
||||||
if let Some(author_id) = post.author_id {
|
|
||||||
body += &format!("=> /authors/{author_id} By {name}\n");
|
|
||||||
}
|
|
||||||
if let Some(date) = post.publish_date.or(post.created_at) {
|
|
||||||
body += &format!("Published {}\n", date.format("%B %d, %Y"));
|
|
||||||
}
|
|
||||||
if post.is_featured == Some(true) {
|
|
||||||
body += "Featured post\n";
|
|
||||||
}
|
|
||||||
body += "\n";
|
|
||||||
match post
|
|
||||||
.body_gemtext
|
|
||||||
.as_deref()
|
|
||||||
.filter(|s| !s.trim().is_empty())
|
|
||||||
{
|
|
||||||
Some(gemtext) => body += gemtext,
|
|
||||||
None => {
|
|
||||||
body += &format!(
|
|
||||||
"This post is available on the web.\n=> {} Read this post",
|
|
||||||
format::web_url(&format!("/posts/{id}"))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
body += &format!("\n\n=> /comments/post/{id} Comments\n=> /posts Back to the blog");
|
|
||||||
page(&post.title, &body)
|
|
||||||
}
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async fn all(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match PostsDatasource::get_all(&pool).await {
|
|
||||||
Ok(items) => page("All posts", &posts(&items)),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async fn recent(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match PostsDatasource::get_recent(&pool).await {
|
|
||||||
Ok(items) => page("Recent Posts", &posts(&items)),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async fn featured(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match PostsDatasource::get_featured(&pool).await {
|
|
||||||
Ok(items) => page("Featured Posts", &posts(&items)),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async fn popular(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match PostsDatasource::get_popular(&pool).await {
|
|
||||||
Ok(items) => page("Popular Posts", &posts(&items)),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async fn hot(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match PostsDatasource::get_hot(&pool).await {
|
|
||||||
Ok(items) => page("Hot Posts", &posts(&items)),
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
use super::format::{self, line, page};
|
|
||||||
use crate::{datasources::projects::ProjectsDatasource, state::AppState};
|
|
||||||
use gemi::{GeminiResponse, GeminiRouter, State};
|
|
||||||
|
|
||||||
pub struct ProjectsGeminiRoutes;
|
|
||||||
impl ProjectsGeminiRoutes {
|
|
||||||
pub fn routes() -> gemi::Result<GeminiRouter<AppState>> {
|
|
||||||
let mut router = GeminiRouter::default();
|
|
||||||
router.add_route("/", Self::all)?;
|
|
||||||
Ok(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn all(State(state): State<AppState>) -> GeminiResponse {
|
|
||||||
let pool = state.lock().await.database.clone();
|
|
||||||
match ProjectsDatasource::get_all(&pool).await {
|
|
||||||
Ok(projects) => {
|
|
||||||
let mut body = String::from("Here's a collection of software and electronics projects I've been tinkering with during my free time - some are ongoing adventures, others are finished experiments!\n\n");
|
|
||||||
if projects.is_empty() {
|
|
||||||
body += "No projects yet.\n";
|
|
||||||
}
|
|
||||||
for project in projects {
|
|
||||||
body += &format!(
|
|
||||||
"## {}\n{}\nTechnology: {}\nStatus: {}\n",
|
|
||||||
line(&project.title),
|
|
||||||
line(&project.summary),
|
|
||||||
line(&project.tech),
|
|
||||||
if project.wip.unwrap_or(true) {
|
|
||||||
"Work in progress"
|
|
||||||
} else {
|
|
||||||
"Complete"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
if let Some(repo) = project
|
|
||||||
.repo
|
|
||||||
.filter(|r| !r.is_empty() && !r.chars().any(char::is_whitespace))
|
|
||||||
{
|
|
||||||
body += &format!("=> {repo} Repository\n");
|
|
||||||
}
|
|
||||||
body += "\n";
|
|
||||||
}
|
|
||||||
page("Projects", &body)
|
|
||||||
}
|
|
||||||
Err(e) => format::error(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
use super::format::{page, web_url};
|
|
||||||
use crate::state::AppState;
|
|
||||||
use gemi::{GeminiResponse, GeminiRouter};
|
|
||||||
|
|
||||||
pub struct RootGeminiRoutes;
|
|
||||||
impl RootGeminiRoutes {
|
|
||||||
pub fn routes() -> gemi::Result<GeminiRouter<AppState>> {
|
|
||||||
let mut router = GeminiRouter::default();
|
|
||||||
router.add_route("/", Self::root)?;
|
|
||||||
router.add_route("/contact", Self::contact)?;
|
|
||||||
router.add_route("/health", Self::health)?;
|
|
||||||
Ok(router)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn root() -> GeminiResponse {
|
|
||||||
page("Heya! I'm Wyatt", "## Thanks for checking out this corner of the Internet!\n\nI design and develop software for developers, for end users, and everyone in between")
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn contact() -> GeminiResponse {
|
|
||||||
page("Contact", &format!("Got a question? Here to yell at me? Send me something!\n\n=> mailto:wjmiller2016@gmail.com Email me\n=> {} Contact form on the web", web_url("/contact")))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn health() -> GeminiResponse {
|
|
||||||
GeminiResponse::text("OK")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
pub mod authors;
|
|
||||||
pub mod comments;
|
|
||||||
pub mod posts;
|
|
||||||
pub mod projects;
|
|
||||||
pub mod root;
|
|
||||||
@@ -1,253 +0,0 @@
|
|||||||
use crate::{
|
|
||||||
datasources::posts::PostsDatasource,
|
|
||||||
models::posts::*,
|
|
||||||
services::posts::*,
|
|
||||||
state::AppState,
|
|
||||||
utils::{
|
|
||||||
rss,
|
|
||||||
sitemap::{self, SitemapEntry},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use axum::http::{HeaderMap, HeaderValue};
|
|
||||||
use axum::{
|
|
||||||
extract::{Path, State},
|
|
||||||
http::{header, StatusCode},
|
|
||||||
response::IntoResponse,
|
|
||||||
routing::get,
|
|
||||||
Json, Router,
|
|
||||||
};
|
|
||||||
use cache::Expiration;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
pub struct PostsRoute;
|
|
||||||
impl PostsRoute {
|
|
||||||
pub fn routes(app_state: &AppState) -> Router {
|
|
||||||
// add more post routes here!
|
|
||||||
Router::new()
|
|
||||||
.route("/posts/all", get(PostsRoute::get_all))
|
|
||||||
.route("/posts/{id}", get(PostsRoute::get_one))
|
|
||||||
.route("/posts/recent", get(PostsRoute::get_recent_posts))
|
|
||||||
.route("/posts/popular", get(PostsRoute::get_popular_posts))
|
|
||||||
.route("/posts/hot", get(PostsRoute::get_hot_posts))
|
|
||||||
.route("/posts/featured", get(PostsRoute::get_featured_posts))
|
|
||||||
.route("/posts/rss", get(PostsRoute::get_rss_posts))
|
|
||||||
.route("/posts/sitemap", get(PostsRoute::get_sitemap))
|
|
||||||
.with_state(app_state.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
// get all posts
|
|
||||||
async fn get_all(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = posts_cache::<Vec<Post>>(&mut state, String::from("all")).await;
|
|
||||||
if let Some(posts) = cached {
|
|
||||||
return Ok(Json(posts));
|
|
||||||
};
|
|
||||||
|
|
||||||
match PostsDatasource::get_all(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
set_posts_cache(
|
|
||||||
&app_state,
|
|
||||||
String::from("all"),
|
|
||||||
posts.clone(),
|
|
||||||
Expiration::EX(10),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(posts))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get one post
|
|
||||||
async fn get_one(
|
|
||||||
State(app_state): State<AppState>,
|
|
||||||
Path(params): Path<PostGetOneParams>,
|
|
||||||
) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = posts_cache::<PostFeaturedVariant>(&mut state, params.id.to_string()).await;
|
|
||||||
|
|
||||||
if let Some(post) = cached {
|
|
||||||
return Ok(Json(post));
|
|
||||||
};
|
|
||||||
|
|
||||||
match PostsDatasource::get_one(&state.database, params.id).await {
|
|
||||||
Ok(post) => {
|
|
||||||
set_posts_cache(
|
|
||||||
&app_state,
|
|
||||||
params.id.to_string(),
|
|
||||||
post.clone(),
|
|
||||||
Expiration::EX(10),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(post))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get recent posts
|
|
||||||
async fn get_recent_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = posts_cache::<Vec<Post>>(&mut state, String::from("recent")).await;
|
|
||||||
|
|
||||||
if let Some(posts) = cached {
|
|
||||||
return Ok(Json(posts));
|
|
||||||
};
|
|
||||||
|
|
||||||
match PostsDatasource::get_recent(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
set_posts_cache(
|
|
||||||
&app_state,
|
|
||||||
String::from("recent"),
|
|
||||||
posts.clone(),
|
|
||||||
Expiration::EX(5),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(posts))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the top three posts with the highest view count
|
|
||||||
async fn get_popular_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = posts_cache::<Vec<Post>>(&mut state, String::from("popular")).await;
|
|
||||||
|
|
||||||
if let Some(posts) = cached {
|
|
||||||
return Ok(Json(posts));
|
|
||||||
};
|
|
||||||
|
|
||||||
match PostsDatasource::get_popular(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
set_posts_cache(
|
|
||||||
&app_state,
|
|
||||||
String::from("popular"),
|
|
||||||
posts.clone(),
|
|
||||||
Expiration::EX(5),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(posts))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the top three posts with the most comments
|
|
||||||
async fn get_hot_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = posts_cache::<Vec<Post>>(&mut state, String::from("hot")).await;
|
|
||||||
|
|
||||||
if let Some(posts) = cached {
|
|
||||||
return Ok(Json(posts));
|
|
||||||
};
|
|
||||||
|
|
||||||
match PostsDatasource::get_hot(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
set_posts_cache(
|
|
||||||
&app_state,
|
|
||||||
String::from("hot"),
|
|
||||||
posts.clone(),
|
|
||||||
Expiration::EX(5),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(posts))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get posts that are featured
|
|
||||||
async fn get_featured_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = posts_cache::<Vec<Post>>(&mut state, String::from("featured")).await;
|
|
||||||
|
|
||||||
if let Some(posts) = cached {
|
|
||||||
return Ok(Json(posts));
|
|
||||||
};
|
|
||||||
|
|
||||||
match PostsDatasource::get_featured(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
set_posts_cache(
|
|
||||||
&app_state,
|
|
||||||
String::from("featured"),
|
|
||||||
posts.clone(),
|
|
||||||
Expiration::EX(5),
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(Json(posts))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// get rss posts
|
|
||||||
async fn get_rss_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let state = app_state.lock().await;
|
|
||||||
|
|
||||||
match PostsDatasource::get_all(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
let web_url =
|
|
||||||
std::env::var("BASE_URI_WEB").expect("Environment BASE_URI_WEB variable found");
|
|
||||||
let mapped_posts: HashMap<String, Post> = posts
|
|
||||||
.into_iter()
|
|
||||||
.map(|post| (post.post_id.to_string(), post))
|
|
||||||
.collect();
|
|
||||||
let xml: String = rss::generate_rss(
|
|
||||||
"Wyatt's blog",
|
|
||||||
"Wyatt and friends",
|
|
||||||
web_url.as_str(),
|
|
||||||
&mapped_posts,
|
|
||||||
);
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert(
|
|
||||||
header::CONTENT_TYPE,
|
|
||||||
HeaderValue::from_static("application/xml"),
|
|
||||||
);
|
|
||||||
(headers, xml)
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert("Content-Type", HeaderValue::from_static("text/plain"));
|
|
||||||
(headers, e.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_sitemap(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let state = app_state.lock().await;
|
|
||||||
// let cached: Option<Vec<Post>> = None; // TODO: maybe implement cache, later??
|
|
||||||
|
|
||||||
match PostsDatasource::get_all(&state.database).await {
|
|
||||||
Ok(posts) => {
|
|
||||||
let web_url =
|
|
||||||
std::env::var("BASE_URI_WEB").expect("Environment BASE_URI_WEB variable found");
|
|
||||||
let mut entries: HashMap<String, SitemapEntry> = posts
|
|
||||||
.into_iter()
|
|
||||||
.map(|p| {
|
|
||||||
(
|
|
||||||
p.post_id.to_string(),
|
|
||||||
SitemapEntry {
|
|
||||||
location: format!("{}/posts/{}", web_url, p.post_id.to_string()),
|
|
||||||
lastmod: p.created_at.unwrap_or_else(|| chrono::Utc::now()),
|
|
||||||
},
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
sitemap::get_static_pages(&mut entries, &web_url);
|
|
||||||
let xml: String = sitemap::generate_sitemap(&entries);
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert(
|
|
||||||
header::CONTENT_TYPE,
|
|
||||||
HeaderValue::from_static("application/xml"),
|
|
||||||
);
|
|
||||||
(headers, xml)
|
|
||||||
}
|
|
||||||
Err(e) => {
|
|
||||||
let mut headers = HeaderMap::new();
|
|
||||||
headers.insert("Content-Type", HeaderValue::from_static("text/plain"));
|
|
||||||
(headers, e.to_string())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
use crate::{
|
|
||||||
datasources::projects::ProjectsDatasource,
|
|
||||||
state::AppState,
|
|
||||||
services::projects::*,
|
|
||||||
models::projects::*
|
|
||||||
};
|
|
||||||
use axum::{
|
|
||||||
extract::State,
|
|
||||||
http::StatusCode,
|
|
||||||
response::IntoResponse,
|
|
||||||
routing::get,
|
|
||||||
Json,
|
|
||||||
Router
|
|
||||||
};
|
|
||||||
use cache::Expiration;
|
|
||||||
|
|
||||||
pub struct ProjectsRoute;
|
|
||||||
impl ProjectsRoute {
|
|
||||||
pub fn routes(app_state: &AppState) -> Router {
|
|
||||||
Router::new()
|
|
||||||
.route("/projects", get(ProjectsRoute::get_all))
|
|
||||||
.with_state(app_state.clone())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_all(State(app_state): State<AppState>) -> impl IntoResponse {
|
|
||||||
let mut state = app_state.lock().await;
|
|
||||||
let cached = projects_cache::<Vec<Project>>(&mut state, String::from("all")).await;
|
|
||||||
|
|
||||||
if let Some(projects) = cached {
|
|
||||||
return Ok(Json(projects));
|
|
||||||
};
|
|
||||||
|
|
||||||
match ProjectsDatasource::get_all(&state.database).await {
|
|
||||||
Ok(projects) => {
|
|
||||||
if let p = &projects {
|
|
||||||
let projects = p.clone();
|
|
||||||
set_projects_cache(
|
|
||||||
&app_state,
|
|
||||||
String::from("all"),
|
|
||||||
projects.clone(),
|
|
||||||
Expiration::EX(10),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(Json(projects))
|
|
||||||
}
|
|
||||||
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
pub mod http;
|
pub mod authors;
|
||||||
pub mod gemini;
|
pub mod comments;
|
||||||
|
pub mod posts;
|
||||||
|
pub mod projects;
|
||||||
|
pub mod root;
|
||||||
@@ -0,0 +1,407 @@
|
|||||||
|
use crate::{
|
||||||
|
datasources::posts::PostsDatasource,
|
||||||
|
state::AppState,
|
||||||
|
utils::{
|
||||||
|
datetime::*,
|
||||||
|
rss,
|
||||||
|
sitemap::{self, SitemapEntry},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use axum::http::{HeaderMap, HeaderValue};
|
||||||
|
use axum::{
|
||||||
|
extract::{Path, State},
|
||||||
|
http::{header, StatusCode},
|
||||||
|
response::IntoResponse,
|
||||||
|
routing::get,
|
||||||
|
Json, Router,
|
||||||
|
};
|
||||||
|
use cache::Expiration;
|
||||||
|
use chrono::Utc;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
||||||
|
pub struct Post {
|
||||||
|
pub post_id: i32,
|
||||||
|
pub author_id: Option<i32>,
|
||||||
|
pub first_name: Option<String>,
|
||||||
|
pub last_name: Option<String>,
|
||||||
|
pub title: String,
|
||||||
|
pub body: String,
|
||||||
|
#[serde(serialize_with = "serialize_datetime")]
|
||||||
|
#[serde(deserialize_with = "deserialize_datetime")]
|
||||||
|
pub created_at: Option<chrono::DateTime<Utc>>,
|
||||||
|
#[serde(serialize_with = "serialize_datetime")]
|
||||||
|
#[serde(deserialize_with = "deserialize_datetime")]
|
||||||
|
pub publish_date: Option<chrono::DateTime<Utc>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
||||||
|
pub struct PostFeaturedVariant {
|
||||||
|
pub post_id: i32,
|
||||||
|
pub author_id: Option<i32>,
|
||||||
|
pub first_name: Option<String>,
|
||||||
|
pub last_name: Option<String>,
|
||||||
|
pub title: String,
|
||||||
|
pub body: String,
|
||||||
|
#[serde(serialize_with = "serialize_datetime")]
|
||||||
|
#[serde(deserialize_with = "deserialize_datetime")]
|
||||||
|
pub created_at: Option<chrono::DateTime<Utc>>,
|
||||||
|
#[serde(serialize_with = "serialize_datetime")]
|
||||||
|
#[serde(deserialize_with = "deserialize_datetime")]
|
||||||
|
pub publish_date: Option<chrono::DateTime<Utc>>,
|
||||||
|
pub is_featured: Option<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct PostGetOneParams {
|
||||||
|
pub id: i32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct PostsRoute;
|
||||||
|
impl PostsRoute {
|
||||||
|
pub fn routes(app_state: &AppState) -> Router {
|
||||||
|
// add more post routes here!
|
||||||
|
Router::new()
|
||||||
|
.route("/posts/all", get(PostsRoute::get_all))
|
||||||
|
.route("/posts/{id}", get(PostsRoute::get_one))
|
||||||
|
.route("/posts/recent", get(PostsRoute::get_recent_posts))
|
||||||
|
.route("/posts/popular", get(PostsRoute::get_popular_posts))
|
||||||
|
.route("/posts/hot", get(PostsRoute::get_hot_posts))
|
||||||
|
.route("/posts/featured", get(PostsRoute::get_featured_posts))
|
||||||
|
.route("/posts/rss", get(PostsRoute::get_rss_posts))
|
||||||
|
.route("/posts/sitemap", get(PostsRoute::get_sitemap))
|
||||||
|
.with_state(app_state.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
// get all posts
|
||||||
|
async fn get_all(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<Vec<Post>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("posts:all"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(posts) = cached {
|
||||||
|
tracing::info!("grabbing all posts from cache");
|
||||||
|
return Ok(Json(posts));
|
||||||
|
};
|
||||||
|
|
||||||
|
match PostsDatasource::get_all(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
tracing::info!("grabbing all posts from database");
|
||||||
|
if let p = &posts {
|
||||||
|
let posts = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("posts:all"),
|
||||||
|
&posts,
|
||||||
|
Some(Expiration::EX(10)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(posts))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get one post
|
||||||
|
async fn get_one(
|
||||||
|
State(app_state): State<AppState>,
|
||||||
|
Path(params): Path<PostGetOneParams>,
|
||||||
|
) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<PostFeaturedVariant> = state
|
||||||
|
.cache
|
||||||
|
.get(format!("posts:{}", params.id))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(post) = cached {
|
||||||
|
tracing::info!("grabbing one post from cache");
|
||||||
|
return Ok(Json(post));
|
||||||
|
};
|
||||||
|
|
||||||
|
match PostsDatasource::get_one(&state.database, params.id).await {
|
||||||
|
Ok(post) => {
|
||||||
|
tracing::info!("grabbing one post from database");
|
||||||
|
if let p = &post {
|
||||||
|
let post = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
format!("posts:{}", params.id),
|
||||||
|
&post,
|
||||||
|
Some(Expiration::EX(10)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(post))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get recent posts
|
||||||
|
async fn get_recent_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<Vec<Post>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("posts:recent"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(posts) = cached {
|
||||||
|
tracing::info!("grabbing recent posts from cache");
|
||||||
|
return Ok(Json(posts));
|
||||||
|
};
|
||||||
|
|
||||||
|
match PostsDatasource::get_recent(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
tracing::info!("grabbing recent posts from database");
|
||||||
|
if let p = &posts {
|
||||||
|
let posts = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("posts:recent"),
|
||||||
|
&posts,
|
||||||
|
Some(Expiration::EX(5)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(posts))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the top three posts with the highest view count
|
||||||
|
async fn get_popular_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<Vec<Post>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("posts:popular"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(posts) = cached {
|
||||||
|
tracing::info!("grabbing popular posts from cache");
|
||||||
|
return Ok(Json(posts));
|
||||||
|
};
|
||||||
|
|
||||||
|
match PostsDatasource::get_popular(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
tracing::info!("grabbing popular posts from database");
|
||||||
|
if let p = &posts {
|
||||||
|
let posts = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("posts:popular"),
|
||||||
|
&posts,
|
||||||
|
Some(Expiration::EX(5)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(posts))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the top three posts with the most comments
|
||||||
|
async fn get_hot_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<Vec<Post>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("posts:hot"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(posts) = cached {
|
||||||
|
tracing::info!("grabbing hot posts from cache");
|
||||||
|
return Ok(Json(posts));
|
||||||
|
};
|
||||||
|
|
||||||
|
match PostsDatasource::get_hot(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
tracing::info!("grabbing hot posts from database");
|
||||||
|
if let p = &posts {
|
||||||
|
let posts = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("posts:hot"),
|
||||||
|
&posts,
|
||||||
|
Some(Expiration::EX(5)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(posts))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get posts that are featured
|
||||||
|
async fn get_featured_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<Vec<Post>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("posts:featured"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(posts) = cached {
|
||||||
|
tracing::info!("grabbing featured posts from cache");
|
||||||
|
return Ok(Json(posts));
|
||||||
|
};
|
||||||
|
|
||||||
|
match PostsDatasource::get_featured(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
tracing::info!("grabbing featured posts from database");
|
||||||
|
if let p = &posts {
|
||||||
|
let posts = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("posts:featured"),
|
||||||
|
&posts,
|
||||||
|
Some(Expiration::EX(5)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(posts))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get rss posts
|
||||||
|
async fn get_rss_posts(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let state = app_state.lock().await;
|
||||||
|
|
||||||
|
match PostsDatasource::get_all(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
let web_url =
|
||||||
|
std::env::var("BASE_URI_WEB").expect("Environment BASE_URI_WEB variable found");
|
||||||
|
let mapped_posts: HashMap<String, Post> = posts
|
||||||
|
.into_iter()
|
||||||
|
.map(|post| (post.post_id.to_string(), post))
|
||||||
|
.collect();
|
||||||
|
let xml: String = rss::generate_rss(
|
||||||
|
"Wyatt's blog",
|
||||||
|
"Wyatt and friends",
|
||||||
|
web_url.as_str(),
|
||||||
|
&mapped_posts,
|
||||||
|
);
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
header::CONTENT_TYPE,
|
||||||
|
HeaderValue::from_static("application/xml"),
|
||||||
|
);
|
||||||
|
(headers, xml)
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert("Content-Type", HeaderValue::from_static("text/plain"));
|
||||||
|
(headers, e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_sitemap(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let state = app_state.lock().await;
|
||||||
|
// let cached: Option<Vec<Post>> = None; // TODO: maybe implement cache, later??
|
||||||
|
|
||||||
|
match PostsDatasource::get_all(&state.database).await {
|
||||||
|
Ok(posts) => {
|
||||||
|
let web_url =
|
||||||
|
std::env::var("BASE_URI_WEB").expect("Environment BASE_URI_WEB variable found");
|
||||||
|
let mut entries: HashMap<String, SitemapEntry> = posts
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| {
|
||||||
|
(
|
||||||
|
p.post_id.to_string(),
|
||||||
|
SitemapEntry {
|
||||||
|
location: format!("{}/posts/{}", web_url, p.post_id.to_string()),
|
||||||
|
lastmod: p.created_at.unwrap_or_else(|| chrono::Utc::now()),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
sitemap::get_static_pages(&mut entries, &web_url);
|
||||||
|
let xml: String = sitemap::generate_sitemap(&entries);
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert(
|
||||||
|
header::CONTENT_TYPE,
|
||||||
|
HeaderValue::from_static("application/xml"),
|
||||||
|
);
|
||||||
|
(headers, xml)
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert("Content-Type", HeaderValue::from_static("text/plain"));
|
||||||
|
(headers, e.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
use crate::{datasources::projects::ProjectsDatasource, state::AppState, utils::datetime::*};
|
||||||
|
use axum::{extract::State, http::StatusCode, response::IntoResponse, routing::get, Json, Router};
|
||||||
|
use cache::Expiration;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(sqlx::FromRow, Deserialize, Serialize, Debug, Clone)]
|
||||||
|
pub struct Project {
|
||||||
|
pub project_id: i32,
|
||||||
|
pub title: String,
|
||||||
|
pub repo: Option<String>,
|
||||||
|
pub summary: String,
|
||||||
|
pub description: Option<String>,
|
||||||
|
pub tech: String,
|
||||||
|
pub wip: Option<bool>,
|
||||||
|
#[serde(serialize_with = "serialize_datetime")]
|
||||||
|
#[serde(deserialize_with = "deserialize_datetime")]
|
||||||
|
pub created_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||||
|
pub images: Option<Vec<String>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ProjectsRoute;
|
||||||
|
impl ProjectsRoute {
|
||||||
|
pub fn routes(app_state: &AppState) -> Router {
|
||||||
|
Router::new()
|
||||||
|
.route("/projects", get(ProjectsRoute::get_all))
|
||||||
|
.with_state(app_state.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_all(State(app_state): State<AppState>) -> impl IntoResponse {
|
||||||
|
let mut state = app_state.lock().await;
|
||||||
|
let cached: Option<Vec<Project>> = state
|
||||||
|
.cache
|
||||||
|
.get(String::from("projects:all"))
|
||||||
|
.await
|
||||||
|
.unwrap_or(None);
|
||||||
|
|
||||||
|
if let Some(projects) = cached {
|
||||||
|
tracing::info!("grabbing all projects from cache");
|
||||||
|
return Ok(Json(projects));
|
||||||
|
};
|
||||||
|
|
||||||
|
match ProjectsDatasource::get_all(&state.database).await {
|
||||||
|
Ok(projects) => {
|
||||||
|
tracing::info!("grabbing all projects from database");
|
||||||
|
if let p = &projects {
|
||||||
|
let projects = p.clone();
|
||||||
|
let state = app_state.clone();
|
||||||
|
|
||||||
|
tracing::info!("storing database data in cache");
|
||||||
|
tokio::spawn(async move {
|
||||||
|
let mut s = state.lock().await;
|
||||||
|
let _ = s
|
||||||
|
.cache
|
||||||
|
.set(
|
||||||
|
String::from("projects:all"),
|
||||||
|
&projects,
|
||||||
|
Some(Expiration::EX(10)),
|
||||||
|
None,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Json(projects))
|
||||||
|
}
|
||||||
|
Err(e) => Err((StatusCode::INTERNAL_SERVER_ERROR, e.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
File renamed without changes.
@@ -1,35 +0,0 @@
|
|||||||
use cache::Expiration;
|
|
||||||
use crate::state::{AppInternalState, AppState};
|
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
pub async fn authors_cache<T: DeserializeOwned>(
|
|
||||||
app_state: &mut AppInternalState,
|
|
||||||
key: String,
|
|
||||||
) -> Option<T> {
|
|
||||||
app_state
|
|
||||||
.cache
|
|
||||||
.get(format!("authors:{key}"))
|
|
||||||
.await
|
|
||||||
.unwrap_or(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_authors_cache<T>(app_state: &AppState, key: String, value: T, expiration: Expiration)
|
|
||||||
where
|
|
||||||
T: Serialize + DeserializeOwned + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
let app_state = app_state.clone();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
let mut s = app_state.lock().await;
|
|
||||||
let _ = s
|
|
||||||
.cache
|
|
||||||
.set(
|
|
||||||
format!("authors:{key}"),
|
|
||||||
&value,
|
|
||||||
Some(expiration),
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
pub mod authors;
|
|
||||||
pub mod posts;
|
|
||||||
pub mod projects;
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
use crate::state::{AppInternalState, AppState};
|
|
||||||
use cache::Expiration;
|
|
||||||
use serde::{de::DeserializeOwned, Serialize};
|
|
||||||
|
|
||||||
pub async fn posts_cache<T: DeserializeOwned>(
|
|
||||||
app_state: &mut AppInternalState,
|
|
||||||
key: String,
|
|
||||||
) -> Option<T> {
|
|
||||||
app_state
|
|
||||||
.cache
|
|
||||||
.get(format!("posts:{key}"))
|
|
||||||
.await
|
|
||||||
.unwrap_or(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_posts_cache<T>(app_state: &AppState, key: String, value: T, expiration: Expiration)
|
|
||||||
where
|
|
||||||
T: Serialize + DeserializeOwned + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
let app_state = app_state.clone();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
let mut s = app_state.lock().await;
|
|
||||||
let _ = s
|
|
||||||
.cache
|
|
||||||
.set(
|
|
||||||
format!("posts:{key}"),
|
|
||||||
&value,
|
|
||||||
Some(expiration),
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
use cache::Expiration;
|
|
||||||
use crate::state::{AppInternalState, AppState};
|
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
pub async fn projects_cache<T: DeserializeOwned>(
|
|
||||||
app_state: &mut AppInternalState,
|
|
||||||
key: String,
|
|
||||||
) -> Option<T> {
|
|
||||||
app_state
|
|
||||||
.cache
|
|
||||||
.get(format!("projects:{key}"))
|
|
||||||
.await
|
|
||||||
.unwrap_or(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_projects_cache<T>(app_state: &AppState, key: String, value: T, expiration: Expiration)
|
|
||||||
where
|
|
||||||
T: Serialize + DeserializeOwned + Send + Sync + 'static,
|
|
||||||
{
|
|
||||||
let app_state = app_state.clone();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
let mut s = app_state.lock().await;
|
|
||||||
let _ = s
|
|
||||||
.cache
|
|
||||||
.set(
|
|
||||||
format!("projects:{key}"),
|
|
||||||
&value,
|
|
||||||
Some(expiration),
|
|
||||||
None,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::models::posts;
|
use crate::routes::posts;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use xml::escape::escape_str_pcdata;
|
use xml::escape::escape_str_pcdata;
|
||||||
|
|
||||||
|
|||||||
Generated
+14
-54
@@ -727,7 +727,7 @@ version = "0.69.5"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"itertools",
|
"itertools",
|
||||||
@@ -744,12 +744,6 @@ dependencies = [
|
|||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "1.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.9.1"
|
version = "2.9.1"
|
||||||
@@ -1462,12 +1456,6 @@ dependencies = [
|
|||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gemtext"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2eb76a04b598440b386caa0893dd7b8228a4b555692d2e4f04636a238b5c4b5b"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "generic-array"
|
name = "generic-array"
|
||||||
version = "0.14.7"
|
version = "0.14.7"
|
||||||
@@ -2006,7 +1994,7 @@ version = "0.7.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
@@ -2207,16 +2195,6 @@ dependencies = [
|
|||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "md2gemtext"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "3ad2427c485f47550ea77fe0b17cb83d0ad26cee4311be1f42e7e676077e7ef0"
|
|
||||||
dependencies = [
|
|
||||||
"gemtext",
|
|
||||||
"pulldown-cmark",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.5"
|
version = "2.7.5"
|
||||||
@@ -2375,7 +2353,7 @@ version = "0.10.73"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"foreign-types",
|
"foreign-types",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -2598,17 +2576,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pulldown-cmark"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.3.2",
|
|
||||||
"memchr",
|
|
||||||
"unicase",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
version = "0.31.0"
|
version = "0.31.0"
|
||||||
@@ -2809,7 +2776,7 @@ version = "0.5.13"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
|
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2988,7 +2955,7 @@ version = "0.38.44"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.4.15",
|
"linux-raw-sys 0.4.15",
|
||||||
@@ -3001,7 +2968,7 @@ version = "1.0.8"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
|
checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys 0.9.4",
|
"linux-raw-sys 0.9.4",
|
||||||
@@ -3157,7 +3124,7 @@ version = "2.11.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
|
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"core-foundation 0.9.4",
|
"core-foundation 0.9.4",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -3170,7 +3137,7 @@ version = "3.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316"
|
checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"core-foundation 0.10.1",
|
"core-foundation 0.10.1",
|
||||||
"core-foundation-sys",
|
"core-foundation-sys",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -3479,7 +3446,7 @@ checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"atoi",
|
"atoi",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"bytes",
|
"bytes",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3522,7 +3489,7 @@ checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"atoi",
|
"atoi",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"chrono",
|
"chrono",
|
||||||
"crc",
|
"crc",
|
||||||
@@ -3651,7 +3618,7 @@ version = "0.6.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
|
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"core-foundation 0.9.4",
|
"core-foundation 0.9.4",
|
||||||
"system-configuration-sys",
|
"system-configuration-sys",
|
||||||
]
|
]
|
||||||
@@ -3668,7 +3635,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "task"
|
name = "task"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cache",
|
"cache",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -3676,7 +3643,6 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"job_scheduler",
|
"job_scheduler",
|
||||||
"markdown",
|
"markdown",
|
||||||
"md2gemtext",
|
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -3913,7 +3879,7 @@ version = "0.6.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
|
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
"bytes",
|
"bytes",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"http 1.3.1",
|
"http 1.3.1",
|
||||||
@@ -4061,12 +4027,6 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicase"
|
|
||||||
version = "2.10.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-bidi"
|
name = "unicode-bidi"
|
||||||
version = "0.3.18"
|
version = "0.3.18"
|
||||||
@@ -4680,7 +4640,7 @@ version = "0.39.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.9.1",
|
"bitflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "task"
|
name = "task"
|
||||||
version = "0.2.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@@ -25,4 +25,3 @@ serde = { version = "*", features = ["derive"] }
|
|||||||
serde_yml = "*"
|
serde_yml = "*"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
|
||||||
md2gemtext = "0.1.0"
|
|
||||||
@@ -1,15 +1,14 @@
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
use std::io::Read;
|
||||||
|
|
||||||
use crate::utils::task_log;
|
use crate::utils::task_log;
|
||||||
use chrono::DateTime;
|
use chrono::{DateTime, FixedOffset, Utc};
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
pub fn register(pool: &sqlx::Pool<sqlx::Postgres>) {
|
pub fn register(pool: &sqlx::Pool<sqlx::Postgres>) {
|
||||||
let p = pool.clone();
|
let p = pool.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Err(error) = import_posts("/app/posts", &p).await {
|
let _ = import_posts("/app/posts", &p).await;
|
||||||
tracing::error!(%error, "Post import failed");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,6 +20,9 @@ async fn import_posts(
|
|||||||
|
|
||||||
// Start task logging
|
// Start task logging
|
||||||
let task = task_log::start(1, pool).await?;
|
let task = task_log::start(1, pool).await?;
|
||||||
|
let options = MarkdownOptions {
|
||||||
|
options: markdown::Constructs::gfm(),
|
||||||
|
};
|
||||||
let entries = fs::read_dir(dir_path)?;
|
let entries = fs::read_dir(dir_path)?;
|
||||||
|
|
||||||
for entry_result in entries {
|
for entry_result in entries {
|
||||||
@@ -64,7 +66,6 @@ async fn import_posts(
|
|||||||
|
|
||||||
let content =
|
let content =
|
||||||
markdown::to_html_with_options(&document.content, &markdown::Options::default());
|
markdown::to_html_with_options(&document.content, &markdown::Options::default());
|
||||||
let gemtext = md2gemtext::convert(&document.content).to_string();
|
|
||||||
|
|
||||||
let title = document.metadata.title;
|
let title = document.metadata.title;
|
||||||
let pub_date =
|
let pub_date =
|
||||||
@@ -72,12 +73,11 @@ async fn import_posts(
|
|||||||
let content_final = content.unwrap();
|
let content_final = content.unwrap();
|
||||||
|
|
||||||
// Insert into database
|
// Insert into database
|
||||||
let _ = sqlx::query_as::<_, InsertPosts>(
|
let results = sqlx::query_as::<_, InsertPosts>(
|
||||||
"INSERT INTO posts (title, body, body_gemtext, filename, publish_date, author_id) VALUES ($1, $2, $3, $4, $5, $6) RETURNING title, body, body_gemtext, filename, author_id"
|
"INSERT INTO posts (title, body, filename, publish_date, author_id) VALUES ($1, $2, $3, $4, $5) RETURNING title, body, filename, author_id"
|
||||||
)
|
)
|
||||||
.bind(title)
|
.bind(title)
|
||||||
.bind(content_final)
|
.bind(content_final)
|
||||||
.bind(gemtext)
|
|
||||||
.bind(file_name_str)
|
.bind(file_name_str)
|
||||||
.bind(pub_date)
|
.bind(pub_date)
|
||||||
.bind(1) // Consider making author_id a parameter
|
.bind(1) // Consider making author_id a parameter
|
||||||
@@ -111,7 +111,6 @@ struct FilenameExists {
|
|||||||
struct InsertPosts {
|
struct InsertPosts {
|
||||||
title: String,
|
title: String,
|
||||||
body: String,
|
body: String,
|
||||||
body_gemtext: String,
|
|
||||||
filename: String,
|
filename: String,
|
||||||
author_id: i32,
|
author_id: i32,
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+13
-13
@@ -2,12 +2,12 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"flake-schemas": {
|
"flake-schemas": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1780327564,
|
"lastModified": 1721999734,
|
||||||
"narHash": "sha256-HiRPtA0spK+Dkgbhz/1zW9glXxNVB+L4Rj2VYmdawb8=",
|
"narHash": "sha256-G5CxYeJVm4lcEtaO87LKzOsVnWeTcHGKbKxNamNWgOw=",
|
||||||
"rev": "6cc9bd98891b1fc6bb2b8cb3277df8bc72799ca6",
|
"rev": "0a5c42297d870156d9c57d8f99e476b738dcd982",
|
||||||
"revCount": 149,
|
"revCount": 75,
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.5.0/019e83cf-9af3-78b1-ac5b-70e68ad1efe1/source.tar.gz"
|
"url": "https://api.flakehub.com/f/pinned/DeterminateSystems/flake-schemas/0.1.5/0190ef2f-61e0-794b-ba14-e82f225e55e6/source.tar.gz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1793410479,
|
"lastModified": 1752436162,
|
||||||
"narHash": "sha256-HzgjxrLY4AEc0044ZuM5CHbLSWLZgDlay1idmzvvpJs=",
|
"narHash": "sha256-Kt1UIPi7kZqkSc5HVj6UY5YLHHEzPBkgpNUByuyxtlw=",
|
||||||
"rev": "fa1373130d5a21c040a47c5dbe1913d59ed91808",
|
"rev": "dfcd5b901dbab46c9c6e80b265648481aafb01f8",
|
||||||
"revCount": 1017588,
|
"revCount": 806304,
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2605.1017588%2Brev-fa1373130d5a21c040a47c5dbe1913d59ed91808/01a1959c-245a-7673-9ea9-ccd89a1f8489/source.tar.gz"
|
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2505.806304%2Brev-dfcd5b901dbab46c9c6e80b265648481aafb01f8/01980f2c-e7f3-7efc-b369-7ebec7be6e59/source.tar.gz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
@@ -63,11 +63,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1793434469,
|
"lastModified": 1752633862,
|
||||||
"narHash": "sha256-+sgVNI2c67di+XIeMaz5KSei4T65kX68s5Nl0E5Gzbc=",
|
"narHash": "sha256-Bj7ozT1+5P7NmvDcuAXJvj56txcXuAhk3Vd9FdWFQzk=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "6ecf534a7c16e7c969f26838fdd8c93597ae93f3",
|
"rev": "8668ca94858206ac3db0860a9dec471de0d995f8",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -76,8 +76,10 @@
|
|||||||
RUST_BACKTRACE = "1";
|
RUST_BACKTRACE = "1";
|
||||||
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
RUST_SRC_PATH = "${pkgs.rustToolchain}/lib/rustlib/src/rust/library";
|
||||||
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
|
||||||
# ZELLIJ_CONFIG_FILE = "config.kdl";
|
NIX_LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [
|
||||||
# PATH = "$PATH:$HOME/.local/share/nvim/mason/bin/deno";
|
pkgs.stdenv.cc.cc
|
||||||
|
];
|
||||||
|
NIX_LD = pkgs.lib.fileContents "${pkgs.stdenv.cc}/nix-support/dynamic-linker";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -4,10 +4,10 @@ RUN apk add bash
|
|||||||
|
|
||||||
# USER deno
|
# USER deno
|
||||||
|
|
||||||
RUN deno cache --reload deno.json
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
RUN deno cache --reload deno.json
|
||||||
|
|
||||||
RUN bash -c 'deno cache main.ts'
|
RUN bash -c 'deno cache main.ts'
|
||||||
|
|
||||||
RUN bash -c 'deno task build'
|
RUN bash -c 'deno task build'
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import * as $projects_index from "./routes/projects/index.tsx";
|
|||||||
import * as $rss_index from "./routes/rss/index.tsx";
|
import * as $rss_index from "./routes/rss/index.tsx";
|
||||||
import * as $sitemap_index from "./routes/sitemap/index.tsx";
|
import * as $sitemap_index from "./routes/sitemap/index.tsx";
|
||||||
import * as $Counter from "./islands/Counter.tsx";
|
import * as $Counter from "./islands/Counter.tsx";
|
||||||
|
import * as $ImageCarousel from "./islands/ImageCarousel.tsx";
|
||||||
|
import * as $Portal from "./islands/Portal.tsx";
|
||||||
import * as $ProjectCard from "./islands/ProjectCard.tsx";
|
import * as $ProjectCard from "./islands/ProjectCard.tsx";
|
||||||
|
import * as $ProjectModal from "./islands/ProjectModal.tsx";
|
||||||
import { type Manifest } from "$fresh/server.ts";
|
import { type Manifest } from "$fresh/server.ts";
|
||||||
|
|
||||||
const manifest = {
|
const manifest = {
|
||||||
@@ -35,7 +38,10 @@ const manifest = {
|
|||||||
},
|
},
|
||||||
islands: {
|
islands: {
|
||||||
"./islands/Counter.tsx": $Counter,
|
"./islands/Counter.tsx": $Counter,
|
||||||
|
"./islands/ImageCarousel.tsx": $ImageCarousel,
|
||||||
|
"./islands/Portal.tsx": $Portal,
|
||||||
"./islands/ProjectCard.tsx": $ProjectCard,
|
"./islands/ProjectCard.tsx": $ProjectCard,
|
||||||
|
"./islands/ProjectModal.tsx": $ProjectModal,
|
||||||
},
|
},
|
||||||
baseUrl: import.meta.url,
|
baseUrl: import.meta.url,
|
||||||
} satisfies Manifest;
|
} satisfies Manifest;
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import { useState } from "preact/hooks";
|
||||||
|
|
||||||
|
export const ImageCarousel = function ImageCarousel(props: ImageCarouselProps) {
|
||||||
|
const [currentImageIndex, setCurrentImageIndex] = useState(0);
|
||||||
|
|
||||||
|
const nextImage = (e: Event) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (props.images && props.images?.length > 0) {
|
||||||
|
const localImage = props.images;
|
||||||
|
setCurrentImageIndex((prev) => (prev + 1) % localImage.length || 0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const prevImage = (e: Event) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (props.images && props.images.length > 0) {
|
||||||
|
const localImage = props.images;
|
||||||
|
setCurrentImageIndex(
|
||||||
|
(prev) => (prev - 1 + localImage.length) % localImage.length,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="relative rounded overflow-hidden bg-gray-100 dark:bg-gray-800">
|
||||||
|
<div class="relative w-full h-96">
|
||||||
|
{props.images.map((image, index) => (
|
||||||
|
<img
|
||||||
|
key={index}
|
||||||
|
src={image}
|
||||||
|
alt={`screenshot ${index + 1}`}
|
||||||
|
class={`absolute inset-0 w-full h-full object-contain transition-opacity duration-500 ${
|
||||||
|
index === currentImageIndex ? "opacity-100" : "opacity-0"
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{props.images.length > 1 && (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={prevImage}
|
||||||
|
class="absolute left-2 top-1/2 -translate-y-1/2 bg-black/50 hover:bg-black/70 text-white rounded-full w-10 h-10 flex items-center justify-center transition-all"
|
||||||
|
aria-label="Previous image"
|
||||||
|
>
|
||||||
|
←
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={nextImage}
|
||||||
|
class="absolute right-2 top-1/2 -translate-y-1/2 bg-black/50 hover:bg-black/70 text-white rounded-full w-10 h-10 flex items-center justify-center transition-all"
|
||||||
|
aria-label="Next image"
|
||||||
|
>
|
||||||
|
→
|
||||||
|
</button>
|
||||||
|
<div class="absolute bottom-4 left-1/2 -translate-x-1/2 flex gap-2 bg-black/30 px-3 py-2 rounded-full">
|
||||||
|
{props.images.map((_, index) => (
|
||||||
|
<button
|
||||||
|
key={index}
|
||||||
|
type="button"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
setCurrentImageIndex(index);
|
||||||
|
}}
|
||||||
|
class={`w-2.5 h-2.5 rounded-full transition-all ${
|
||||||
|
index === currentImageIndex
|
||||||
|
? "bg-white scale-125"
|
||||||
|
: "bg-white/50 hover:bg-white/75"
|
||||||
|
}`}
|
||||||
|
aria-label={`Go to image ${index + 1}`}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
type ImageCarouselProps = {
|
||||||
|
images: Array<string>;
|
||||||
|
};
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import { useEffect, useState } from "preact/hooks";
|
||||||
|
import { createPortal } from "preact/compat";
|
||||||
|
import type { ComponentChildren } from "preact";
|
||||||
|
|
||||||
|
type PortalProps = {
|
||||||
|
into?: string | HTMLElement;
|
||||||
|
children: ComponentChildren;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function Portal({ into = "body", children }: PortalProps) {
|
||||||
|
const [host, setHost] = useState<HTMLElement | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (typeof document === "undefined") return;
|
||||||
|
|
||||||
|
let target: HTMLElement | null = null;
|
||||||
|
if (typeof into === "string") {
|
||||||
|
target = into === "body" ? document.body : document.querySelector(into);
|
||||||
|
} else {
|
||||||
|
target = into;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!target) target = document.body;
|
||||||
|
|
||||||
|
const wrapper = document.createElement("div");
|
||||||
|
wrapper.className = "preact-portal-root";
|
||||||
|
target.appendChild(wrapper);
|
||||||
|
setHost(wrapper);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
if (wrapper.parentNode) wrapper.parentNode.removeChild(wrapper);
|
||||||
|
setHost(null);
|
||||||
|
};
|
||||||
|
}, [into]);
|
||||||
|
|
||||||
|
if (!host) return null;
|
||||||
|
return createPortal(children, host);
|
||||||
|
}
|
||||||
@@ -1,4 +1,23 @@
|
|||||||
|
import { useState } from "preact/hooks";
|
||||||
|
import { Portal } from "./Portal.tsx";
|
||||||
|
import { type ModalAction, ProjectModal } from "./ProjectModal.tsx";
|
||||||
|
import { ImageCarousel } from "./ImageCarousel.tsx";
|
||||||
|
import * as hi from "@preact-icons/hi2";
|
||||||
|
|
||||||
export const ProjectCard = function ProjectCard(props: ProjectProps) {
|
export const ProjectCard = function ProjectCard(props: ProjectProps) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const modalButtons: Array<ModalAction> = [
|
||||||
|
{
|
||||||
|
label: "Open repository",
|
||||||
|
icon: <hi.HiCodeBracket />,
|
||||||
|
onClick: () => {
|
||||||
|
if (props.repo) globalThis.open(props.repo, "_blank");
|
||||||
|
},
|
||||||
|
variant: "primary",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
class={`md:m-8 group space-y-1 rounded-md ${
|
class={`md:m-8 group space-y-1 rounded-md ${
|
||||||
@@ -13,25 +32,26 @@ export const ProjectCard = function ProjectCard(props: ProjectProps) {
|
|||||||
}
|
}
|
||||||
: {}
|
: {}
|
||||||
}
|
}
|
||||||
onClick={() => props.repo && open(props.repo, "_blank")}
|
onClick={() => {
|
||||||
|
// clicking the card (not the link) opens the modal
|
||||||
|
setOpen(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<div class="flex items-center justify-between">
|
<div class="flex items-center justify-between">
|
||||||
<h2 class="text-lg text-white font-black uppercase">
|
<h2 class="text-lg text-white font-black uppercase">
|
||||||
<a href={props.repo} target="_blank">
|
<a
|
||||||
|
href={props.repo}
|
||||||
|
target="_blank"
|
||||||
|
onClick={(e) => {
|
||||||
|
// clicking the link should not open the modal
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
|
>
|
||||||
{props.title}
|
{props.title}
|
||||||
</a>
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="bg-[#585b70] text-[#a6adc8] text-xs font-bold uppercase px-2.5 py-0.5 rounded-full">
|
<div class="bg-[#585b70] text-[#a6adc8] text-xs font-bold uppercase px-2.5 py-0.5 rounded-full">
|
||||||
{props.repo && (
|
{props.repo && <span>Active</span>}
|
||||||
<a
|
|
||||||
class="hover:underline"
|
|
||||||
href={props.repo}
|
|
||||||
target="_blank"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
>
|
|
||||||
Active
|
|
||||||
</a>
|
|
||||||
)}
|
|
||||||
{!props.repo && !props.wip && <span>Dead</span>}
|
{!props.repo && !props.wip && <span>Dead</span>}
|
||||||
{props.wip && <span>WIP</span>}
|
{props.wip && <span>WIP</span>}
|
||||||
</div>
|
</div>
|
||||||
@@ -42,6 +62,28 @@ export const ProjectCard = function ProjectCard(props: ProjectProps) {
|
|||||||
<p class="whitespace-pre-wrap text-sm font-semibold text-[#a6adc8]">
|
<p class="whitespace-pre-wrap text-sm font-semibold text-[#a6adc8]">
|
||||||
{props.tech}
|
{props.tech}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{open && !props.wip ? (
|
||||||
|
<Portal into="body">
|
||||||
|
<ProjectModal
|
||||||
|
title={props.title}
|
||||||
|
onClose={() => setOpen(false)}
|
||||||
|
actions={modalButtons}
|
||||||
|
>
|
||||||
|
<div class="space-y-3">
|
||||||
|
{props.images && props.images.length > 0 && (
|
||||||
|
<ImageCarousel images={props.images} />
|
||||||
|
)}
|
||||||
|
<p class="text-sm text-gray-800 dark:text-gray-200">
|
||||||
|
{props.description}
|
||||||
|
</p>
|
||||||
|
<p class="text-xs font-mono text-gray-600 dark:text-gray-300">
|
||||||
|
Technologies used: {props.tech}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</ProjectModal>
|
||||||
|
</Portal>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -50,6 +92,8 @@ type ProjectProps = {
|
|||||||
title: string;
|
title: string;
|
||||||
repo?: string;
|
repo?: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
|
description?: string;
|
||||||
tech: string;
|
tech: string;
|
||||||
wip?: boolean;
|
wip?: boolean;
|
||||||
|
images?: string[];
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,160 @@
|
|||||||
|
import { useEffect, useRef, useState } from "preact/hooks";
|
||||||
|
import type { ComponentChildren } from "preact";
|
||||||
|
import * as hi from "jsr:@preact-icons/hi2";
|
||||||
|
|
||||||
|
export type ModalAction = {
|
||||||
|
label: string;
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
icon?: any;
|
||||||
|
onClick: () => void;
|
||||||
|
variant?: "primary" | "secondary" | "link";
|
||||||
|
};
|
||||||
|
|
||||||
|
type ModalProps = {
|
||||||
|
title?: string;
|
||||||
|
/**
|
||||||
|
* Called after the modal has finished its exit animation.
|
||||||
|
* The Modal will run the exit animation internally and then call onClose().
|
||||||
|
*/
|
||||||
|
onClose: () => void;
|
||||||
|
children: ComponentChildren;
|
||||||
|
ariaLabel?: string;
|
||||||
|
actions?: ModalAction[]; // rendered in footer; each button will be given flex-1 so buttons fill the width together
|
||||||
|
/**
|
||||||
|
* Optional: duration (ms) of enter/exit animation. Defaults to 200.
|
||||||
|
* Keep this in sync with the CSS transition-duration classes used below.
|
||||||
|
*/
|
||||||
|
animationDurationMs?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ProjectModal = function ProjectModal({
|
||||||
|
title,
|
||||||
|
onClose,
|
||||||
|
children,
|
||||||
|
ariaLabel,
|
||||||
|
actions,
|
||||||
|
animationDurationMs = 200,
|
||||||
|
}: ModalProps) {
|
||||||
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
|
const closingRef = useRef(false);
|
||||||
|
const timeoutRef = useRef<number | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const raf = requestAnimationFrame(() => setIsVisible(true));
|
||||||
|
|
||||||
|
function onKey(e: KeyboardEvent) {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
startCloseFlow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener("keydown", onKey);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
cancelAnimationFrame(raf);
|
||||||
|
document.removeEventListener("keydown", onKey);
|
||||||
|
if (timeoutRef.current !== null) {
|
||||||
|
clearTimeout(timeoutRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const footerActions: ModalAction[] =
|
||||||
|
actions && actions.length > 0
|
||||||
|
? [
|
||||||
|
...actions,
|
||||||
|
{
|
||||||
|
label: "Close",
|
||||||
|
icon: <hi.HiXCircle />,
|
||||||
|
onClick: startCloseFlow,
|
||||||
|
variant: "secondary",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: [{ label: "Close", onClick: startCloseFlow, variant: "primary" }];
|
||||||
|
|
||||||
|
function startCloseFlow() {
|
||||||
|
if (closingRef.current) return;
|
||||||
|
closingRef.current = true;
|
||||||
|
setIsVisible(false);
|
||||||
|
timeoutRef.current = globalThis.setTimeout(() => {
|
||||||
|
timeoutRef.current = null;
|
||||||
|
onClose();
|
||||||
|
}, animationDurationMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
const panelBase =
|
||||||
|
"relative z-10 max-w-lg w-full bg-white dark:bg-[#1f2937] rounded-lg shadow-xl p-6 mx-4 transform transition-all";
|
||||||
|
const panelVisible = "opacity-100 translate-y-0 scale-100";
|
||||||
|
const panelHidden = "opacity-0 translate-y-2 scale-95";
|
||||||
|
const backdropBase =
|
||||||
|
"absolute inset-0 bg-black/50 backdrop-blur-sm transition-opacity";
|
||||||
|
const backdropVisible = "opacity-100";
|
||||||
|
const backdropHidden = "opacity-0";
|
||||||
|
|
||||||
|
const renderActionButton = (action: ModalAction) => {
|
||||||
|
const base =
|
||||||
|
"flex-1 w-full px-4 py-2 rounded-md font-semibold focus:outline-none flex items-center justify-center gap-2";
|
||||||
|
const styles =
|
||||||
|
action.variant === "primary"
|
||||||
|
? "bg-[#94e2d5] text-black hover:brightness-95 border-b-4 border-b-[#364153] shadow-xl"
|
||||||
|
: action.variant === "link"
|
||||||
|
? "bg-transparent text-[#075985] underline"
|
||||||
|
: "bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200 hover:brightness-95 border-b-4 border-b-[#94e2d5] shadow-xl";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={action.label}
|
||||||
|
onClick={action.onClick}
|
||||||
|
class={`${base} ${styles}`}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
{action.icon} {action.label}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
class="fixed inset-0 z-50 flex items-center justify-center"
|
||||||
|
aria-modal="true"
|
||||||
|
role="dialog"
|
||||||
|
aria-label={ariaLabel ?? title ?? "Modal dialog"}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{ transitionDuration: `${animationDurationMs}ms` }}
|
||||||
|
class={`${backdropBase} ${
|
||||||
|
isVisible ? backdropVisible : backdropHidden
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
style={{ transitionDuration: `${animationDurationMs}ms` }}
|
||||||
|
class={`${panelBase} ${isVisible ? panelVisible : panelHidden}`}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
|
<div class="flex items-start justify-between">
|
||||||
|
<h3 class="text-lg font-semibold text-gray-900 dark:text-white">
|
||||||
|
{title}
|
||||||
|
</h3>
|
||||||
|
<button
|
||||||
|
onClick={startCloseFlow}
|
||||||
|
aria-label="Close modal"
|
||||||
|
class="ml-4 rounded-md text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 p-1"
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4 text-sm text-gray-700 dark:text-gray-300">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-6">
|
||||||
|
<div class="flex gap-3 w-full">
|
||||||
|
{footerActions.map(renderActionButton)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -6,26 +6,26 @@ interface ProjectData {
|
|||||||
title: string;
|
title: string;
|
||||||
repo?: string;
|
repo?: string;
|
||||||
summary: string;
|
summary: string;
|
||||||
|
description?: string;
|
||||||
tech: string;
|
tech: string;
|
||||||
wip?: boolean;
|
wip?: boolean;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
images: Array<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handler: Handlers<ProjectData> = {
|
export const handler: Handlers<Array<ProjectData>> = {
|
||||||
async GET(_req: Request, ctx: FreshContext) {
|
async GET(_req: Request, ctx: FreshContext) {
|
||||||
const projectResult = await fetch(
|
const projectResult = await fetch(
|
||||||
`${Deno.env.get("BASE_URI_API")}/projects`,
|
`${Deno.env.get("BASE_URI_API")}/projects`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const projectData = await projectResult.json();
|
const projectData = await projectResult.json();
|
||||||
return ctx.render({
|
return ctx.render(projectData);
|
||||||
projectData,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Projects({ data }: PageProps<ProjectData>) {
|
export default function Projects(props: PageProps<Array<ProjectData>>) {
|
||||||
const { projectData: projects } = data;
|
const projects = props.data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="space-y-12 px-10 py-8 sm:min-h-screen bg-[#313244]">
|
<div class="space-y-12 px-10 py-8 sm:min-h-screen bg-[#313244]">
|
||||||
@@ -43,14 +43,19 @@ export default function Projects({ data }: PageProps<ProjectData>) {
|
|||||||
challenges that keep me busy when I'm not doing "real work" stuff!
|
challenges that keep me busy when I'm not doing "real work" stuff!
|
||||||
</p>
|
</p>
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2">
|
<div class="grid grid-cols-1 sm:grid-cols-2">
|
||||||
{projects.map((project: any) => {
|
{projects.map((project: ProjectData) => {
|
||||||
return (
|
return (
|
||||||
<ProjectCard
|
<ProjectCard
|
||||||
title={project.title}
|
title={project.title}
|
||||||
repo={project.repo ?? undefined}
|
repo={project.repo ?? undefined}
|
||||||
summary={project.summary}
|
summary={project.summary}
|
||||||
|
description={
|
||||||
|
project.description ??
|
||||||
|
"No description found. Perhaps you should check out the repository instead!"
|
||||||
|
}
|
||||||
tech={project.tech}
|
tech={project.tech}
|
||||||
wip={project.wip ?? true}
|
wip={project.wip ?? true}
|
||||||
|
images={project.images}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in new issue
Block a user