diff --git a/Cargo.lock b/Cargo.lock index ba96d2d..ea17551 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1227,9 +1227,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.59" +version = "0.1.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" +checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2990,9 +2990,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.35.1" +version = "1.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" +checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931" dependencies = [ "backtrace", "bytes", @@ -3546,9 +3546,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.25.3" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" [[package]] name = "whoami" @@ -3730,9 +3730,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.36" +version = "0.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" +checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" dependencies = [ "memchr", ] diff --git a/app/src/components/api.rs b/app/src/components/api.rs index 42012ce..75cf0b2 100644 --- a/app/src/components/api.rs +++ b/app/src/components/api.rs @@ -1,3 +1,6 @@ +use core::time; +use std::time::Duration; + use leptos::*; use serde::{Deserialize, Serialize}; @@ -26,12 +29,15 @@ pub async fn get_articles(article_type: ArticleType) -> Result, Ser ArticleType::All => "select * from blog order by date desc", ArticleType::Blog => "select * from blog where content_type like 'blog' order by date desc", ArticleType::Game => "select * from blog where content_type like 'game' order by date desc", - ArticleType::Project => "select * from blog where content_type like 'project' order by date desc", + ArticleType::Project => { + "select * from blog where content_type like 'project' order by date desc" + } }; let pool: SqlitePool = use_context::().expect("couldn't get pool context"); let articles: Vec
= sqlx::query_as::<_, Article>(query).fetch_all(&pool).await?; + std::thread::sleep(time::Duration::from_millis(2000)); Ok(articles) } diff --git a/app/src/components/ui.rs b/app/src/components/ui.rs index 3868772..f4cc78a 100644 --- a/app/src/components/ui.rs +++ b/app/src/components/ui.rs @@ -1,3 +1,4 @@ pub mod articles; pub mod cards; pub mod containers; +pub mod skeletons; diff --git a/app/src/components/ui/cards.rs b/app/src/components/ui/cards.rs index 98a32c3..177ef9d 100644 --- a/app/src/components/ui/cards.rs +++ b/app/src/components/ui/cards.rs @@ -6,7 +6,7 @@ use crate::components::api::get_articles; #[component] pub fn Card(data: Article) -> impl IntoView { view! { -
+

{&data.title}


{&data.date} @@ -35,5 +35,9 @@ pub fn CardBuilder(article_type: ArticleType) -> impl IntoView { .collect_view() }) }; - view! {
{cards_view}
} + view! { +
+ {cards_view} +
+ } } diff --git a/app/src/components/ui/skeletons.rs b/app/src/components/ui/skeletons.rs new file mode 100644 index 0000000..93abfbc --- /dev/null +++ b/app/src/components/ui/skeletons.rs @@ -0,0 +1,16 @@ +use leptos::*; +use crate::components::ui::containers::*; + +#[component] +pub fn Skeleton() -> impl IntoView { + view! { + +
+
+ "███████▒▒▒ 69%" +
+
+
+ } +} + diff --git a/app/src/error_template.rs b/app/src/error_template.rs index cb7bbdc..3db10e3 100644 --- a/app/src/error_template.rs +++ b/app/src/error_template.rs @@ -1,3 +1,4 @@ +use crate::components::ui::containers::*; use http::status::StatusCode; use leptos::*; use thiserror::Error; @@ -35,22 +36,22 @@ pub fn ErrorTemplate( println!("Errors: {errors:#?}"); view! { -
-

- {if errors.len() > 1 { "Errors!" } else { "Error!" }} -

-
+ +
+

+ {if errors.len() > 1 { "Errors" } else { "Error" }} +

+
+
    + {move || { + errors + .into_iter() + .map(|e: &_| view! {
  • {e.to_string()}
  • }) + .collect_view() + }} -
      - {move || { - errors - .into_iter() - .map(|e: &_| view! {
    • {e.to_string()}
    • }) - .collect_view() - }} - -
    - -
+ +
+ } } diff --git a/app/src/lib.rs b/app/src/lib.rs index 49cc55f..8ac2c10 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -32,15 +32,15 @@ pub fn App() -> impl IntoView { "Home" -
  • - "Blog" -
  • "Projects"
  • "Games"
  • +
  • + "Blog" +
  • "Git"
  • @@ -49,9 +49,9 @@ pub fn App() -> impl IntoView {
    - +

    diff --git a/app/src/routes/blog.rs b/app/src/routes/blog.rs index cd35cfb..cae6214 100644 --- a/app/src/routes/blog.rs +++ b/app/src/routes/blog.rs @@ -1,5 +1,6 @@ use crate::components::api::ArticleType; use crate::components::ui::articles::ArticleBuilder; +use crate::components::ui::skeletons::*; use crate::error_template::*; use leptos::*; @@ -7,7 +8,7 @@ use leptos::*; pub fn Blog() -> impl IntoView { view! { "Loading..."

    } + view! { } }> } diff --git a/app/src/routes/games.rs b/app/src/routes/games.rs index be8b0b5..50f3941 100644 --- a/app/src/routes/games.rs +++ b/app/src/routes/games.rs @@ -1,5 +1,6 @@ use crate::components::api::ArticleType; use crate::components::ui::cards::*; +use crate::components::ui::skeletons::*; use crate::error_template::*; use leptos::*; @@ -8,7 +9,7 @@ pub fn Games() -> impl IntoView { view! { "Loading..."

    } + view! { } }> } diff --git a/app/src/routes/home.rs b/app/src/routes/home.rs index 3b1ea7f..90b11f6 100644 --- a/app/src/routes/home.rs +++ b/app/src/routes/home.rs @@ -1,15 +1,15 @@ use crate::components::api::ArticleType; use crate::components::ui::articles::ArticleBuilder; use crate::components::ui::cards::*; +use crate::components::ui::skeletons::*; use crate::error_template::*; use leptos::*; #[island] pub fn Home() -> impl IntoView { - view! { "Loading..."

    } + view! { } }> } diff --git a/app/src/routes/projects.rs b/app/src/routes/projects.rs index 9a1fef3..dda3c08 100644 --- a/app/src/routes/projects.rs +++ b/app/src/routes/projects.rs @@ -1,5 +1,6 @@ use crate::components::api::ArticleType; use crate::components::ui::articles::ArticleBuilder; +use crate::components::ui::skeletons::*; use crate::error_template::*; use leptos::*; @@ -7,7 +8,7 @@ use leptos::*; pub fn Projects() -> impl IntoView { view! { "Loading..."

    } + view! { } }> } diff --git a/server/src/db.rs b/server/src/db.rs index 5ab7789..7989680 100644 --- a/server/src/db.rs +++ b/server/src/db.rs @@ -3,7 +3,7 @@ use leptos::*; use serde::*; use sqlx::*; -pub async fn db_build(pool: SqlitePool) -> Result<(), ServerFnError> { +pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> { let _res = query( " CREATE TABLE @@ -15,7 +15,7 @@ pub async fn db_build(pool: SqlitePool) -> Result<(), ServerFnError> { ) ", ) - .execute(&pool) + .execute(pool) .await?; // println!("{:?}", _res); @@ -63,7 +63,7 @@ pub async fn db_build(pool: SqlitePool) -> Result<(), ServerFnError> { .bind(article.title) .bind(article.date) .bind(article.content) - .execute(&pool) + .execute(pool) .await?; // println!("{:?}", _res); diff --git a/server/src/main.rs b/server/src/main.rs index a745d97..d1ff2c8 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -16,7 +16,7 @@ async fn main() { let routes = generate_route_list(App); let pool = start_pool().await.expect("pool error"); - let _ = db_build(pool.clone()).await.unwrap(); + let _ = db_build(&pool).await.expect("build error"); let app = Router::new() .leptos_routes_with_context(