diff --git a/.gitignore b/.gitignore index 41fd1e4..81c51f8 100644 --- a/.gitignore +++ b/.gitignore @@ -19,4 +19,7 @@ Cargo.lock **/package.json # Don't put the old code in the repo. -**/.archive/** \ No newline at end of file +**/.archive/** + +# Don't commit the access token to the repo. +**/access_token.key \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index b151590..beea512 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,9 @@ edition = "2021" dioxus-autofmt = "0.5.0-alpha.0" console_error_panic_hook = "0.1.7" log = "0.4.17" -manganis = "*" -serde = "*" +manganis = "0.2.2" +serde = "1.0.197" +toml = "0.8.12" [dependencies.dioxus-router] version = "0.5.0-alpha.0" @@ -23,9 +24,17 @@ features = ["web", "fullstack"] [features] default = [] -server = ["dioxus/axum"] +server = ["dioxus/axum", "dep:megalodon", "dep:tokio"] web = ["dioxus/web"] [dependencies.time] verison = "0.3.34" -features = ["wasm-bindgen", "macros", "local-offset"] \ No newline at end of file +features = ["wasm-bindgen", "macros", "local-offset"] + +[dependencies.megalodon] +version = "0.13.2" +optional = true + +[dependencies.tokio] +version = "1.36.0" +optional = true \ No newline at end of file diff --git a/data/testimonials.toml b/data/testimonials.toml new file mode 100644 index 0000000..653bed0 --- /dev/null +++ b/data/testimonials.toml @@ -0,0 +1,43 @@ +[[accounts]] +username = "@shroomie@0w0.is" +content = "dragon woman play metroid good" + +[[accounts]] +username = "@deejvalen@plush.city" +content = "A real Cutie Patootie" + +[[accounts]] +username = "@genderfaerie@tech.lbgt" +content = "Alice is a rad friend and a cool person to know" + +[[accounts]] +username = "@colabunny@yiff.life" +content = "Alice is cool, cute and silly. 10/10 derg" + +[[accounts]] +username = "@fibonacci_reminder@plush.city" +content = "I think Alice is cool and good! She is nice and I'm glad that I know her." + +[[accounts]] +username = "@thufie@social.pixie.town" +content = "a type of dragon!" + +[[accounts]] +username = "@GameDevWitch@tech.lgbt" +content = "You are the best Werefox I have ever met." + +[[accounts]] +username = "@astraluma@tech.lgbt" +content = "a good derg" + +[[accounts]] +username = "@heatherhorns@plush.city" +content = "Alice kisses the girls and defeats the bad guys" + +[[accounts]] +username = "@tillianisafox@meow.social" +content = "ur awesome" + +[[accounts]] +username = "@Anzeliane@eldritch.cafe" +content = "ALICE HOW ARE YOU SO STUNNING HDKSJDNSBDBJSJZ" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 5259abe..6e077d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -345,13 +345,46 @@ pub mod info_app { #[component] pub fn Testimonials() -> Element { - rsx! { div {} } + let mastodon_status = use_resource(get_account_avatar); + // use_effect(|| { + // to_owned![mastodon_status]; + // async move { + // mastodon_status.set(get_mastodon_info().await.unwrap()); + // } + // }); + rsx! { div { match (mastodon_status.value())() { + Some(account) => format!("{:#?}", account.unwrap()), + _ => "Nothing yet...".to_string(), + } } } + } + + #[server] + async fn get_account_avatar() -> Result { + let client = megalodon::generator( + megalodon::SNS::Mastodon, + String::from("https://bark.lgbt"), + Some(tokio::fs::read_to_string("access_token.key").await?), + None, + ); + let testimonial_toml: String = tokio::fs::read_to_string("data/testimonials.toml").await?; + let testinomial_accounts: TestimonialAccount = toml::from_str(testimonial_toml.as_str()).unwrap(); + let res = client.search_account(String::from("@heatherhorns@plush.city"), None).await?; + Ok(format!("{}", res.json()[0].avatar_static)) + } + + #[derive(Deserialize)] + struct TestimonialAccount { + accounts: Vec, + } + + #[derive(Deserialize)] + struct Testimonial { + username: String, + content: String, } #[component] pub fn Hrt() -> Element { - // let time_elapsed: TimeElapsed = GetHrtTime().await(); - // let mut test = get_hrt_time(); let time_elapsed = use_signal(|| TimeElapsed { days: 0, hours: 0,