From 7e12bacdf31add6274b3c82fb0c5720f1085187c Mon Sep 17 00:00:00 2001 From: aumetra Date: Sat, 30 Nov 2024 21:20:34 +0100 Subject: [PATCH] replace askama --- Cargo.lock | 129 ++++++++++-------- Cargo.toml | 5 +- crates/kitsune-email/Cargo.toml | 2 +- .../src/mails/confirm_account.rs | 4 +- crates/kitsune-email/templates/verify.mjml | 29 ++-- crates/kitsune-language/Cargo.toml | 2 +- kitsune/src/template.rs | 4 +- 7 files changed, 95 insertions(+), 80 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7998751c7..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" @@ -2722,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" @@ -3295,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", ] @@ -3595,7 +3572,6 @@ dependencies = [ name = "kitsune-email" version = "0.0.1-pre.6" dependencies = [ - "askama", "diesel", "diesel-async", "kitsune-db", @@ -3604,6 +3580,7 @@ dependencies = [ "kitsune-url", "lettre", "mrml", + "sailfish", "speedy-uuid", "triomphe", "typed-builder", @@ -5863,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" @@ -5988,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" @@ -7660,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", @@ -7671,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", @@ -7686,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", @@ -7699,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", @@ -7709,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", @@ -7722,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" @@ -8079,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/src/template.rs b/kitsune/src/template.rs index 94a9666c0..16d770e65 100644 --- a/kitsune/src/template.rs +++ b/kitsune/src/template.rs @@ -1,6 +1,6 @@ use arc_swap::ArcSwapAny; use core::str; -use notify_debouncer_full::notify; +use notify_debouncer_full::{notify, DebounceEventResult}; use rust_embed::RustEmbed; use std::{mem::ManuallyDrop, path::Path, sync::OnceLock, time::Duration}; use triomphe::Arc; @@ -33,7 +33,7 @@ fn spawn_watcher() { let watcher = notify_debouncer_full::new_debouncer( Duration::from_secs(1), None, - |events: notify_debouncer_full::DebounceEventResult| { + |events: DebounceEventResult| { let Ok(events) = events else { return; };