diff --git a/Cargo.lock b/Cargo.lock index 6762099e6..bad5fe373 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -251,45 +251,6 @@ dependencies = [ "serde", ] -[[package]] -name = "askama" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b79091df18a97caea757e28cd2d5fda49c6cd4bd01ddffd7ff01ace0c0ad2c28" -dependencies = [ - "askama_derive", - "askama_escape", -] - -[[package]] -name = "askama_derive" -version = "0.12.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19fe8d6cb13c4714962c072ea496f3392015f0989b1a2847bb4b2d9effd71d83" -dependencies = [ - "askama_parser", - "mime", - "mime_guess", - "proc-macro2", - "quote", - "syn 2.0.90", -] - -[[package]] -name = "askama_escape" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "619743e34b5ba4e9703bba34deac3427c72507c7159f5fd030aea8cac0cfe341" - -[[package]] -name = "askama_parser" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acb1161c6b64d1c3d83108213c2a2533a342ac225aabd0bda218278c2ddb00c0" -dependencies = [ - "nom", -] - [[package]] name = "async-compression" version = "0.4.18" @@ -2124,6 +2085,15 @@ version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" +[[package]] +name = "file-id" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bc904b9bbefcadbd8e3a9fb0d464a9b979de6324c03b3c663e8994f46a5be36" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "filetime" version = "0.2.25" @@ -2713,6 +2683,15 @@ dependencies = [ "digest", ] +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "hostname" version = "0.4.0" @@ -3286,12 +3265,19 @@ version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "itoap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9028f49264629065d057f340a86acb84867925865f73bbf8d47b4d149a7e88b8" + [[package]] name = "js-sys" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb15147158e79fd8b8afd0252522769c4f48725460b37338544d8379d94fc8f9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -3378,7 +3364,7 @@ dependencies = [ "mime", "mime_guess", "minijinja", - "notify", + "notify-debouncer-full", "oxide-auth", "oxide-auth-async", "oxide-auth-axum", @@ -3586,7 +3572,6 @@ dependencies = [ name = "kitsune-email" version = "0.0.1-pre.6" dependencies = [ - "askama", "diesel", "diesel-async", "kitsune-db", @@ -3595,6 +3580,7 @@ dependencies = [ "kitsune-url", "lettre", "mrml", + "sailfish", "speedy-uuid", "triomphe", "typed-builder", @@ -4628,6 +4614,19 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "notify-debouncer-full" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dcf855483228259b2353f89e99df35fc639b2b2510d1166e4858e3f67ec1afb" +dependencies = [ + "file-id", + "log", + "notify", + "notify-types", + "walkdir", +] + [[package]] name = "notify-types" version = "1.0.0" @@ -5841,9 +5840,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" +checksum = "c7fb8039b3032c191086b10f11f319a6e99e1e82889c5cc6046f515c9db1d497" [[package]] name = "rustc_version" @@ -5966,6 +5965,42 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "sailfish" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4d5cd6d4f24f3ab107e949ab424738cf55b03deddce3b184c46985d7b1394ef" +dependencies = [ + "itoap", + "ryu", + "sailfish-macros", + "version_check", +] + +[[package]] +name = "sailfish-compiler" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7254ec7b3651f7f723a9073153f5dcddc1f2bf1bf8d1b23ac71c236ef6360d2b" +dependencies = [ + "filetime", + "home", + "memchr", + "proc-macro2", + "quote", + "syn 2.0.90", +] + +[[package]] +name = "sailfish-macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00812289fe1891c191cc2d9db461352fc410619e07ec2bb748faaa06412619d0" +dependencies = [ + "proc-macro2", + "sailfish-compiler", +] + [[package]] name = "same-file" version = "1.0.6" @@ -7638,9 +7673,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.96" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21d3b25c3ea1126a2ad5f4f9068483c2af1e64168f847abe863a526b8dbfe00b" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -7649,9 +7684,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.96" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52857d4c32e496dc6537646b5b117081e71fd2ff06de792e3577a150627db283" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", @@ -7664,9 +7699,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.46" +version = "0.4.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951fe82312ed48443ac78b66fa43eded9999f738f6022e67aead7b708659e49a" +checksum = "9dfaf8f50e5f293737ee323940c7d8b08a66a95a419223d9f41610ca08b0833d" dependencies = [ "cfg-if", "js-sys", @@ -7677,9 +7712,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.96" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "920b0ffe069571ebbfc9ddc0b36ba305ef65577c94b06262ed793716a1afd981" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -7687,9 +7722,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.96" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf59002391099644be3524e23b781fa43d2be0c5aa0719a18c0731b9d195cab6" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", @@ -7700,9 +7735,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.96" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5047c5392700766601942795a436d7d2599af60dcc3cc1248c9120bfb0827b0" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "wasm-encoder" @@ -8057,9 +8092,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "476364ff87d0ae6bfb661053a9104ab312542658c3d8f963b7ace80b6f9b26b9" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index 37d94ec02..ebc9161ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,6 @@ members = [ resolver = "2" [workspace.dependencies] -askama = { version = "0.12.1", default-features = false } asynk-strim = "0.1.2" clap = { version = "4.5.21", features = ["derive", "wrap_help"] } diesel = { version = "2.2.5", default-features = false, features = [ @@ -116,6 +115,10 @@ iso8601-timestamp = "0.3.1" itertools = { version = "0.13.0", default-features = false } minijinja = { version = "2.5.0", features = ["loader"] } moka = { version = "=0.12.7", features = ["sync"] } +sailfish = { version = "0.9.0", default-features = false, features = [ + "derive", + "perf-inline", +] } simdutf8 = { version = "0.1.5", features = ["aarch64_neon"] } sonic-rs = "=0.3.14" tokio = "1.41.1" diff --git a/crates/kitsune-email/Cargo.toml b/crates/kitsune-email/Cargo.toml index d0310d0c7..b9c93ad33 100644 --- a/crates/kitsune-email/Cargo.toml +++ b/crates/kitsune-email/Cargo.toml @@ -6,7 +6,6 @@ version.workspace = true license.workspace = true [dependencies] -askama.workspace = true diesel.workspace = true diesel-async.workspace = true kitsune-db.workspace = true @@ -26,6 +25,7 @@ mrml = { version = "4.0.1", default-features = false, features = [ "parse", "render", ] } +sailfish.workspace = true speedy-uuid.workspace = true triomphe.workspace = true typed-builder = "0.20.0" diff --git a/crates/kitsune-email/src/mails/confirm_account.rs b/crates/kitsune-email/src/mails/confirm_account.rs index da6f731a9..70bc3e6e3 100644 --- a/crates/kitsune-email/src/mails/confirm_account.rs +++ b/crates/kitsune-email/src/mails/confirm_account.rs @@ -1,11 +1,11 @@ use crate::traits::{RenderableEmail, RenderedEmail}; -use askama::Template; use kitsune_error::Result; use mrml::{mjml::Mjml, prelude::render::RenderOptions}; +use sailfish::Template; use typed_builder::TypedBuilder; #[derive(Template, TypedBuilder)] -#[template(escape = "html", path = "verify.mjml")] +#[template(path = "verify.mjml")] pub struct ConfirmAccount<'a> { domain: &'a str, username: &'a str, diff --git a/crates/kitsune-email/templates/verify.mjml b/crates/kitsune-email/templates/verify.mjml index 2bafdd312..e8ce7810d 100644 --- a/crates/kitsune-email/templates/verify.mjml +++ b/crates/kitsune-email/templates/verify.mjml @@ -1,6 +1,6 @@ - Confirm your {{domain}} account + Confirm your <%= self.domain %> account @@ -8,34 +8,33 @@ - - - Kitsune - + Kitsune - - Confirm your account - + Confirm your account - Congratulations to your new account on {{domain}}! - Click the button below to unlock your account (@{{username}})! + Congratulations to your new account on <%= self.domain %>! + + Click the button below to unlock your account (@<%= self.username + %>)! + - - Confirm my account! - + Confirm my account! You didn't register an account? Feel free to just ignore this email! - {{domain}} powered by Kitsune + <%= self.domain %> powered by + Kitsune - \ No newline at end of file + diff --git a/crates/kitsune-language/Cargo.toml b/crates/kitsune-language/Cargo.toml index 32627c775..975dfc441 100644 --- a/crates/kitsune-language/Cargo.toml +++ b/crates/kitsune-language/Cargo.toml @@ -14,7 +14,7 @@ isolang = { version = "2.4.0", features = [ "list_languages", "serde", ] } -rustc-hash = "2.0.0" +rustc-hash = "2.1.0" whatlang = "0.16.4" whichlang = "0.1.0" diff --git a/kitsune/Cargo.toml b/kitsune/Cargo.toml index ee404de41..800fdc2a5 100644 --- a/kitsune/Cargo.toml +++ b/kitsune/Cargo.toml @@ -71,7 +71,7 @@ mimalloc = "0.1.43" mime = "0.3.17" mime_guess = { version = "2.0.5", default-features = false } minijinja.workspace = true -notify = "7.0.0" +notify-debouncer-full = "0.4.0" oxide-auth = "0.6.1" oxide-auth-async = "0.2.1" oxide-auth-axum = "0.5.0" diff --git a/kitsune/assets/template.scss b/kitsune/assets/template.scss deleted file mode 100644 index c8ad52760..000000000 --- a/kitsune/assets/template.scss +++ /dev/null @@ -1,212 +0,0 @@ -@use "../../kitsune-fe/src/styles/colours" as *; -@use "../../kitsune-fe/src/styles/mixins" as *; - -* { - font-family: "Courier New", Courier, monospace; -} - -a { - font-weight: 500; - color: $shade1light; - text-decoration: inherit; -} - -body { - //background-image: url("/public/assets/BG.webp"); - //background-size: cover; - //backdrop-filter: blur(2.5px) saturate(1.4); - //background-position: center; - //background-repeat: no-repeat; - - background-color: $dark1; - color: white; - margin: 0; - padding: 0; - display: flex; - flex-direction: column; - gap: 20px; - justify-content: center; - align-items: center; - height: 100vh; - width: 100vw; -} - -.header { - font-size: 4.3rem; - color: $shade2light; - text-shadow: $shade2dark 3px 3px 4.5px; - line-height: 100%; - margin: 25px auto; - - @include only-on-mobile { - font-size: 42px; - color: $shade2light; - text-shadow: $shade2dark 3px 3px 4.5px; - line-height: 100%; - margin: 25px auto; - } -} - -form, -.message { - background: linear-gradient(to top left, $dark2, $dark1); - border: 10px solid; - border-image-slice: 1; - border-width: 4px; - border-image-source: linear-gradient(to left, $shade1light, $shade1dark); - font-size: 18px; - font-weight: 300; - display: flex; - flex-direction: column; - gap: 10px; - align-items: center; - justify-content: center; - margin-bottom: 20px; -} - -form { - padding: 8vh 4.5vh; - - & .field { - width: 280px; - min-height: 30px; - margin: 10px auto; - margin-bottom: 20px; - border: 0.5px solid $shade2light; - border-radius: 2px; - font-size: 20px; - - @include only-on-mobile { - width: 200px; - min-height: 25px; - margin: 10px auto; - margin-bottom: 20px; - border: 0.5px solid $shade2light; - border-radius: 2px; - font-size: 16px; - } - } -} - -.message, -.consent-forms form { - padding: 2vh; -} - -div.consent-forms { - display: flex; - flex-direction: row; - gap: 1em; -} - -.label { - text-transform: uppercase; -} - -.disclaimer { - background: linear-gradient(to right, $dark2, $dark1); - padding: 2vh; - border: 10px solid; - border-image-slice: 1; - border-width: 3px; - border-image-source: linear-gradient(to left, $shade1light, $shade1dark); - font-size: 16px; - font-weight: bold; - max-width: 80%; - - @include only-on-mobile { - font-size: 13px; - max-width: 70%; - text-align: center; - border-width: 3px; - } -} - -.authUsername, -.appName { - color: $shade2light; - font-weight: bold; -} - -.appName { - text-transform: uppercase; -} - -.formButton { - background-color: $shade2dark; - border: 0.5px solid $shade2light; - border-radius: 5px; - padding: 10px; - color: white; - font-size: 20px; - font-weight: 500; - width: 100px; - cursor: pointer; - font-weight: bold; - transition: 0.5s; - - &:hover { - background-color: $shade2light; - color: $dark1; - transition: 0.3s; - } - - @include only-on-mobile { - padding: 8px; - font-size: 16px; - width: 80px; - } -} - -.tokenContainer { - background: linear-gradient(to top left, $dark2, $dark1); - padding: 8vh 4.5vh; - border: 10px solid; - border-image-slice: 1; - border-width: 4px; - border-image-source: linear-gradient(to left, $shade1light, $shade1dark); - font-size: 20px; - font-weight: 300; - display: flex; - flex-direction: column; - gap: 10px; - align-items: center; - justify-content: center; - margin-bottom: 20px; -} - -.token { - border: 0.5px solid $shade2light; - width: 400px; - padding: 20px 10px; - text-align: center; - overflow-x: auto; - font-weight: bold; - - &::-webkit-scrollbar { - width: 0.5em; - height: 10px; - } - - &::-webkit-scrollbar-track { - box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); - } - - &::-webkit-scrollbar-thumb { - background-color: $shade2dark; - outline: 1px solid $dark2; - } - - @include only-on-mobile { - max-width: 250px; - } -} - -@include only-on-mobile { - form, - .tokenContainer { - padding: 6vh 4vh; - font-size: 16px; - border-width: 3px; - } -} diff --git a/kitsune/src/template.rs b/kitsune/src/template.rs index 81d357f3f..16d770e65 100644 --- a/kitsune/src/template.rs +++ b/kitsune/src/template.rs @@ -1,8 +1,8 @@ use arc_swap::ArcSwapAny; use core::str; -use notify::Watcher; +use notify_debouncer_full::{notify, DebounceEventResult}; use rust_embed::RustEmbed; -use std::{mem::ManuallyDrop, path::Path, sync::OnceLock}; +use std::{mem::ManuallyDrop, path::Path, sync::OnceLock, time::Duration}; use triomphe::Arc; static ENVIRONMENT: OnceLock>>> = OnceLock::new(); @@ -30,28 +30,33 @@ fn init_environment() -> minijinja::Environment<'static> { } fn spawn_watcher() { - let watcher = notify::recommended_watcher(|event: notify::Result| { - if event.is_err() { - return; - } + let watcher = notify_debouncer_full::new_debouncer( + Duration::from_secs(1), + None, + |events: DebounceEventResult| { + let Ok(events) = events else { + return; + }; - match event { - Ok(notify::Event { - kind: - notify::EventKind::Create(..) - | notify::EventKind::Modify(..) - | notify::EventKind::Remove(..), - .. - }) => { - debug!("reloading templates"); + for event in events { + if matches!( + event.event, + notify::Event { + kind: notify::EventKind::Create(..) + | notify::EventKind::Modify(..) + | notify::EventKind::Remove(..), + .. + } + ) { + debug!("reloading templates"); - if let Some(env) = ENVIRONMENT.get() { - env.store(Arc::new(init_environment())); + if let Some(env) = ENVIRONMENT.get() { + env.store(Arc::new(init_environment())); + } } } - _ => return, - } - }) + }, + ) .unwrap(); let mut watcher = ManuallyDrop::new(watcher);
Click the button below to unlock your account (@{{username}})!
+ Click the button below to unlock your account (@<%= self.username + %>)! +