From afdfd025560f5d4e76088aac80a8a642083cd8fd Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Sat, 27 Jan 2024 03:31:55 -0500 Subject: [PATCH] flatten articles --- app/src/components/article.rs | 2 +- app/src/components/slingshot.rs | 50 ++++++++----------- app/src/lib.rs | 7 ++- app/src/routes.rs | 4 +- app/src/routes/blog.rs | 17 ++++++- app/src/routes/home.rs | 4 +- app/src/routes/projects.rs | 17 ++++++- public/articles/bots/cartman.html | 1 - public/articles/games/index.html | 23 --------- public/{articles => }/blog/20220207-swim.md | 2 +- public/{articles => }/blog/20220506-change.md | 0 public/{articles => }/blog/20220520-nvidia.md | 0 .../games/snek.md => blog/20220520-snek.md} | 0 .../projects => blog}/20220529-housing.md | 0 public/{articles => }/blog/20220602-back.md | 0 .../projects => blog}/20220614-reddit.md | 2 +- .../{articles => }/blog/20220701-progress.md | 0 .../games/adam.md => blog/20220911-adam.md} | 0 .../games/balls.md => blog/20220913-balls.md} | 0 .../games/fps.md => blog/20221009-fps.md} | 0 .../projects => blog}/20221020-cartman.md | 0 .../projects => blog}/20230427-lightning.md | 0 22 files changed, 62 insertions(+), 67 deletions(-) delete mode 100644 public/articles/bots/cartman.html delete mode 100644 public/articles/games/index.html rename public/{articles => }/blog/20220207-swim.md (99%) rename public/{articles => }/blog/20220506-change.md (100%) rename public/{articles => }/blog/20220520-nvidia.md (100%) rename public/{articles/games/snek.md => blog/20220520-snek.md} (100%) rename public/{articles/projects => blog}/20220529-housing.md (100%) rename public/{articles => }/blog/20220602-back.md (100%) rename public/{articles/projects => blog}/20220614-reddit.md (99%) rename public/{articles => }/blog/20220701-progress.md (100%) rename public/{articles/games/adam.md => blog/20220911-adam.md} (100%) rename public/{articles/games/balls.md => blog/20220913-balls.md} (100%) rename public/{articles/games/fps.md => blog/20221009-fps.md} (100%) rename public/{articles/projects => blog}/20221020-cartman.md (100%) rename public/{articles/projects => blog}/20230427-lightning.md (100%) diff --git a/app/src/components/article.rs b/app/src/components/article.rs index 31e3a5e..4f8e4a1 100644 --- a/app/src/components/article.rs +++ b/app/src/components/article.rs @@ -14,7 +14,7 @@ pub struct ArticleData { pub fn ArticleBuilder() -> impl IntoView { let data_resource = create_local_resource( || (), - |_| async move { slingshot("./public/articles".to_string()).await }, + |_| async move { slingshot("./public/blog".to_string()).await }, ); let articles_view = move || { diff --git a/app/src/components/slingshot.rs b/app/src/components/slingshot.rs index e71d724..83fc3cc 100644 --- a/app/src/components/slingshot.rs +++ b/app/src/components/slingshot.rs @@ -13,42 +13,36 @@ struct ArticleFrontmatter { pub async fn slingshot(path: String) -> Result, ServerFnError> { let mut articles = vec![]; - for dir in std::fs::read_dir(path)? { - for file in std::fs::read_dir(dir?.path())? { - let fileinfo = file?; - let filepath = fileinfo.path(); + for file in std::fs::read_dir(path)? { + let fileinfo = file?; + let filepath = fileinfo.path(); - if let Some(filetype) = filepath.extension() { - if filetype == "md" { - let file = std::fs::read_to_string(filepath)?; - let html_from_md = - femark::process_markdown_to_html_with_frontmatter(&file.to_string(), true) - .expect("Problem processing markdown"); - let content = html_from_md.content; - let _toc = html_from_md.toc; + if let Some(filetype) = filepath.extension() { + if filetype == "md" { + let file = std::fs::read_to_string(filepath)?; + let html_from_md = + femark::process_markdown_to_html_with_frontmatter(&file.to_string(), true) + .expect("Problem processing markdown"); + let content = html_from_md.content; + let _toc = html_from_md.toc; - if let Some(front_raw) = html_from_md.frontmatter { - if let Some(front_code) = front_raw.code_block { - let toml: ArticleFrontmatter = - toml::from_str(&front_code.source)?; + if let Some(front_raw) = html_from_md.frontmatter { + if let Some(front_code) = front_raw.code_block { + let toml: ArticleFrontmatter = toml::from_str(&front_code.source)?; - articles.push(ArticleData { - content_type: toml.content_type, - title: toml.title, - date: toml.date, - content, - }) - } + println!("{} {}", &toml.date, &toml.title); + articles.push(ArticleData { + content_type: toml.content_type, + title: toml.title, + date: toml.date, + content, + }) } } } } } - // Simulate lag - // use std::thread::sleep; - // use std::time::Duration; - // sleep(Duration::from_millis(300)); - + println!("iran"); Ok(articles) } diff --git a/app/src/lib.rs b/app/src/lib.rs index 472d5c8..779d9f6 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -8,8 +8,7 @@ pub mod components; pub mod error_template; pub mod routes; -// use crate::routes::{blog::*, home::*, projects::*}; -use crate::routes::home::Home; +use crate::routes::{blog::Blog, home::Home, projects::Projects}; #[component] pub fn App() -> impl IntoView { @@ -47,8 +46,8 @@ pub fn App() -> impl IntoView {
- // - // + +

diff --git a/app/src/routes.rs b/app/src/routes.rs index 509f52f..a28ef14 100644 --- a/app/src/routes.rs +++ b/app/src/routes.rs @@ -1,3 +1,3 @@ pub mod home; -// pub mod blog; -// pub mod projects; +pub mod blog; +pub mod projects; diff --git a/app/src/routes/blog.rs b/app/src/routes/blog.rs index 9a4b7d5..d95e782 100644 --- a/app/src/routes/blog.rs +++ b/app/src/routes/blog.rs @@ -1,7 +1,20 @@ use crate::components::article::*; +use crate::components::slingshot::*; +use crate::error_template::*; use leptos::*; -#[component] +#[island] pub fn Blog() -> impl IntoView { - view! {

} + + view! { + "Loading..."

} + }> + } + }> + + +
+ } } diff --git a/app/src/routes/home.rs b/app/src/routes/home.rs index 95cf032..9015acd 100644 --- a/app/src/routes/home.rs +++ b/app/src/routes/home.rs @@ -3,7 +3,7 @@ use crate::components::slingshot::*; use crate::error_template::*; use leptos::*; -#[island] +#[component] pub fn Home() -> impl IntoView { view! { @@ -13,7 +13,7 @@ pub fn Home() -> impl IntoView { } }> - + "Hello again" } diff --git a/app/src/routes/projects.rs b/app/src/routes/projects.rs index 7169efa..b5e6912 100644 --- a/app/src/routes/projects.rs +++ b/app/src/routes/projects.rs @@ -1,7 +1,20 @@ -use crate::components::article::*; +// use crate::components::article::*; +// use crate::components::slingshot::*; +use crate::error_template::*; use leptos::*; #[component] pub fn Projects() -> impl IntoView { - view! {
} + + view! { + "Loading..."

} + }> + } + }> + "Projects" + +
+ } } diff --git a/public/articles/bots/cartman.html b/public/articles/bots/cartman.html deleted file mode 100644 index 2755d2d..0000000 --- a/public/articles/bots/cartman.html +++ /dev/null @@ -1 +0,0 @@ -cartman diff --git a/public/articles/games/index.html b/public/articles/games/index.html deleted file mode 100644 index 68a671e..0000000 --- a/public/articles/games/index.html +++ /dev/null @@ -1,23 +0,0 @@ -

Some games using wasm/webgl

-

Browser performance as of January 2023

-

Tested better:

-
    -
  1. Opera
  2. -
  3. Firefox Developer Edition
  4. -
  5. Brave
  6. -
-

Tested poor or broken:

-
    -
  1. Safari
  2. -
  3. Chrome stable release or older
  4. -
  5. Edge, see above^
  6. -
-

Consider anything else average or let me know otherwise

-
    - ---MY GAMES--- -
  • adam - The first. Unity Demo/Tutorial with some mods
  • -
  • multiplayer fps - Dive into netcode with Godot (Open two, invite - your friends!)
  • -
  • snek - Canvas + JS (the actual first)
  • -
  • balls - Godot demo engine test
  • -
diff --git a/public/articles/blog/20220207-swim.md b/public/blog/20220207-swim.md similarity index 99% rename from public/articles/blog/20220207-swim.md rename to public/blog/20220207-swim.md index b802d96..43fa047 100644 --- a/public/articles/blog/20220207-swim.md +++ b/public/blog/20220207-swim.md @@ -1,6 +1,6 @@ ```toml content_type = "blog" -title = "Hume" +title = "Swim" date = "2022 2 7" ``` diff --git a/public/articles/blog/20220506-change.md b/public/blog/20220506-change.md similarity index 100% rename from public/articles/blog/20220506-change.md rename to public/blog/20220506-change.md diff --git a/public/articles/blog/20220520-nvidia.md b/public/blog/20220520-nvidia.md similarity index 100% rename from public/articles/blog/20220520-nvidia.md rename to public/blog/20220520-nvidia.md diff --git a/public/articles/games/snek.md b/public/blog/20220520-snek.md similarity index 100% rename from public/articles/games/snek.md rename to public/blog/20220520-snek.md diff --git a/public/articles/projects/20220529-housing.md b/public/blog/20220529-housing.md similarity index 100% rename from public/articles/projects/20220529-housing.md rename to public/blog/20220529-housing.md diff --git a/public/articles/blog/20220602-back.md b/public/blog/20220602-back.md similarity index 100% rename from public/articles/blog/20220602-back.md rename to public/blog/20220602-back.md diff --git a/public/articles/projects/20220614-reddit.md b/public/blog/20220614-reddit.md similarity index 99% rename from public/articles/projects/20220614-reddit.md rename to public/blog/20220614-reddit.md index 92bcc7d..2de45ca 100644 --- a/public/articles/projects/20220614-reddit.md +++ b/public/blog/20220614-reddit.md @@ -1,7 +1,7 @@ ```toml content_type = "project" title = "What goes into a successful Reddit post?" -date = "2022 6 16" +date = "2022 6 14" ``` In an attempt to find out what about a Reddit post makes it successful I will use some diff --git a/public/articles/blog/20220701-progress.md b/public/blog/20220701-progress.md similarity index 100% rename from public/articles/blog/20220701-progress.md rename to public/blog/20220701-progress.md diff --git a/public/articles/games/adam.md b/public/blog/20220911-adam.md similarity index 100% rename from public/articles/games/adam.md rename to public/blog/20220911-adam.md diff --git a/public/articles/games/balls.md b/public/blog/20220913-balls.md similarity index 100% rename from public/articles/games/balls.md rename to public/blog/20220913-balls.md diff --git a/public/articles/games/fps.md b/public/blog/20221009-fps.md similarity index 100% rename from public/articles/games/fps.md rename to public/blog/20221009-fps.md diff --git a/public/articles/projects/20221020-cartman.md b/public/blog/20221020-cartman.md similarity index 100% rename from public/articles/projects/20221020-cartman.md rename to public/blog/20221020-cartman.md diff --git a/public/articles/projects/20230427-lightning.md b/public/blog/20230427-lightning.md similarity index 100% rename from public/articles/projects/20230427-lightning.md rename to public/blog/20230427-lightning.md