From deb8244597c76ad5300c37be1d7f817a4fa34149 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Sun, 18 Feb 2024 15:34:23 +0100 Subject: [PATCH] Fix leptos 0.6 migration --- .gitignore | 1 + Cargo.lock | 415 ++++------------------------------------- Cargo.toml | 6 +- src/app/pages/posts.rs | 59 +++--- 4 files changed, 70 insertions(+), 411 deletions(-) diff --git a/.gitignore b/.gitignore index f33a15c..0ffacff 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ dist-ssr # Added by cargo /target +.sass-cache/ \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 2c2c70e..2ce02c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -661,16 +661,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "core-foundation-sys" version = "0.8.6" @@ -1157,17 +1147,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.11", - "pin-project-lite", -] - [[package]] name = "http-range" version = "0.1.5" @@ -1186,30 +1165,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "hyper" -version = "0.14.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2", - "http 0.2.11", - "http-body", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1475,12 +1430,6 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f958d3d68f4167080a18141e10381e7634563984a537f2a49a30fd8e53ac5767" -[[package]] -name = "ipnet" -version = "2.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" - [[package]] name = "itertools" version = "0.12.1" @@ -1526,25 +1475,6 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" -[[package]] -name = "leptos" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "269ba4ba91ffa73d9559c975e0be17bd4eb34c6b6abd7fdd5704106132d89d2a" -dependencies = [ - "cfg-if", - "leptos_config 0.5.7", - "leptos_dom 0.5.7", - "leptos_macro 0.5.7", - "leptos_reactive 0.5.7", - "leptos_server 0.5.7", - "server_fn 0.5.7", - "tracing", - "typed-builder", - "typed-builder-macro", - "web-sys", -] - [[package]] name = "leptos" version = "0.6.5" @@ -1552,12 +1482,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c115de7c6fca2164133e18328777d02c371434ace38049ac02886b5cffd22dc" dependencies = [ "cfg-if", - "leptos_config 0.6.5", - "leptos_dom 0.6.5", - "leptos_macro 0.6.5", - "leptos_reactive 0.6.5", - "leptos_server 0.6.5", - "server_fn 0.6.5", + "leptos_config", + "leptos_dom", + "leptos_macro", + "leptos_reactive", + "leptos_server", + "server_fn", "tracing", "typed-builder", "typed-builder-macro", @@ -1574,32 +1504,19 @@ dependencies = [ "actix-http", "actix-web", "futures", - "leptos 0.6.5", + "leptos", "leptos_integration_utils", - "leptos_macro 0.6.5", + "leptos_macro", "leptos_meta", "leptos_router", "parking_lot", "regex", "serde_json", - "server_fn 0.6.5", + "server_fn", "tokio", "tracing", ] -[[package]] -name = "leptos_config" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e72d8689d54737991831e9b279bb4fba36d27a93aa975c75cd4241d9a4a425ec" -dependencies = [ - "config", - "regex", - "serde", - "thiserror", - "typed-builder", -] - [[package]] name = "leptos_config" version = "0.6.5" @@ -1613,36 +1530,6 @@ dependencies = [ "typed-builder", ] -[[package]] -name = "leptos_dom" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad314950d41acb1bfdb8b5924811b2983484a8d6f69a20b834a173a682657ed4" -dependencies = [ - "async-recursion", - "cfg-if", - "drain_filter_polyfill", - "futures", - "getrandom", - "html-escape", - "indexmap", - "itertools", - "js-sys", - "leptos_reactive 0.5.7", - "once_cell", - "pad-adapter", - "paste", - "rustc-hash", - "serde", - "serde_json", - "server_fn 0.5.7", - "smallvec", - "tracing", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "leptos_dom" version = "0.6.5" @@ -1658,14 +1545,14 @@ dependencies = [ "indexmap", "itertools", "js-sys", - "leptos_reactive 0.6.5", + "leptos_reactive", "once_cell", "pad-adapter", "paste", "rustc-hash", "serde", "serde_json", - "server_fn 0.6.5", + "server_fn", "smallvec", "tracing", "wasm-bindgen", @@ -1673,24 +1560,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "leptos_hot_reload" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f62dcab17728877f2d2f16d2c8a6701c4c5fbdfb4964792924acb0b50529659" -dependencies = [ - "anyhow", - "camino", - "indexmap", - "parking_lot", - "proc-macro2", - "quote", - "rstml", - "serde", - "syn 2.0.49", - "walkdir", -] - [[package]] name = "leptos_hot_reload" version = "0.6.5" @@ -1711,14 +1580,15 @@ dependencies = [ [[package]] name = "leptos_icons" -version = "0.2.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0477a66b90ed94d3b3e9472247189359426c1b6313f8589d3f2edf3fdf676b" +checksum = "584bccafed73138f4d700f936e6a82268efec2df9a2f9d74e1ee80985653413e" dependencies = [ + "bytes", "encoding_rs", "icondata_core", "lazy_static", - "leptos 0.5.7", + "leptos", "log", "paste", ] @@ -1730,36 +1600,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "700bdb6d9d754964b576fa3b76a28a68adbd6ced6d7dc84a18e29e91a82c2376" dependencies = [ "futures", - "leptos 0.6.5", - "leptos_config 0.6.5", - "leptos_hot_reload 0.6.5", + "leptos", + "leptos_config", + "leptos_hot_reload", "leptos_meta", "tracing", ] -[[package]] -name = "leptos_macro" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57955d66f624265222444a5c565fea38efa5b0152a1dfc7c060a78e5fb62a852" -dependencies = [ - "attribute-derive", - "cfg-if", - "convert_case 0.6.0", - "html-escape", - "itertools", - "leptos_hot_reload 0.5.7", - "prettyplease", - "proc-macro-error", - "proc-macro2", - "quote", - "rstml", - "server_fn_macro 0.5.7", - "syn 2.0.49", - "tracing", - "uuid", -] - [[package]] name = "leptos_macro" version = "0.6.5" @@ -1771,13 +1618,13 @@ dependencies = [ "convert_case 0.6.0", "html-escape", "itertools", - "leptos_hot_reload 0.6.5", + "leptos_hot_reload", "prettyplease", "proc-macro-error", "proc-macro2", "quote", "rstml", - "server_fn_macro 0.6.5", + "server_fn_macro", "syn 2.0.49", "tracing", "uuid", @@ -1791,35 +1638,12 @@ checksum = "4bbbbd77839b4d3189c06319b32aaa3bc43510fb43f9c1bffb8e124a33decd6c" dependencies = [ "cfg-if", "indexmap", - "leptos 0.6.5", + "leptos", "tracing", "wasm-bindgen", "web-sys", ] -[[package]] -name = "leptos_reactive" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4f54a525a0edfc8c2bf3ee92aae411800b8b10892c9cd819f8e8a6d4f0d62f3" -dependencies = [ - "base64", - "cfg-if", - "futures", - "indexmap", - "paste", - "pin-project", - "rustc-hash", - "self_cell", - "serde", - "serde-wasm-bindgen 0.5.0", - "serde_json", - "slotmap", - "thiserror", - "tracing", - "wasm-bindgen-futures", -] - [[package]] name = "leptos_reactive" version = "0.6.5" @@ -1837,7 +1661,7 @@ dependencies = [ "rustc-hash", "self_cell", "serde", - "serde-wasm-bindgen 0.6.3", + "serde-wasm-bindgen", "serde_json", "slotmap", "thiserror", @@ -1860,7 +1684,7 @@ dependencies = [ "itertools", "js-sys", "lazy_static", - "leptos 0.6.5", + "leptos", "leptos_integration_utils", "leptos_meta", "linear-map", @@ -1880,22 +1704,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "leptos_server" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fd1517c2024bc47d764e96053e55b927f8a2159e735a0cc47232542b493df9d" -dependencies = [ - "inventory", - "lazy_static", - "leptos_macro 0.5.7", - "leptos_reactive 0.5.7", - "serde", - "server_fn 0.5.7", - "thiserror", - "tracing", -] - [[package]] name = "leptos_server" version = "0.6.5" @@ -1904,10 +1712,10 @@ checksum = "f06b9b860479385991fad54cbee372382aee3c1e75ca78b5da6f8bda90c153e1" dependencies = [ "inventory", "lazy_static", - "leptos_macro 0.6.5", - "leptos_reactive 0.6.5", + "leptos_macro", + "leptos_reactive", "serde", - "server_fn 0.6.5", + "server_fn", "thiserror", "tracing", ] @@ -2198,7 +2006,7 @@ dependencies = [ "gloo-net 0.5.0", "gray_matter", "icondata", - "leptos 0.6.5", + "leptos", "leptos_actix", "leptos_icons", "leptos_meta", @@ -2312,16 +2120,23 @@ dependencies = [ [[package]] name = "pulldown-cmark" -version = "0.9.6" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b" +checksum = "dce76ce678ffc8e5675b22aa1405de0b7037e2fdf8913fea40d1926c6fe1e6e7" dependencies = [ "bitflags 2.4.2", "getopts", "memchr", + "pulldown-cmark-escape", "unicase", ] +[[package]] +name = "pulldown-cmark-escape" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5d8f9aa0e3cbcfaf8bf00300004ee3b72f74770f9cbac93f6928771f613276b" + [[package]] name = "quote" version = "1.0.35" @@ -2437,42 +2252,6 @@ dependencies = [ "bytecheck", ] -[[package]] -name = "reqwest" -version = "0.11.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6920094eb85afde5e4a138be3f2de8bbdf28000f0029e72c45025a56b042251" -dependencies = [ - "base64", - "bytes", - "encoding_rs", - "futures-core", - "futures-util", - "h2", - "http 0.2.11", - "http-body", - "hyper", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "system-configuration", - "tokio", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "winreg", -] - [[package]] name = "rkyv" version = "0.7.44" @@ -2594,17 +2373,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-wasm-bindgen" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3b143e2833c57ab9ad3ea280d21fd34e285a42837aeb0ee301f4f41890fa00e" -dependencies = [ - "js-sys", - "serde", - "wasm-bindgen", -] - [[package]] name = "serde-wasm-bindgen" version = "0.6.3" @@ -2683,30 +2451,6 @@ dependencies = [ "unsafe-libyaml", ] -[[package]] -name = "server_fn" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c265de965fe48e09ad8899d0ab1ffebdfa1a9914e4de5ff107b07bd94cf7541" -dependencies = [ - "ciborium", - "const_format", - "gloo-net 0.2.6", - "js-sys", - "lazy_static", - "once_cell", - "proc-macro2", - "quote", - "reqwest", - "serde", - "serde_json", - "serde_qs", - "server_fn_macro_default 0.5.7", - "syn 2.0.49", - "thiserror", - "xxhash-rust", -] - [[package]] name = "server_fn" version = "0.6.5" @@ -2728,7 +2472,7 @@ dependencies = [ "serde", "serde_json", "serde_qs", - "server_fn_macro_default 0.6.5", + "server_fn_macro_default", "thiserror", "url", "wasm-bindgen", @@ -2738,21 +2482,6 @@ dependencies = [ "xxhash-rust", ] -[[package]] -name = "server_fn_macro" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f77000541a62ceeec01eef3ee0f86c155c33dac5fae750ad04a40852c6d5469a" -dependencies = [ - "const_format", - "proc-macro-error", - "proc-macro2", - "quote", - "serde", - "syn 2.0.49", - "xxhash-rust", -] - [[package]] name = "server_fn_macro" version = "0.6.5" @@ -2767,23 +2496,13 @@ dependencies = [ "xxhash-rust", ] -[[package]] -name = "server_fn_macro_default" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a3353f22e2bcc451074d4feaa37317d9d17dff11d4311928384734ea17ab9ca" -dependencies = [ - "server_fn_macro 0.5.7", - "syn 2.0.49", -] - [[package]] name = "server_fn_macro_default" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "752ed78ec49132d154b922cf5ab6485680cab039a75740c48ea2db621ad481da" dependencies = [ - "server_fn_macro 0.6.5", + "server_fn_macro", "syn 2.0.49", ] @@ -2900,33 +2619,6 @@ dependencies = [ "syn 2.0.49", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - -[[package]] -name = "system-configuration" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" -dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "system-configuration-sys", -] - -[[package]] -name = "system-configuration-sys" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "tap" version = "1.0.1" @@ -3041,12 +2733,6 @@ dependencies = [ "serde", ] -[[package]] -name = "tower-service" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" - [[package]] name = "tracing" version = "0.1.40" @@ -3079,12 +2765,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typed-builder" version = "0.18.1" @@ -3213,15 +2893,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -3480,16 +3151,6 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" -[[package]] -name = "winreg" -version = "0.50.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" -dependencies = [ - "cfg-if", - "windows-sys", -] - [[package]] name = "wyz" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index 6bf4e44..3561c7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ serde = "1.0" chrono = { version = "0.4", features = ["serde"] } # https://carlosted.github.io/icondata/ -leptos_icons = "0.2" +leptos_icons = "0.3" icondata = "0.3" # dependecies for client (enable when csr or hydrate set) @@ -29,11 +29,11 @@ console_error_panic_hook = { version = "0.1", optional = true } # dependecies for server (enable when ssr set) actix-files = { version = "0.6", optional = true } -actix-web = { version = "4.4", features = ["macros"], optional = true } +actix-web = { version = "4.5", features = ["macros"], optional = true } leptos_actix = { version = "0.6", optional = true } futures = { version = "0.3", optional = true } simple_logger = { version = "4.3", optional = true } -pulldown-cmark = { version = "0.9", optional = true } # Markdown parser +pulldown-cmark = { version = "0.10", optional = true } # Markdown parser gray_matter = { version = "0.2", optional = true } # frontmatter parser serde_yaml = { version = "0.9", optional = true } anyhow = { version = "1.0", optional = true } diff --git a/src/app/pages/posts.rs b/src/app/pages/posts.rs index 6c843fb..caf58e3 100644 --- a/src/app/pages/posts.rs +++ b/src/app/pages/posts.rs @@ -11,42 +11,39 @@ use crate::app::{ pub async fn get_posts( tag: Option ) -> Result, ServerFnError> { - leptos_actix::extract( - |data: actix_web::web::Data| async move { - let data = data.into_inner(); - let default = vec![]; - let posts = match tag { - Some(tag) => data.posts_by_tag.get(&tag).unwrap_or(&default), - None => &data.posts - }; - posts.iter() - .map(|post| { - Post { - metadata: post.metadata.clone(), - content: post.content.clone(), - } - }) - .collect::, >() - }, - ).await + let data : actix_web::web::Data = leptos_actix::extract().await?; + let data = data.into_inner(); + + let default = vec![]; + let posts = match tag { + Some(tag) => data.posts_by_tag.get(&tag).unwrap_or(&default), + None => &data.posts + }; + + Ok( + posts.iter() + .map(|post| { + Post { + metadata: post.metadata.clone(), + content: post.content.clone(), + } + }) + .collect::, >() + ) } #[server] pub async fn get_post( slug: String ) -> Result { - leptos_actix::extract( - |data: actix_web::web::Data| async move { - let data = data.into_inner(); - data.posts_by_slug.get(&slug) - .and_then(|post| Some(Post { - metadata: post.metadata.clone(), - content: post.content.clone(), - })) - }, - ) - .await - .and_then(|post| post.ok_or_else(|| ServerFnError::ServerError("Post not found".to_string()))) + let data : actix_web::web::Data = leptos_actix::extract().await?; + let data = data.into_inner(); + + data.posts_by_slug.get(&slug).map(|post| Post { + metadata: post.metadata.clone(), + content: post.content.clone(), + }) + .ok_or(ServerFnError::ServerError("Post not found".to_string())) } #[component] @@ -130,7 +127,7 @@ pub fn PostList() -> impl IntoView { }; let filter_view = move || { - tag().and_then(|tag| Some(view! { + tag().map(|tag| Some(view! {
Tag sélectionné : {tag}