From e5fc327af0960c22615570a7489c15cb42e813c7 Mon Sep 17 00:00:00 2001 From: Alessandro Campeis <12007735+campeis@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:05:13 +0100 Subject: [PATCH 1/8] update handlebars to version 5.1 --- Cargo.lock | 34 ++++++++++++++++++++++--------- templating/fluent/Cargo.toml | 4 ++-- templating/fluent/src/main.rs | 13 +++++++++--- templating/handlebars/Cargo.toml | 2 +- templating/handlebars/src/main.rs | 11 ++++++++-- 5 files changed, 46 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d221e19..4e30c3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -984,7 +984,7 @@ dependencies = [ "fast_chemail", "fnv", "futures-util", - "handlebars", + "handlebars 4.5.0", "http 0.2.9", "indexmap 2.1.0", "mime", @@ -3168,24 +3168,24 @@ dependencies = [ [[package]] name = "fluent-template-macros" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dec7592cd1f45c1afe9084ce59c62a3a7c266c125c4c2ec97e95b0563c4aa914" +checksum = "0c58fd7421bad2b89506827409317a3088b74d0d637202003f2e87efdc43ae8e" dependencies = [ "flume 0.10.14", "ignore", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.48", "unic-langid", ] [[package]] name = "fluent-templates" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3ef2c2152757885365abce32ddf682746062f1b6b3c0824a29fbed6ee4d080" +checksum = "fc023356542b155925aa5e433806ddd33acb46f0218541f869b342676332cd79" dependencies = [ "arc-swap", "fluent", @@ -3194,7 +3194,7 @@ dependencies = [ "fluent-syntax", "fluent-template-macros", "flume 0.10.14", - "handlebars", + "handlebars 5.1.0", "heck", "ignore", "intl-memoizer", @@ -3678,6 +3678,20 @@ name = "handlebars" version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror", +] + +[[package]] +name = "handlebars" +version = "5.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab283476b99e66691dee3f1640fea91487a8d81f50fb5ecc75538f8f8879a1e4" dependencies = [ "log", "pest", @@ -7601,7 +7615,7 @@ dependencies = [ "actix-web", "actix-web-lab", "fluent-templates", - "handlebars", + "handlebars 5.1.0", "serde", "serde_json", ] @@ -7611,7 +7625,7 @@ name = "templating-handlebars" version = "1.0.0" dependencies = [ "actix-web", - "handlebars", + "handlebars 5.1.0", "serde_json", ] @@ -8261,7 +8275,7 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 0.1.10", + "cfg-if 1.0.0", "rand 0.8.5", "static_assertions", ] diff --git a/templating/fluent/Cargo.toml b/templating/fluent/Cargo.toml index f6ed7ce..e1a73a2 100644 --- a/templating/fluent/Cargo.toml +++ b/templating/fluent/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" [dependencies] actix-web.workspace = true actix-web-lab.workspace = true -fluent-templates = { version = "0.8", features = ["handlebars"] } -handlebars = { version = "4.5", features = ["dir_source"] } +fluent-templates = { version = "0.9", features = ["handlebars"] } +handlebars = { version = "5.1", features = ["dir_source"] } serde.workspace = true serde_json.workspace = true diff --git a/templating/fluent/src/main.rs b/templating/fluent/src/main.rs index 8732a35..9cd7874 100644 --- a/templating/fluent/src/main.rs +++ b/templating/fluent/src/main.rs @@ -10,7 +10,7 @@ use actix_web::{ }; use actix_web_lab::{extract::Path, respond::Html}; use fluent_templates::{static_loader, FluentLoader, Loader as _}; -use handlebars::Handlebars; +use handlebars::{DirectorySourceOptions, Handlebars}; use serde_json::json; mod lang_choice; @@ -57,7 +57,14 @@ async fn main() -> io::Result<()> { // register template dir with Handlebars registry handlebars - .register_templates_directory(".html", "./templates") + .register_templates_directory( + "./static/templates", + DirectorySourceOptions { + tpl_extension: ".html".to_owned(), + hidden: false, + temporary: false, + }, + ) .unwrap(); // register Fluent helper with Handlebars registry @@ -85,7 +92,7 @@ fn error_handlers() -> ErrorHandlers { // Error handler for a 404 Page not found error. fn not_found(res: ServiceResponse) -> Result> { let lang = LangChoice::from_req(res.request()).lang_id(); - let error = LOCALES.lookup(&lang, "error-not-found").unwrap(); + let error = LOCALES.lookup(&lang, "error-not-found"); let response = get_error_response(&res, &error); diff --git a/templating/handlebars/Cargo.toml b/templating/handlebars/Cargo.toml index 374e29c..7b64c60 100644 --- a/templating/handlebars/Cargo.toml +++ b/templating/handlebars/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" [dependencies] actix-web.workspace = true -handlebars = { version = "4.5", features = ["dir_source"] } +handlebars = { version = "5.1", features = ["dir_source"] } serde_json.workspace = true diff --git a/templating/handlebars/src/main.rs b/templating/handlebars/src/main.rs index 3e4bb1b..abffed2 100644 --- a/templating/handlebars/src/main.rs +++ b/templating/handlebars/src/main.rs @@ -8,7 +8,7 @@ use actix_web::{ middleware::{ErrorHandlerResponse, ErrorHandlers}, web, App, HttpResponse, HttpServer, Result, }; -use handlebars::Handlebars; +use handlebars::{DirectorySourceOptions, Handlebars}; use serde_json::json; // Macro documentation can be found in the actix_web_codegen crate @@ -41,7 +41,14 @@ async fn main() -> io::Result<()> { // Application Builder as an atomic reference-counted pointer. let mut handlebars = Handlebars::new(); handlebars - .register_templates_directory(".html", "./static/templates") + .register_templates_directory( + "./static/templates", + DirectorySourceOptions { + tpl_extension: ".html".to_owned(), + hidden: false, + temporary: false, + }, + ) .unwrap(); let handlebars_ref = web::Data::new(handlebars); From c5c208eda73afcaf49931b168f517ba4190ca2b4 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 5 Mar 2024 22:30:51 +0000 Subject: [PATCH 2/8] chore: fix template location --- Cargo.lock | 3 +++ templating/fluent/Cargo.toml | 3 ++- templating/fluent/src/main.rs | 5 ++++- templating/handlebars/Cargo.toml | 4 +++- templating/handlebars/src/main.rs | 17 ++++++++++------- .../{static => }/templates/error.html | 0 .../{static => }/templates/index.html | 0 .../handlebars/{static => }/templates/user.html | 0 8 files changed, 22 insertions(+), 10 deletions(-) rename templating/handlebars/{static => }/templates/error.html (100%) rename templating/handlebars/{static => }/templates/index.html (100%) rename templating/handlebars/{static => }/templates/user.html (100%) diff --git a/Cargo.lock b/Cargo.lock index 4e30c3a..29e9c59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7614,6 +7614,7 @@ version = "1.0.0" dependencies = [ "actix-web", "actix-web-lab", + "env_logger", "fluent-templates", "handlebars 5.1.0", "serde", @@ -7625,6 +7626,8 @@ name = "templating-handlebars" version = "1.0.0" dependencies = [ "actix-web", + "actix-web-lab", + "env_logger", "handlebars 5.1.0", "serde_json", ] diff --git a/templating/fluent/Cargo.toml b/templating/fluent/Cargo.toml index e1a73a2..53b29e0 100644 --- a/templating/fluent/Cargo.toml +++ b/templating/fluent/Cargo.toml @@ -6,7 +6,8 @@ edition = "2021" [dependencies] actix-web.workspace = true actix-web-lab.workspace = true +env_logger.workspace = true fluent-templates = { version = "0.9", features = ["handlebars"] } -handlebars = { version = "5.1", features = ["dir_source"] } +handlebars = { version = "5", features = ["dir_source"] } serde.workspace = true serde_json.workspace = true diff --git a/templating/fluent/src/main.rs b/templating/fluent/src/main.rs index 9cd7874..d8c6cde 100644 --- a/templating/fluent/src/main.rs +++ b/templating/fluent/src/main.rs @@ -51,6 +51,8 @@ async fn user( #[actix_web::main] async fn main() -> io::Result<()> { + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); + // Handlebars uses a repository for the compiled templates. This object must be shared between // the application threads, and is therefore passed to the App in an Arc. let mut handlebars = Handlebars::new(); @@ -58,7 +60,7 @@ async fn main() -> io::Result<()> { // register template dir with Handlebars registry handlebars .register_templates_directory( - "./static/templates", + "./templates", DirectorySourceOptions { tpl_extension: ".html".to_owned(), hidden: false, @@ -79,6 +81,7 @@ async fn main() -> io::Result<()> { .service(index) .service(user) }) + .workers(2) .bind(("127.0.0.1", 8080))? .run() .await diff --git a/templating/handlebars/Cargo.toml b/templating/handlebars/Cargo.toml index 7b64c60..4079d49 100644 --- a/templating/handlebars/Cargo.toml +++ b/templating/handlebars/Cargo.toml @@ -5,5 +5,7 @@ edition = "2021" [dependencies] actix-web.workspace = true -handlebars = { version = "5.1", features = ["dir_source"] } +actix-web-lab.workspace = true +env_logger.workspace = true +handlebars = { version = "5", features = ["dir_source"] } serde_json.workspace = true diff --git a/templating/handlebars/src/main.rs b/templating/handlebars/src/main.rs index abffed2..ba36421 100644 --- a/templating/handlebars/src/main.rs +++ b/templating/handlebars/src/main.rs @@ -6,24 +6,24 @@ use actix_web::{ get, http::{header::ContentType, StatusCode}, middleware::{ErrorHandlerResponse, ErrorHandlers}, - web, App, HttpResponse, HttpServer, Result, + web, App, HttpResponse, HttpServer, Responder, Result, }; +use actix_web_lab::respond::Html; use handlebars::{DirectorySourceOptions, Handlebars}; use serde_json::json; -// Macro documentation can be found in the actix_web_codegen crate #[get("/")] -async fn index(hb: web::Data>) -> HttpResponse { +async fn index(hb: web::Data>) -> impl Responder { let data = json!({ "name": "Handlebars" }); let body = hb.render("index", &data).unwrap(); - HttpResponse::Ok().body(body) + Html(body) } #[get("/{user}/{data}")] -async fn user(hb: web::Data>, path: web::Path<(String, String)>) -> HttpResponse { +async fn user(hb: web::Data>, path: web::Path<(String, String)>) -> impl Responder { let info = path.into_inner(); let data = json!({ "user": info.0, @@ -31,18 +31,20 @@ async fn user(hb: web::Data>, path: web::Path<(String, String)>) }); let body = hb.render("user", &data).unwrap(); - HttpResponse::Ok().body(body) + Html(body) } #[actix_web::main] async fn main() -> io::Result<()> { + env_logger::init_from_env(env_logger::Env::new().default_filter_or("info")); + // Handlebars uses a repository for the compiled templates. This object must be // shared between the application threads, and is therefore passed to the // Application Builder as an atomic reference-counted pointer. let mut handlebars = Handlebars::new(); handlebars .register_templates_directory( - "./static/templates", + "./templates", DirectorySourceOptions { tpl_extension: ".html".to_owned(), hidden: false, @@ -59,6 +61,7 @@ async fn main() -> io::Result<()> { .service(index) .service(user) }) + .workers(2) .bind(("127.0.0.1", 8080))? .run() .await diff --git a/templating/handlebars/static/templates/error.html b/templating/handlebars/templates/error.html similarity index 100% rename from templating/handlebars/static/templates/error.html rename to templating/handlebars/templates/error.html diff --git a/templating/handlebars/static/templates/index.html b/templating/handlebars/templates/index.html similarity index 100% rename from templating/handlebars/static/templates/index.html rename to templating/handlebars/templates/index.html diff --git a/templating/handlebars/static/templates/user.html b/templating/handlebars/templates/user.html similarity index 100% rename from templating/handlebars/static/templates/user.html rename to templating/handlebars/templates/user.html From 6a50acecb3c72fdcc6bdfc88fcc9d9ca1a63b179 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:27:59 +0000 Subject: [PATCH 3/8] chore(deps): bump taiki-e/install-action from 2.27.10 to 2.28.1 Bumps [taiki-e/install-action](https://github.com/taiki-e/install-action) from 2.27.10 to 2.28.1. - [Release notes](https://github.com/taiki-e/install-action/releases) - [Changelog](https://github.com/taiki-e/install-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/taiki-e/install-action/compare/v2.27.10...v2.28.1) --- updated-dependencies: - dependency-name: taiki-e/install-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/ci-nightly.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-nightly.yml b/.github/workflows/ci-nightly.yml index 77d7482..c012a09 100644 --- a/.github/workflows/ci-nightly.yml +++ b/.github/workflows/ci-nightly.yml @@ -59,7 +59,7 @@ jobs: timeout-minutes: 10 - name: Install cargo-ci-cache-clean - uses: taiki-e/install-action@v2.27.10 + uses: taiki-e/install-action@v2.28.1 with: tool: cargo-ci-cache-clean diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52b93d9..604e0b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,7 +64,7 @@ jobs: timeout-minutes: 10 - name: Install cargo-ci-cache-clean - uses: taiki-e/install-action@v2.27.10 + uses: taiki-e/install-action@v2.28.1 with: tool: cargo-ci-cache-clean From 53d727e73603cbc7db2de8650429d723aa428452 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:10:06 +0000 Subject: [PATCH 4/8] chore(deps): bump log from 0.4.20 to 0.4.21 Bumps [log](https://github.com/rust-lang/log) from 0.4.20 to 0.4.21. - [Release notes](https://github.com/rust-lang/log/releases) - [Changelog](https://github.com/rust-lang/log/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/log/compare/0.4.20...0.4.21) --- updated-dependencies: - dependency-name: log dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29e9c59..fc88d7d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4611,9 +4611,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.20" +version = "0.4.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "lru" From e0e07633f1b42aa31cb3e05b854245da375a215c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:08:46 +0000 Subject: [PATCH 5/8] chore(deps): bump mongodb from 2.8.0 to 2.8.1 Bumps [mongodb](https://github.com/mongodb/mongo-rust-driver) from 2.8.0 to 2.8.1. - [Release notes](https://github.com/mongodb/mongo-rust-driver/releases) - [Commits](https://github.com/mongodb/mongo-rust-driver/compare/v2.8.0...v2.8.1) --- updated-dependencies: - dependency-name: mongodb dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc88d7d..0660ff1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4872,15 +4872,15 @@ name = "mongodb" version = "1.0.0" dependencies = [ "actix-web", - "mongodb 2.8.0", + "mongodb 2.8.1", "serde", ] [[package]] name = "mongodb" -version = "2.8.0" +version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c30763a5c6c52079602be44fa360ca3bfacee55fca73f4734aecd23706a7f2" +checksum = "de59562e5c71656c098d8e966641b31da87b89dc3dcb6e761d3b37dcdfa0cb72" dependencies = [ "async-trait", "base64 0.13.1", From 653098d0831931e689ce986432ca63446bbfc817 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:07:41 +0000 Subject: [PATCH 6/8] chore(deps): bump rust-argon2 from 2.0.0 to 2.1.0 Bumps [rust-argon2](https://github.com/sru-systems/rust-argon2) from 2.0.0 to 2.1.0. - [Changelog](https://github.com/sru-systems/rust-argon2/blob/master/CHANGELOG.md) - [Commits](https://github.com/sru-systems/rust-argon2/compare/2.0.0...2.1.0) --- updated-dependencies: - dependency-name: rust-argon2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0660ff1..c18f57e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6439,9 +6439,9 @@ dependencies = [ [[package]] name = "rust-argon2" -version = "2.0.0" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e71971821b3ae0e769e4a4328dbcb517607b434db7697e9aba17203ec14e46a" +checksum = "9d9848531d60c9cbbcf9d166c885316c24bc0e2a9d3eba0956bb6cbbd79bc6e8" dependencies = [ "base64 0.21.7", "blake2b_simd", From 511cc863e69a60f940a299281abc2ce5d2165d92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:06:18 +0000 Subject: [PATCH 7/8] chore(deps): bump actix-codec from 0.5.1 to 0.5.2 Bumps [actix-codec](https://github.com/actix/actix-net) from 0.5.1 to 0.5.2. - [Release notes](https://github.com/actix/actix-net/releases) - [Commits](https://github.com/actix/actix-net/compare/codec-v0.5.1...codec-v0.5.2) --- updated-dependencies: - dependency-name: actix-codec dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c18f57e..28e87c2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -86,11 +86,11 @@ dependencies = [ [[package]] name = "actix-codec" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "617a8268e3537fe1d8c9ead925fca49ef6400927ee7bc26750e90ecee14ce4b8" +checksum = "5f7b0a21988c1bf877cf4759ef5ddaac04c1c9fe808c9142ecb78ba97d97a28a" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", "bytes 1.5.0", "futures-core", "futures-sink", From 413a918bc28c360a8e006cd322e4db4447896029 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 17:46:06 +0000 Subject: [PATCH 8/8] chore(deps): bump actix-identity from 0.7.0 to 0.7.1 Bumps [actix-identity](https://github.com/actix/actix-extras) from 0.7.0 to 0.7.1. - [Release notes](https://github.com/actix/actix-extras/releases) - [Commits](https://github.com/actix/actix-extras/compare/cors-v0.7.0...session-v0.7.1) --- updated-dependencies: - dependency-name: actix-identity dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 28e87c2..3f6cb77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -218,9 +218,9 @@ dependencies = [ [[package]] name = "actix-identity" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1478456bca71c7b04411da1afb0c506e16dec6863815207693b791247511027f" +checksum = "f2c99b7a5614b72a78f04aa2021e5370fc1aef2475fffeffc0c1266b99007062" dependencies = [ "actix-service", "actix-session", @@ -8278,8 +8278,8 @@ version = "1.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ - "cfg-if 1.0.0", - "rand 0.8.5", + "cfg-if 0.1.10", + "rand 0.7.3", "static_assertions", ]