From 6dd77e1732725e89ec768954309787e0a73c9b5d Mon Sep 17 00:00:00 2001 From: Agahnim Date: Mon, 23 Mar 2026 16:01:10 +0100 Subject: [PATCH] home: finished website articles logic --- Cargo.lock | 198 ++--------------------------------- content/web-articles.json | 12 +-- flake.nix | 4 +- src/domain.rs | 16 ++- static/style.css | 45 ++++++-- templates/partials/home.html | 3 +- 6 files changed, 58 insertions(+), 220 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bacd539..9764f45 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9,7 +9,6 @@ dependencies = [ "askama", "axum", "chrono", - "notify", "serde", "serde_json", "tokio", @@ -151,12 +150,6 @@ dependencies = [ "serde", ] -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.11.0" @@ -218,7 +211,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -236,15 +229,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fsevent-sys" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" -dependencies = [ - "libc", -] - [[package]] name = "futures-channel" version = "0.3.32" @@ -395,26 +379,6 @@ dependencies = [ "cc", ] -[[package]] -name = "inotify" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd5b3eaf1a28b758ac0faa5a4254e8ab2705605496f1b1f3fbbc3988ad73d199" -dependencies = [ - "bitflags 2.11.0", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb" -dependencies = [ - "libc", -] - [[package]] name = "itoa" version = "1.0.17" @@ -431,26 +395,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "kqueue" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b" -dependencies = [ - "bitflags 1.3.2", - "libc", -] - [[package]] name = "libc" version = "0.2.183" @@ -507,36 +451,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a69bcab0ad47271a0234d9422b131806bf3968021e5dc9328caf2d4cd58557fc" dependencies = [ "libc", - "log", "wasi", - "windows-sys 0.61.2", -] - -[[package]] -name = "notify" -version = "8.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d3d07927151ff8575b7087f245456e549fea62edf0ec4e565a5ee50c8402bc3" -dependencies = [ - "bitflags 2.11.0", - "fsevent-sys", - "inotify", - "kqueue", - "libc", - "log", - "mio", - "notify-types", - "walkdir", - "windows-sys 0.60.2", -] - -[[package]] -name = "notify-types" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42b8cfee0e339a0337359f3c88165702ac6e600dc01c0cc9579a92d62b08477a" -dependencies = [ - "bitflags 2.11.0", + "windows-sys", ] [[package]] @@ -619,7 +535,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.11.0", + "bitflags", ] [[package]] @@ -640,15 +556,6 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -756,7 +663,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -790,7 +697,7 @@ dependencies = [ "signal-hook-registry", "socket2", "tokio-macros", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -839,7 +746,7 @@ version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4e6559d53cc268e5031cd8429d05415bc4cb4aefc4aa5d6cc35fbf5b924a1f8" dependencies = [ - "bitflags 2.11.0", + "bitflags", "bytes", "futures-core", "futures-util", @@ -917,16 +824,6 @@ version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "wasi" version = "0.11.1+wasi-snapshot-preview1" @@ -978,15 +875,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "winapi-util" -version = "0.1.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" -dependencies = [ - "windows-sys 0.61.2", -] - [[package]] name = "windows-core" version = "0.62.2" @@ -1046,15 +934,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.61.2" @@ -1064,71 +943,6 @@ dependencies = [ "windows-link", ] -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winnow" version = "0.7.15" diff --git a/content/web-articles.json b/content/web-articles.json index b519c4f..c3f3e3c 100644 --- a/content/web-articles.json +++ b/content/web-articles.json @@ -4,15 +4,7 @@ "body": "Just added this section! For now its implementation is very unextensible, but since it's my project anyway, I'll be the only one who may complain about it. We finally have been able to move out from Vercel !! I would've said thank you for your service if the CEO wasn't such a scummy human being. Every step towards self-hosting is a step in the right direction!" }, { - "date": "2025-10-09", - "body": "Just added this section! For now its implementation is very unextensible, but since it's my project anyway, I'll be the only one who may complain about it. We finally have been able to move out from Vercel !! I would've said thank you for your service if the CEO wasn't such a scummy human being. Every step towards self-hosting is a step in the right direction!" - }, - { - "date": "2025-10-09", - "body": "Just added this section! For now its implementation is very unextensible, but since it's my project anyway, I'll be the only one who may complain about it. We finally have been able to move out from Vercel !! I would've said thank you for your service if the CEO wasn't such a scummy human being. Every step towards self-hosting is a step in the right direction!" - }, - { - "date": "2025-10-09", - "body": "Just added this section! For now its implementation is very unextensible, but since it's my project anyway, I'll be the only one who may complain about it. We finally have been able to move out from Vercel !! I would've said thank you for your service if the CEO wasn't such a scummy human being. Every step towards self-hosting is a step in the right direction!" + "date": "2026-03-23", + "body": "It's been a long time ! I'm writing this as I am completely overhauling the website, but I won't tell much about it until I'm done with this project ! What I can say though is that this section is far more extensible now thanks to the handy web-articles json file !" } ] \ No newline at end of file diff --git a/flake.nix b/flake.nix index 4426b44..eb18119 100644 --- a/flake.nix +++ b/flake.nix @@ -23,8 +23,8 @@ ]; shellHook = '' echo "=========================================================" - echo "Pour lancer le projet et avoir les changements en temps réel" - echo "cargo watch -w src -w templates -w static -x run" + echo "Pour lancer le projet et avoir les changements en temps réel : " + echo "- cargo watch -w content -w src -w templates -w static -x run" ''; }; }; diff --git a/src/domain.rs b/src/domain.rs index 07c34c5..3a4c727 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -20,11 +20,17 @@ impl AppState { .expect("p-tracks.json non trouvé"), ) .expect("JSON invalide"), - website_news: serde_json::from_str( - &std::fs::read_to_string("content/web-articles.json") - .expect("web-articles.json non trouvé"), - ) - .expect("JSON invalide"), + website_news: { + let mut news: Vec = serde_json::from_str( + &std::fs::read_to_string("content/web-articles.json") + .expect("web-articles.json non trouvé"), + ) + .expect("JSON invalide"); + + news.sort_by(|a, b| b.date.cmp(&a.date)); + + news + }, } } } diff --git a/static/style.css b/static/style.css index 9b69641..c2655c9 100644 --- a/static/style.css +++ b/static/style.css @@ -225,7 +225,7 @@ body { overflow: auto; font-family: "DotGothic16", sans-serif; - font-size: 16px; + font-size: 1rem; main { padding-top: 8rem; @@ -471,24 +471,36 @@ home-content { website-news { display: flex; flex-direction: column; + justify-content: center; gap: 0.6rem; + + &>img { + margin: auto; + } } article-entry { + padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.2rem; - padding-bottom: 0.4rem; - border-bottom: 1px dashed #0002; - } - article-entry time { - color: var(--darkerer-pink); - font-weight: bold; - } + time { + color: var(--darkerer-pink); + font-weight: bold; + } - article-body { - line-height: 1.3; + article-body { + padding-bottom: 1rem; + } + + img { + margin: auto; + } + + article-body { + line-height: 1.3; + } } ominous-message { @@ -762,6 +774,7 @@ mini-player { } } + /* Navbar */ navbar { font-size: 1.125rem; @@ -821,6 +834,8 @@ mini-player { } } + /* Miniplayer */ + mini-player { display: none; width: 95svw; @@ -842,4 +857,14 @@ mini-player { .progress-input { width: 85%; } + + /* Home */ + + home-content boxes { + flex-direction: column; + + box { + width: 90%; + } + } } \ No newline at end of file diff --git a/templates/partials/home.html b/templates/partials/home.html index 3d69c29..563b630 100644 --- a/templates/partials/home.html +++ b/templates/partials/home.html @@ -56,7 +56,7 @@ - + {% for article in news %} @@ -66,6 +66,7 @@ {{ article.body }} + {% else %}