yolo cause solo

This commit is contained in:
Adam 2024-02-03 16:09:28 -05:00
parent 2e7024222e
commit 92f42d5bd9
13 changed files with 71 additions and 40 deletions

16
Cargo.lock generated
View file

@ -1227,9 +1227,9 @@ dependencies = [
[[package]] [[package]]
name = "iana-time-zone" name = "iana-time-zone"
version = "0.1.59" version = "0.1.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539" checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"core-foundation-sys", "core-foundation-sys",
@ -2990,9 +2990,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.35.1" version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104" checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",
@ -3546,9 +3546,9 @@ dependencies = [
[[package]] [[package]]
name = "webpki-roots" name = "webpki-roots"
version = "0.25.3" version = "0.25.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1778a42e8b3b90bff8d0f5032bf22250792889a5cdc752aa0020c84abe3aaf10" checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1"
[[package]] [[package]]
name = "whoami" name = "whoami"
@ -3730,9 +3730,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]] [[package]]
name = "winnow" name = "winnow"
version = "0.5.36" version = "0.5.37"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249" checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5"
dependencies = [ dependencies = [
"memchr", "memchr",
] ]

View file

@ -1,3 +1,6 @@
use core::time;
use std::time::Duration;
use leptos::*; use leptos::*;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -26,12 +29,15 @@ pub async fn get_articles(article_type: ArticleType) -> Result<Vec<Article>, Ser
ArticleType::All => "select * from blog order by date desc", ArticleType::All => "select * from blog order by date desc",
ArticleType::Blog => "select * from blog where content_type like '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::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::<SqlitePool>().expect("couldn't get pool context"); let pool: SqlitePool = use_context::<SqlitePool>().expect("couldn't get pool context");
let articles: Vec<Article> = sqlx::query_as::<_, Article>(query).fetch_all(&pool).await?; let articles: Vec<Article> = sqlx::query_as::<_, Article>(query).fetch_all(&pool).await?;
std::thread::sleep(time::Duration::from_millis(2000));
Ok(articles) Ok(articles)
} }

View file

@ -1,3 +1,4 @@
pub mod articles; pub mod articles;
pub mod cards; pub mod cards;
pub mod containers; pub mod containers;
pub mod skeletons;

View file

@ -6,7 +6,7 @@ use crate::components::api::get_articles;
#[component] #[component]
pub fn Card(data: Article) -> impl IntoView { pub fn Card(data: Article) -> impl IntoView {
view! { view! {
<div class="p-7 my-5 mx-2 w-80 rounded-lg shadow-inner min-w-3/12 max-w-3/12 bg-zinc-900 shadow-zinc-950"> <div class="p-7 my-5 mx-2 w-80 rounded-lg shadow-inner min-w-1/12 max-w-2/12 bg-zinc-900 shadow-zinc-950">
<h1 class="text-2xl font-light text-orange-600 max-6-xs">{&data.title}</h1> <h1 class="text-2xl font-light text-orange-600 max-6-xs">{&data.title}</h1>
<hr class="opacity-50"/> <hr class="opacity-50"/>
<span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span> <span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span>
@ -35,5 +35,9 @@ pub fn CardBuilder(article_type: ArticleType) -> impl IntoView {
.collect_view() .collect_view()
}) })
}; };
view! { <div class="flex overflow-x-scroll flex-wrap place-content-evenly mx-auto w-11/12 max-w-screen-xl">{cards_view}</div> } view! {
<div class="flex overflow-x-scroll flex-wrap place-content-evenly mx-auto w-11/12 max-w-screen-xl">
{cards_view}
</div>
}
} }

View file

@ -0,0 +1,16 @@
use leptos::*;
use crate::components::ui::containers::*;
#[component]
pub fn Skeleton() -> impl IntoView {
view! {
<Container>
<div class="flex animate-pulse">
<div class="mx-auto place-items-center h-64">
<code class="my-auto">"███████▒▒▒ 69%"</code>
</div>
</div>
</Container>
}
}

View file

@ -1,3 +1,4 @@
use crate::components::ui::containers::*;
use http::status::StatusCode; use http::status::StatusCode;
use leptos::*; use leptos::*;
use thiserror::Error; use thiserror::Error;
@ -35,22 +36,22 @@ pub fn ErrorTemplate(
println!("Errors: {errors:#?}"); println!("Errors: {errors:#?}");
view! { view! {
<article class="p-7 my-5 mx-auto w-11/12 max-w-screen-xl bg-opacity-10 rounded-md bg-zinc-700 shadow-1g"> <Container>
<h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs"> <article>
{if errors.len() > 1 { "Errors!" } else { "Error!" }} <h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">
</h1> {if errors.len() > 1 { "Errors" } else { "Error" }}
<hr class="opacity-50"/> </h1>
<hr class="opacity-50"/>
<ul>
{move || {
errors
.into_iter()
.map(|e: &_| view! { <li>{e.to_string()}</li> })
.collect_view()
}}
<ul> </ul>
{move || { </article>
errors </Container>
.into_iter()
.map(|e: &_| view! { <li>{e.to_string()}</li> })
.collect_view()
}}
</ul>
</article>
} }
} }

View file

@ -32,15 +32,15 @@ pub fn App() -> impl IntoView {
"Home" "Home"
</A> </A>
</li> </li>
<li>
<A href="/blog">"Blog"</A>
</li>
<li> <li>
<A href="/projects">"Projects"</A> <A href="/projects">"Projects"</A>
</li> </li>
<li> <li>
<A href="/games">"Games"</A> <A href="/games">"Games"</A>
</li> </li>
<li>
<A href="/blog">"Blog"</A>
</li>
<li> <li>
<a href="https://git.doordesk.net">"Git"</a> <a href="https://git.doordesk.net">"Git"</a>
</li> </li>
@ -49,9 +49,9 @@ pub fn App() -> impl IntoView {
<main> <main>
<Routes> <Routes>
<Route path="" view=Home/> <Route path="" view=Home/>
<Route path="blog" view=Blog/>
<Route path="projects" view=Projects/> <Route path="projects" view=Projects/>
<Route path="games" view=Games/> <Route path="games" view=Games/>
<Route path="blog" view=Blog/>
</Routes> </Routes>
</main> </main>
<p class="m-auto w-8 text-center duration-200 hover:rotate-180"> <p class="m-auto w-8 text-center duration-200 hover:rotate-180">

View file

@ -1,5 +1,6 @@
use crate::components::api::ArticleType; use crate::components::api::ArticleType;
use crate::components::ui::articles::ArticleBuilder; use crate::components::ui::articles::ArticleBuilder;
use crate::components::ui::skeletons::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
@ -7,7 +8,7 @@ use leptos::*;
pub fn Blog() -> impl IntoView { pub fn Blog() -> impl IntoView {
view! { view! {
<Suspense fallback=move || { <Suspense fallback=move || {
view! { <p>"Loading..."</p> } view! { <Skeleton/> }
}> }>
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }

View file

@ -1,5 +1,6 @@
use crate::components::api::ArticleType; use crate::components::api::ArticleType;
use crate::components::ui::cards::*; use crate::components::ui::cards::*;
use crate::components::ui::skeletons::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
@ -8,7 +9,7 @@ pub fn Games() -> impl IntoView {
view! { view! {
<Suspense fallback=move || { <Suspense fallback=move || {
view! { <p>"Loading..."</p> } view! { <Skeleton/> }
}> }>
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }

View file

@ -1,15 +1,15 @@
use crate::components::api::ArticleType; use crate::components::api::ArticleType;
use crate::components::ui::articles::ArticleBuilder; use crate::components::ui::articles::ArticleBuilder;
use crate::components::ui::cards::*; use crate::components::ui::cards::*;
use crate::components::ui::skeletons::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
#[island] #[island]
pub fn Home() -> impl IntoView { pub fn Home() -> impl IntoView {
view! { view! {
<Suspense fallback=move || { <Suspense fallback=move || {
view! { <p>"Loading..."</p> } view! { <Skeleton/> }
}> }>
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }

View file

@ -1,5 +1,6 @@
use crate::components::api::ArticleType; use crate::components::api::ArticleType;
use crate::components::ui::articles::ArticleBuilder; use crate::components::ui::articles::ArticleBuilder;
use crate::components::ui::skeletons::*;
use crate::error_template::*; use crate::error_template::*;
use leptos::*; use leptos::*;
@ -7,7 +8,7 @@ use leptos::*;
pub fn Projects() -> impl IntoView { pub fn Projects() -> impl IntoView {
view! { view! {
<Suspense fallback=move || { <Suspense fallback=move || {
view! { <p>"Loading..."</p> } view! { <Skeleton/> }
}> }>
<ErrorBoundary fallback=|errors| { <ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> } view! { <ErrorTemplate errors=errors/> }

View file

@ -3,7 +3,7 @@ use leptos::*;
use serde::*; use serde::*;
use sqlx::*; use sqlx::*;
pub async fn db_build(pool: SqlitePool) -> Result<(), ServerFnError> { pub async fn db_build(pool: &SqlitePool) -> Result<(), ServerFnError> {
let _res = query( let _res = query(
" "
CREATE TABLE CREATE TABLE
@ -15,7 +15,7 @@ pub async fn db_build(pool: SqlitePool) -> Result<(), ServerFnError> {
) )
", ",
) )
.execute(&pool) .execute(pool)
.await?; .await?;
// println!("{:?}", _res); // println!("{:?}", _res);
@ -63,7 +63,7 @@ pub async fn db_build(pool: SqlitePool) -> Result<(), ServerFnError> {
.bind(article.title) .bind(article.title)
.bind(article.date) .bind(article.date)
.bind(article.content) .bind(article.content)
.execute(&pool) .execute(pool)
.await?; .await?;
// println!("{:?}", _res); // println!("{:?}", _res);

View file

@ -16,7 +16,7 @@ async fn main() {
let routes = generate_route_list(App); let routes = generate_route_list(App);
let pool = start_pool().await.expect("pool error"); 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() let app = Router::new()
.leptos_routes_with_context( .leptos_routes_with_context(