yolo cause solo
This commit is contained in:
parent
2e7024222e
commit
92f42d5bd9
13 changed files with 71 additions and 40 deletions
16
Cargo.lock
generated
16
Cargo.lock
generated
|
@ -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",
|
||||
]
|
||||
|
|
|
@ -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<Vec<Article>, 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::<SqlitePool>().expect("couldn't get pool context");
|
||||
|
||||
let articles: Vec<Article> = sqlx::query_as::<_, Article>(query).fetch_all(&pool).await?;
|
||||
|
||||
std::thread::sleep(time::Duration::from_millis(2000));
|
||||
Ok(articles)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
pub mod articles;
|
||||
pub mod cards;
|
||||
pub mod containers;
|
||||
pub mod skeletons;
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::components::api::get_articles;
|
|||
#[component]
|
||||
pub fn Card(data: Article) -> impl IntoView {
|
||||
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>
|
||||
<hr class="opacity-50"/>
|
||||
<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()
|
||||
})
|
||||
};
|
||||
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>
|
||||
}
|
||||
}
|
||||
|
|
16
app/src/components/ui/skeletons.rs
Normal file
16
app/src/components/ui/skeletons.rs
Normal 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>
|
||||
}
|
||||
}
|
||||
|
|
@ -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! {
|
||||
<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">
|
||||
<h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">
|
||||
{if errors.len() > 1 { "Errors!" } else { "Error!" }}
|
||||
</h1>
|
||||
<hr class="opacity-50"/>
|
||||
<Container>
|
||||
<article>
|
||||
<h1 class="text-3xl font-light text-orange-600 capitalize max-6-xs">
|
||||
{if errors.len() > 1 { "Errors" } else { "Error" }}
|
||||
</h1>
|
||||
<hr class="opacity-50"/>
|
||||
<ul>
|
||||
{move || {
|
||||
errors
|
||||
.into_iter()
|
||||
.map(|e: &_| view! { <li>{e.to_string()}</li> })
|
||||
.collect_view()
|
||||
}}
|
||||
|
||||
<ul>
|
||||
{move || {
|
||||
errors
|
||||
.into_iter()
|
||||
.map(|e: &_| view! { <li>{e.to_string()}</li> })
|
||||
.collect_view()
|
||||
}}
|
||||
|
||||
</ul>
|
||||
|
||||
</article>
|
||||
</ul>
|
||||
</article>
|
||||
</Container>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,15 +32,15 @@ pub fn App() -> impl IntoView {
|
|||
"Home"
|
||||
</A>
|
||||
</li>
|
||||
<li>
|
||||
<A href="/blog">"Blog"</A>
|
||||
</li>
|
||||
<li>
|
||||
<A href="/projects">"Projects"</A>
|
||||
</li>
|
||||
<li>
|
||||
<A href="/games">"Games"</A>
|
||||
</li>
|
||||
<li>
|
||||
<A href="/blog">"Blog"</A>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://git.doordesk.net">"Git"</a>
|
||||
</li>
|
||||
|
@ -49,9 +49,9 @@ pub fn App() -> impl IntoView {
|
|||
<main>
|
||||
<Routes>
|
||||
<Route path="" view=Home/>
|
||||
<Route path="blog" view=Blog/>
|
||||
<Route path="projects" view=Projects/>
|
||||
<Route path="games" view=Games/>
|
||||
<Route path="blog" view=Blog/>
|
||||
</Routes>
|
||||
</main>
|
||||
<p class="m-auto w-8 text-center duration-200 hover:rotate-180">
|
||||
|
|
|
@ -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! {
|
||||
<Suspense fallback=move || {
|
||||
view! { <p>"Loading..."</p> }
|
||||
view! { <Skeleton/> }
|
||||
}>
|
||||
<ErrorBoundary fallback=|errors| {
|
||||
view! { <ErrorTemplate errors=errors/> }
|
||||
|
|
|
@ -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! {
|
||||
<Suspense fallback=move || {
|
||||
view! { <p>"Loading..."</p> }
|
||||
view! { <Skeleton/> }
|
||||
}>
|
||||
<ErrorBoundary fallback=|errors| {
|
||||
view! { <ErrorTemplate errors=errors/> }
|
||||
|
|
|
@ -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! {
|
||||
<Suspense fallback=move || {
|
||||
view! { <p>"Loading..."</p> }
|
||||
view! { <Skeleton/> }
|
||||
}>
|
||||
<ErrorBoundary fallback=|errors| {
|
||||
view! { <ErrorTemplate errors=errors/> }
|
||||
|
|
|
@ -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! {
|
||||
<Suspense fallback=move || {
|
||||
view! { <p>"Loading..."</p> }
|
||||
view! { <Skeleton/> }
|
||||
}>
|
||||
<ErrorBoundary fallback=|errors| {
|
||||
view! { <ErrorTemplate errors=errors/> }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue