Compare commits

..

No commits in common. "f37ebd04453963c36b5f647b53b868f32474cb00" and "49028baec7c47d6144dc920aed894ad372606980" have entirely different histories.

11 changed files with 118 additions and 128 deletions

90
Cargo.lock generated
View file

@ -66,6 +66,7 @@ checksum = "080e9890a082662b09c1ad45f567faeeb47f22b5fb23895fbe1e651e718e25ca"
name = "app"
version = "0.1.0"
dependencies = [
"femark",
"http 1.0.0",
"leptos",
"leptos_axum",
@ -74,6 +75,7 @@ dependencies = [
"serde",
"sqlx",
"thiserror",
"toml 0.8.9",
]
[[package]]
@ -974,7 +976,7 @@ dependencies = [
"futures-sink",
"futures-util",
"http 1.0.0",
"indexmap 2.2.2",
"indexmap 2.2.1",
"slab",
"tokio",
"tokio-util",
@ -1176,11 +1178,12 @@ dependencies = [
[[package]]
name = "hyper-util"
version = "0.1.3"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa"
checksum = "bdea9aac0dbe5a9240d68cfd9501e2db94222c6dc06843e06640b9e07f0fdc67"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http 1.0.0",
"http-body",
@ -1188,6 +1191,7 @@ dependencies = [
"pin-project-lite",
"socket2",
"tokio",
"tracing",
]
[[package]]
@ -1224,9 +1228,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.2.2"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824b2ae422412366ba479e8111fd301f7b5faece8149317bb81925979a53f520"
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
dependencies = [
"equivalent",
"hashbrown 0.14.3",
@ -1288,9 +1292,9 @@ dependencies = [
[[package]]
name = "leptos"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c115de7c6fca2164133e18328777d02c371434ace38049ac02886b5cffd22dc"
checksum = "13156caccc40bb71d687bed455b7d644ac69ecb5a5c180c2809ba52df863a99a"
dependencies = [
"cfg-if",
"leptos_config",
@ -1310,9 +1314,9 @@ dependencies = [
[[package]]
name = "leptos_axum"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "933ce9f409dd29ce429eb457f928d1cb48ebd39386d2dfe2f78d366e78cf7842"
checksum = "47756bd25127a3cc5eb33535cafe7199d669fffd5f12d2a9a37757b7399556c9"
dependencies = [
"axum",
"cfg-if",
@ -1334,9 +1338,9 @@ dependencies = [
[[package]]
name = "leptos_config"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "055262ff3660e95ec95cadd8a05a02070d624354e08e30b99c14a81023feb2dc"
checksum = "99cee343145b16836df6847d7da0db6f7f0a3f53f860e6b771bdeebb6da7f0ed"
dependencies = [
"config",
"regex",
@ -1347,9 +1351,9 @@ dependencies = [
[[package]]
name = "leptos_dom"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adfea7feb9c488448db466ca0673b691ec2a05efb0b2bc6626b7248ee04bb39c"
checksum = "bf6c02444169c390660bb8975adf064daf3f24f40b2d3f25618e5c0bbbe89cb5"
dependencies = [
"async-recursion",
"cfg-if",
@ -1357,7 +1361,7 @@ dependencies = [
"futures",
"getrandom",
"html-escape",
"indexmap 2.2.2",
"indexmap 2.2.1",
"itertools",
"js-sys",
"leptos_reactive",
@ -1377,13 +1381,13 @@ dependencies = [
[[package]]
name = "leptos_hot_reload"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ba8f68f7c3135975eb34ed19210272ebef2d6f422d138ff87a726b8793fe105"
checksum = "11bf126e9ac0597cda4156f14dea23627d90d53ade182a537b234b7e131e0096"
dependencies = [
"anyhow",
"camino",
"indexmap 2.2.2",
"indexmap 2.2.1",
"parking_lot",
"proc-macro2",
"quote",
@ -1395,9 +1399,9 @@ dependencies = [
[[package]]
name = "leptos_integration_utils"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "700bdb6d9d754964b576fa3b76a28a68adbd6ced6d7dc84a18e29e91a82c2376"
checksum = "55eb3cbc78aa67790799ef480270bef3d10e23f0a38e6fa3e4e42d797f931a13"
dependencies = [
"futures",
"leptos",
@ -1409,9 +1413,9 @@ dependencies = [
[[package]]
name = "leptos_macro"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "039c510dafb7d9997e4b8accfcced5675fabc65720caf544592df32432d6d65a"
checksum = "b859592ff768b01122733ac03a72507849e7ea2f640c63bb1c3487a5dc7a0891"
dependencies = [
"attribute-derive",
"cfg-if",
@ -1432,12 +1436,12 @@ dependencies = [
[[package]]
name = "leptos_meta"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bbbbd77839b4d3189c06319b32aaa3bc43510fb43f9c1bffb8e124a33decd6c"
checksum = "4705c24a835c3e8a158a351fee971d9efb0060a9817f719a79e22666dd112558"
dependencies = [
"cfg-if",
"indexmap 2.2.2",
"indexmap 2.2.1",
"leptos",
"tracing",
"wasm-bindgen",
@ -1446,14 +1450,14 @@ dependencies = [
[[package]]
name = "leptos_reactive"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b30c5bc7f3496d6ba399578171cf133c50d2172f9791fe292db4da2fd0d8cec4"
checksum = "4c5f08f2392b01cc5fc9223eeb92c70b40d366354ffbfb1c6761c9e621a8f966"
dependencies = [
"base64",
"cfg-if",
"futures",
"indexmap 2.2.2",
"indexmap 2.2.1",
"js-sys",
"paste",
"pin-project",
@ -1474,9 +1478,9 @@ dependencies = [
[[package]]
name = "leptos_router"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "498159479603569e1d7c969cffa0817b73249e96f825c295743f8f4607a68cbe"
checksum = "28334116fab9b903b31c8f6d2be254e86dd35265db6e0c0f5cfbc7b6c18ea0ef"
dependencies = [
"cached",
"cfg-if",
@ -1506,9 +1510,9 @@ dependencies = [
[[package]]
name = "leptos_server"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f06b9b860479385991fad54cbee372382aee3c1e75ca78b5da6f8bda90c153e1"
checksum = "4d6baa84d07a5869261e1dc606058886f1a79d6bf89b7b138cf25bae30983b76"
dependencies = [
"inventory",
"lazy_static",
@ -1522,9 +1526,9 @@ dependencies = [
[[package]]
name = "libc"
version = "0.2.153"
version = "0.2.152"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
[[package]]
name = "libm"
@ -2428,9 +2432,9 @@ dependencies = [
[[package]]
name = "server_fn"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97fab54d9dd2d7e9eba4efccac41d2ec3e7c6e9973d14c0486d662a32662320c"
checksum = "f27208122b0fa6d2b90b7dc25de60294e28647efd43b4c8abaf7df86227931a5"
dependencies = [
"axum",
"bytes",
@ -2463,9 +2467,9 @@ dependencies = [
[[package]]
name = "server_fn_macro"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3be6011b586a0665546b7ced372b0be690d9e005d3f8524795da2843274d7720"
checksum = "a8d7a5a1c0f78f261dbb8cf16281020552a1d518dbcb8501b33b8edae02b781b"
dependencies = [
"const_format",
"convert_case",
@ -2477,9 +2481,9 @@ dependencies = [
[[package]]
name = "server_fn_macro_default"
version = "0.6.5"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "752ed78ec49132d154b922cf5ab6485680cab039a75740c48ea2db621ad481da"
checksum = "29d13a68cc5b1ff8a3259e3ae984b91559268f0e5a7a8b0216f55b05307df5cb"
dependencies = [
"server_fn_macro",
"syn 2.0.48",
@ -2648,7 +2652,7 @@ dependencies = [
"futures-util",
"hashlink",
"hex",
"indexmap 2.2.2",
"indexmap 2.2.1",
"log",
"memchr",
"once_cell",
@ -3022,7 +3026,7 @@ version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1"
dependencies = [
"indexmap 2.2.2",
"indexmap 2.2.1",
"serde",
"serde_spanned",
"toml_datetime",
@ -3662,9 +3666,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
[[package]]
name = "winnow"
version = "0.5.36"
version = "0.5.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "818ce546a11a9986bc24f93d0cdf38a8a1a400f1473ea8c82e59f6e0ffab9249"
checksum = "1931d78a9c73861da0134f453bb1f790ce49b2e30eba8410b4b79bac72b46a2d"
dependencies = [
"memchr",
]

View file

@ -12,6 +12,8 @@ leptos_axum = { workspace = true, optional = true }
http.workspace = true
thiserror.workspace = true
serde = { version = "1" }
femark = { version = "0.1.5", optional = true }
toml = { version = "0.8.8", optional = true }
sqlx = { version = "0.7", features = [
"runtime-tokio-rustls",
"sqlite",
@ -25,5 +27,10 @@ ssr = [
"leptos_meta/ssr",
"leptos_router/ssr",
"dep:leptos_axum",
"dep:femark",
"dep:toml",
"dep:sqlx",
]
[package.metadata.cargo-all-features]
denylist = ["femark"]

View file

@ -1,21 +1,17 @@
use crate::components::ui::articles::*;
use leptos::*;
use crate::components::ui::articles::Article;
#[server]
pub async fn get_articles(article_type: ArticleType) -> Result<Vec<Article>, ServerFnError> {
pub async fn get_blog_posts() -> Result<Vec<Article>, 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::<SqlitePool>().expect("couldn't get pool context");
let result = sqlx::query_as::<_, Article>(query)
.fetch_all(&pool)
.await?;
let result =
sqlx::query_as::<_, Article>("select * from blog where content_type like 'game'")
.fetch_all(&pool)
.await?;
Ok(result)
}

View file

@ -1,5 +1,5 @@
use crate::components::api::*;
use crate::components::ui::containers::*;
use crate::components::api::*;
use leptos::*;
use serde::*;
@ -12,14 +12,6 @@ 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! {
@ -37,9 +29,12 @@ pub fn Article(data: Article) -> impl IntoView {
}
#[component]
pub fn ArticleBuilder(article_type: ArticleType) -> impl IntoView {
let data_resource =
create_local_resource(|| (), move |_| async move { get_articles(article_type).await });
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 },
);
let articles_view = move || {
data_resource.and_then(|data| {

View file

@ -1,21 +1,17 @@
use crate::components::ui::articles::*;
use leptos::*;
use crate::components::api::get_articles;
#[component]
pub fn Card(data: Article) -> impl IntoView {
pub fn Card(children: Children) -> 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">
<h1 class="text-2xl font-light text-orange-600 max-6-xs">
{&data.title}
"Card Header"
</h1>
<hr class="opacity-50"/>
<span class="pt-0 pb-3.5 text-xs opacity-50 m-t">{&data.date}</span>
<p class="text-center">
"[image]"
</p>
<div inner_html=&data.content></div>
{children()}
<p class="text-right">
<a class="text-orange-300 hover:underline" href="https://lickmysa.cc" >Read more...</a>
</p>
@ -24,22 +20,6 @@ pub fn Card(data: Article) -> impl IntoView {
}
#[component]
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! {<Card data=article.clone()/> })
.collect_view()
})
};
view! {
<div class="flex flex-wrap place-content-evenly mx-auto max-w-8/12">
{cards_view}
</div>
}
pub fn CardHolder(children: Children) -> impl IntoView {
view! { <div class="flex flex-wrap place-content-evenly mx-auto w-11/12">{children()}</div> }
}

View file

@ -8,7 +8,7 @@ pub mod components;
pub mod error_template;
pub mod routes;
use crate::routes::{blog::Blog, games::Games, home::Home, projects::Projects};
use crate::routes::{blog::Blog, home::Home, projects::Projects};
#[component]
pub fn App() -> impl IntoView {
@ -38,9 +38,6 @@ pub fn App() -> impl IntoView {
<li>
<A href="/projects">"Projects"</A>
</li>
<li>
<A href="/games">"Games"</A>
</li>
<li>
<a href="https://git.doordesk.net">"Git"</a>
</li>
@ -51,7 +48,6 @@ pub fn App() -> impl IntoView {
<Route path="" view=Home/>
<Route path="blog" view=Blog/>
<Route path="projects" view=Projects/>
<Route path="games" view=Games/>
</Routes>
</main>
<p class="m-auto w-8 text-center duration-200 hover:rotate-180">

View file

@ -1,4 +1,3 @@
pub mod blog;
pub mod games;
pub mod home;
pub mod blog;
pub mod projects;

View file

@ -12,7 +12,7 @@ pub fn Blog() -> impl IntoView {
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<ArticleBuilder article_type={ArticleType::Blog} />
<ArticleBuilder/>
</ErrorBoundary>
</Suspense>
}

View file

@ -1,20 +0,0 @@
use crate::components::ui::articles::*;
use crate::components::ui::cards::*;
use crate::error_template::*;
use leptos::*;
#[island]
pub fn Games() -> impl IntoView {
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
}>
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<CardBuilder article_type={ArticleType::Game} />
</ErrorBoundary>
</Suspense>
}
}

View file

@ -1,11 +1,9 @@
use crate::components::ui::articles::*;
use crate::components::ui::cards::*;
use crate::error_template::*;
use leptos::*;
#[island]
#[component]
pub fn Home() -> impl IntoView {
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
@ -13,8 +11,26 @@ pub fn Home() -> impl IntoView {
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<CardBuilder article_type={ArticleType::Game} />
<ArticleBuilder article_type={ArticleType::All} />
<h1>Latest Stuff or whatever</h1>
<CardHolder>
<Card>
<p>{"home1"}</p>
</Card>
<Card>
<p>{"home2"}</p>
</Card>
<Card>
<p>{"home3"}</p>
</Card>
<Card>
<p>{"home4"}</p>
</Card>
<Card>
<p>{"home5"}</p>
</Card>
</CardHolder>
</ErrorBoundary>
</Suspense>
}

View file

@ -1,10 +1,9 @@
use crate::components::ui::articles::*;
use crate::components::ui::cards::*;
use crate::error_template::*;
use leptos::*;
#[island]
#[component]
pub fn Projects() -> impl IntoView {
view! {
<Suspense fallback=move || {
view! { <p>"Loading..."</p> }
@ -12,7 +11,25 @@ pub fn Projects() -> impl IntoView {
<ErrorBoundary fallback=|errors| {
view! { <ErrorTemplate errors=errors/> }
}>
<ArticleBuilder article_type={ArticleType::Project} />
<CardHolder>
<Card>
<p>{"project1"}</p>
</Card>
<Card>
<p>{"project2"}</p>
</Card>
<Card>
<p>{"project3"}</p>
</Card>
<Card>
<p>{"project4"}</p>
</Card>
<Card>
<p>{"project5"}</p>
</Card>
</CardHolder>
</ErrorBoundary>
</Suspense>
}