aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorLibravatar cel 🌸 <cel@blos.sm>2023-01-17 02:31:48 +0000
committerLibravatar cel 🌸 <cel@blos.sm>2023-01-17 02:31:48 +0000
commit26f9dc3ea3f90c23067a96381bba37b28c2a0871 (patch)
tree8f098f151252d165b484752375c9e18a1a2b875b /src/main.rs
parent57c3a21bce3f4040eefdcc8b57bc86bdc59dacbf (diff)
downloadblossom-26f9dc3ea3f90c23067a96381bba37b28c2a0871.tar.gz
blossom-26f9dc3ea3f90c23067a96381bba37b28c2a0871.tar.bz2
blossom-26f9dc3ea3f90c23067a96381bba37b28c2a0871.zip
implement skweet widget
Diffstat (limited to '')
-rw-r--r--src/main.rs32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 6efade0..1a2aab7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,7 @@
+use std::borrow::Cow;
+
use listenbrainz::raw::response::UserPlayingNowResponse;
+use mastodon_async::{Data, Mastodon};
use rocket::fs::{relative, FileServer};
use rocket::http::Status;
use rocket::response::Responder;
@@ -58,11 +61,21 @@ async fn home() -> Template {
let listenbrainz = listenbrainz::raw::Client::new();
let playingnow = listenbrainz.user_playing_now("celblossom").unwrap();
let listenbrainz_data = ScrobbleData::new(playingnow);
- println!("{}", listenbrainz_data.is_scrobbling);
+
+ let mut skinny_data = Data::default();
+ skinny_data.base = Cow::from("https://skinnyver.se");
+ let skinny_client = Mastodon::from(skinny_data);
+ let mut skweets = skinny_client
+ .statuses("cel", Default::default())
+ .await
+ .unwrap()
+ .initial_items;
+
+ skweets.truncate(6);
Template::render(
"home",
- context! { is_live: false, listenbrainz: listenbrainz_data },
+ context! { is_live: false, listenbrainz: listenbrainz_data, skweets: skweets },
)
}
@@ -71,10 +84,17 @@ async fn contact() -> Template {
Template::render("contact", context! {})
}
+#[get("/plants")]
+async fn plants() -> Result<Template, BlossomError> {
+ todo!()
+}
+
// #[get("/test")]
// async fn test() -> Result<Template, BlossomError> {
-// let posts = reqwest::get("https://skinnyver.se/api/v1/accounts/cel/statuses").await;
-// posts
+// let posts = reqwest::get("https://skinnyver.se/api/v1/accounts/cel/statuses")
+// .await?
+// .json()
+// .await?;
// }
#[catch(default)]
@@ -99,7 +119,9 @@ fn error(status: Status, req: &Request) -> Template {
#[tokio::main]
async fn main() -> Result<(), rocket::Error> {
let _rocket = rocket::build()
- .attach(Template::fairing())
+ .attach(Template::custom(|engines| {
+ engines.tera.autoescape_on(vec![]);
+ }))
.mount("/", routes![home, contact])
.register("/", catchers![error])
.mount("/", FileServer::from(relative!("static")))