From f37ebd04453963c36b5f647b53b868f32474cb00 Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Wed, 31 Jan 2024 21:24:17 -0500 Subject: [PATCH] sketch layout --- Cargo.lock | 88 +++++++++++++++---------------- app/src/components/api.rs | 18 ++++--- app/src/components/ui/articles.rs | 19 ++++--- app/src/components/ui/cards.rs | 30 +++++++++-- app/src/lib.rs | 6 ++- app/src/routes.rs | 3 +- app/src/routes/blog.rs | 2 +- app/src/routes/games.rs | 20 +++++++ app/src/routes/home.rs | 26 ++------- app/src/routes/projects.rs | 25 ++------- 10 files changed, 128 insertions(+), 109 deletions(-) create mode 100644 app/src/routes/games.rs diff --git a/Cargo.lock b/Cargo.lock index a8abe30..c779b60 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -974,7 +974,7 @@ dependencies = [ "futures-sink", "futures-util", "http 1.0.0", - "indexmap 2.2.1", + "indexmap 2.2.2", "slab", "tokio", "tokio-util", @@ -1176,12 +1176,11 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67" +checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" dependencies = [ "bytes", - "futures-channel", "futures-util", "http 1.0.0", "http-body", @@ -1189,7 +1188,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tracing", ] [[package]] @@ -1226,9 +1224,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.1" +version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b" +checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520" dependencies = [ "equivalent", "hashbrown 0.14.3", @@ -1290,9 +1288,9 @@ dependencies = [ [[package]] name = "leptos" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13156caccc40bb71d687bed455b7d644ac69ecb5a5c180c2809ba52df863a99a" +checksum = "0c115de7c6fca2164133e18328777d02c371434ace38049ac02886b5cffd22dc" dependencies = [ "cfg-if", "leptos_config", @@ -1312,9 +1310,9 @@ dependencies = [ [[package]] name = "leptos_axum" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47756bd25127a3cc5eb33535cafe7199d669fffd5f12d2a9a37757b7399556c9" +checksum = "933ce9f409dd29ce429eb457f928d1cb48ebd39386d2dfe2f78d366e78cf7842" dependencies = [ "axum", "cfg-if", @@ -1336,9 +1334,9 @@ dependencies = [ [[package]] name = "leptos_config" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cee343145b16836df6847d7da0db6f7f0a3f53f860e6b771bdeebb6da7f0ed" +checksum = "055262ff3660e95ec95cadd8a05a02070d624354e08e30b99c14a81023feb2dc" dependencies = [ "config", "regex", @@ -1349,9 +1347,9 @@ dependencies = [ [[package]] name = "leptos_dom" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf6c02444169c390660bb8975adf064daf3f24f40b2d3f25618e5c0bbbe89cb5" +checksum = "adfea7feb9c488448db466ca0673b691ec2a05efb0b2bc6626b7248ee04bb39c" dependencies = [ "async-recursion", "cfg-if", @@ -1359,7 +1357,7 @@ dependencies = [ "futures", "getrandom", "html-escape", - "indexmap 2.2.1", + "indexmap 2.2.2", "itertools", "js-sys", "leptos_reactive", @@ -1379,13 +1377,13 @@ dependencies = [ [[package]] name = "leptos_hot_reload" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11bf126e9ac0597cda4156f14dea23627d90d53ade182a537b234b7e131e0096" +checksum = "3ba8f68f7c3135975eb34ed19210272ebef2d6f422d138ff87a726b8793fe105" dependencies = [ "anyhow", "camino", - "indexmap 2.2.1", + "indexmap 2.2.2", "parking_lot", "proc-macro2", "quote", @@ -1397,9 +1395,9 @@ dependencies = [ [[package]] name = "leptos_integration_utils" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55eb3cbc78aa67790799ef480270bef3d10e23f0a38e6fa3e4e42d797f931a13" +checksum = "700bdb6d9d754964b576fa3b76a28a68adbd6ced6d7dc84a18e29e91a82c2376" dependencies = [ "futures", "leptos", @@ -1411,9 +1409,9 @@ dependencies = [ [[package]] name = "leptos_macro" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b859592ff768b01122733ac03a72507849e7ea2f640c63bb1c3487a5dc7a0891" +checksum = "039c510dafb7d9997e4b8accfcced5675fabc65720caf544592df32432d6d65a" dependencies = [ "attribute-derive", "cfg-if", @@ -1434,12 +1432,12 @@ dependencies = [ [[package]] name = "leptos_meta" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4705c24a835c3e8a158a351fee971d9efb0060a9817f719a79e22666dd112558" +checksum = "4bbbbd77839b4d3189c06319b32aaa3bc43510fb43f9c1bffb8e124a33decd6c" dependencies = [ "cfg-if", - "indexmap 2.2.1", + "indexmap 2.2.2", "leptos", "tracing", "wasm-bindgen", @@ -1448,14 +1446,14 @@ dependencies = [ [[package]] name = "leptos_reactive" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c5f08f2392b01cc5fc9223eeb92c70b40d366354ffbfb1c6761c9e621a8f966" +checksum = "b30c5bc7f3496d6ba399578171cf133c50d2172f9791fe292db4da2fd0d8cec4" dependencies = [ "base64", "cfg-if", "futures", - "indexmap 2.2.1", + "indexmap 2.2.2", "js-sys", "paste", "pin-project", @@ -1476,9 +1474,9 @@ dependencies = [ [[package]] name = "leptos_router" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28334116fab9b903b31c8f6d2be254e86dd35265db6e0c0f5cfbc7b6c18ea0ef" +checksum = "498159479603569e1d7c969cffa0817b73249e96f825c295743f8f4607a68cbe" dependencies = [ "cached", "cfg-if", @@ -1508,9 +1506,9 @@ dependencies = [ [[package]] name = "leptos_server" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d6baa84d07a5869261e1dc606058886f1a79d6bf89b7b138cf25bae30983b76" +checksum = "f06b9b860479385991fad54cbee372382aee3c1e75ca78b5da6f8bda90c153e1" dependencies = [ "inventory", "lazy_static", @@ -1524,9 +1522,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.152" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libm" @@ -2430,9 +2428,9 @@ dependencies = [ [[package]] name = "server_fn" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f27208122b0fa6d2b90b7dc25de60294e28647efd43b4c8abaf7df86227931a5" +checksum = "97fab54d9dd2d7e9eba4efccac41d2ec3e7c6e9973d14c0486d662a32662320c" dependencies = [ "axum", "bytes", @@ -2465,9 +2463,9 @@ dependencies = [ [[package]] name = "server_fn_macro" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8d7a5a1c0f78f261dbb8cf16281020552a1d518dbcb8501b33b8edae02b781b" +checksum = "3be6011b586a0665546b7ced372b0be690d9e005d3f8524795da2843274d7720" dependencies = [ "const_format", "convert_case", @@ -2479,9 +2477,9 @@ dependencies = [ [[package]] name = "server_fn_macro_default" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29d13a68cc5b1ff8a3259e3ae984b91559268f0e5a7a8b0216f55b05307df5cb" +checksum = "752ed78ec49132d154b922cf5ab6485680cab039a75740c48ea2db621ad481da" dependencies = [ "server_fn_macro", "syn 2.0.48", @@ -2650,7 +2648,7 @@ dependencies = [ "futures-util", "hashlink", "hex", - "indexmap 2.2.1", + "indexmap 2.2.2", "log", "memchr", "once_cell", @@ -3024,7 +3022,7 @@ version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ - "indexmap 2.2.1", + "indexmap 2.2.2", "serde", "serde_spanned", "toml_datetime", @@ -3664,9 +3662,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.35" +version = "0.5.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d" +checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" dependencies = [ "memchr", ] diff --git a/app/src/components/api.rs b/app/src/components/api.rs index 6e64c9c..0468472 100644 --- a/app/src/components/api.rs +++ b/app/src/components/api.rs @@ -1,17 +1,21 @@ +use crate::components::ui::articles::*; use leptos::*; -use crate::components::ui::articles::Article; #[server] -pub async fn get_blog_posts() -> Result, ServerFnError> { +pub async fn get_articles(article_type: ArticleType) -> Result, ServerFnError> { use sqlx::*; + let query = match article_type { + ArticleType::All => "select * from blog order by date", + ArticleType::Blog => "select * from blog where content_type like 'blog'", + ArticleType::Game => "select * from blog where content_type like 'game'", + ArticleType::Project => "select * from blog where content_type like 'project'", + }; let pool: SqlitePool = use_context::().expect("couldn't get pool context"); - let result = - sqlx::query_as::<_, Article>("select * from blog where content_type like 'game'") - .fetch_all(&pool) - .await?; + let result = sqlx::query_as::<_, Article>(query) + .fetch_all(&pool) + .await?; Ok(result) } - diff --git a/app/src/components/ui/articles.rs b/app/src/components/ui/articles.rs index f6cd685..1bdcb47 100644 --- a/app/src/components/ui/articles.rs +++ b/app/src/components/ui/articles.rs @@ -1,5 +1,5 @@ -use crate::components::ui::containers::*; use crate::components::api::*; +use crate::components::ui::containers::*; use leptos::*; use serde::*; @@ -12,6 +12,14 @@ pub struct Article { pub content: String, } +#[derive(Clone, Copy, Debug, Serialize, Deserialize)] +pub enum ArticleType { + All, + Blog, + Game, + Project, +} + #[component] pub fn Article(data: Article) -> impl IntoView { view! { @@ -29,12 +37,9 @@ pub fn Article(data: Article) -> impl IntoView { } #[component] -pub fn ArticleBuilder() -> impl IntoView { - let data_resource = create_local_resource( - || (), - |_| async move { get_blog_posts().await }, - // |_| async move { slingshot("./public/blog".to_string()).await }, - ); +pub fn ArticleBuilder(article_type: ArticleType) -> impl IntoView { + let data_resource = + create_local_resource(|| (), move |_| async move { get_articles(article_type).await }); let articles_view = move || { data_resource.and_then(|data| { diff --git a/app/src/components/ui/cards.rs b/app/src/components/ui/cards.rs index bee7dbe..8da563e 100644 --- a/app/src/components/ui/cards.rs +++ b/app/src/components/ui/cards.rs @@ -1,17 +1,21 @@ +use crate::components::ui::articles::*; use leptos::*; +use crate::components::api::get_articles; + #[component] -pub fn Card(children: Children) -> impl IntoView { +pub fn Card(data: Article) -> impl IntoView { view! {

- "Card Header" + {&data.title}


+ {&data.date}

"[image]"

- {children()} +

Read more...

@@ -20,6 +24,22 @@ pub fn Card(children: Children) -> impl IntoView { } #[component] -pub fn CardHolder(children: Children) -> impl IntoView { - view! {
{children()}
} +pub fn CardBuilder(article_type: ArticleType) -> impl IntoView { + let data_resource = create_local_resource( + || (), + move |_| async move { get_articles(article_type).await }, + ); + + let cards_view = move || { + data_resource.and_then(|data| { + data.iter() + .map(|article| view! { }) + .collect_view() + }) + }; + view! { +
+ {cards_view} +
+ } } diff --git a/app/src/lib.rs b/app/src/lib.rs index 779d9f6..49cc55f 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -8,7 +8,7 @@ pub mod components; pub mod error_template; pub mod routes; -use crate::routes::{blog::Blog, home::Home, projects::Projects}; +use crate::routes::{blog::Blog, games::Games, home::Home, projects::Projects}; #[component] pub fn App() -> impl IntoView { @@ -38,6 +38,9 @@ pub fn App() -> impl IntoView {
  • "Projects"
  • +
  • + "Games" +
  • "Git"
  • @@ -48,6 +51,7 @@ pub fn App() -> impl IntoView { +

    diff --git a/app/src/routes.rs b/app/src/routes.rs index a28ef14..a0d0eb7 100644 --- a/app/src/routes.rs +++ b/app/src/routes.rs @@ -1,3 +1,4 @@ -pub mod home; pub mod blog; +pub mod games; +pub mod home; pub mod projects; diff --git a/app/src/routes/blog.rs b/app/src/routes/blog.rs index f47a70a..4ca740c 100644 --- a/app/src/routes/blog.rs +++ b/app/src/routes/blog.rs @@ -12,7 +12,7 @@ pub fn Blog() -> impl IntoView { } }> - + } diff --git a/app/src/routes/games.rs b/app/src/routes/games.rs new file mode 100644 index 0000000..38e8ca3 --- /dev/null +++ b/app/src/routes/games.rs @@ -0,0 +1,20 @@ +use crate::components::ui::articles::*; +use crate::components::ui::cards::*; +use crate::error_template::*; +use leptos::*; + +#[island] +pub fn Games() -> impl IntoView { + + view! { + "Loading..."

    } + }> + } + }> + + + + } +} diff --git a/app/src/routes/home.rs b/app/src/routes/home.rs index 8d44fa8..31f0b42 100644 --- a/app/src/routes/home.rs +++ b/app/src/routes/home.rs @@ -1,9 +1,11 @@ +use crate::components::ui::articles::*; use crate::components::ui::cards::*; use crate::error_template::*; use leptos::*; -#[component] +#[island] pub fn Home() -> impl IntoView { + view! { "Loading..."

    } @@ -11,26 +13,8 @@ pub fn Home() -> impl IntoView { } }> -

    Latest Stuff or whatever

    - - - -

    {"home1"}

    -
    - -

    {"home2"}

    -
    - -

    {"home3"}

    -
    - -

    {"home4"}

    -
    - -

    {"home5"}

    -
    -
    - + +
    } diff --git a/app/src/routes/projects.rs b/app/src/routes/projects.rs index 21951f1..9d5604a 100644 --- a/app/src/routes/projects.rs +++ b/app/src/routes/projects.rs @@ -1,9 +1,10 @@ -use crate::components::ui::cards::*; +use crate::components::ui::articles::*; use crate::error_template::*; use leptos::*; -#[component] +#[island] pub fn Projects() -> impl IntoView { + view! { "Loading..."

    } @@ -11,25 +12,7 @@ pub fn Projects() -> impl IntoView { } }> - - - -

    {"project1"}

    -
    - -

    {"project2"}

    -
    - -

    {"project3"}

    -
    - -

    {"project4"}

    -
    - -

    {"project5"}

    -
    -
    - +
    }