diff options
author | Vika <vika@fireburn.ru> | 2021-12-05 23:00:01 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2021-12-05 23:00:01 +0300 |
commit | 4aa7f01da39ab55b4f6346e7565d8bb29566de39 (patch) | |
tree | 125c147e1a39dfebc4be1a3ac3a6dd8fadb3855e /src/frontend | |
parent | c0b552318cb08872c7deae82a10122b0e16b7ae8 (diff) | |
download | kittybox-4aa7f01da39ab55b4f6346e7565d8bb29566de39.tar.zst |
Code cleanup and small bugfixing in templates
Diffstat (limited to 'src/frontend')
-rw-r--r-- | src/frontend/mod.rs | 23 | ||||
-rw-r--r-- | src/frontend/templates/mod.rs | 8 | ||||
-rw-r--r-- | src/frontend/templates/onboarding.rs | 1 |
3 files changed, 23 insertions, 9 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 6194249..ce4f015 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -185,7 +185,9 @@ pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S log::debug!("Creating feeds..."); for feed in body.feeds { - if &feed.name == "" || &feed.slug == "" { continue }; + if &feed.name == "" || &feed.slug == "" { + continue; + }; log::debug!("Creating feed {} with slug {}", &feed.name, &feed.slug); let (_, feed) = crate::micropub::normalize_mf2( json!({ @@ -282,7 +284,10 @@ pub async fn mainpage<S: Storage>(mut req: Request<ApplicationState<S>>) -> Resu webmention: None, microsub: None, }, - feeds: backend.get_channels(hcard_url).await.unwrap_or_else(|_| Vec::default()), + feeds: backend + .get_channels(hcard_url) + .await + .unwrap_or_else(|_| Vec::default()), content: MainPage { feed: &feed?, card: &card?, @@ -358,7 +363,12 @@ pub async fn render_post<S: Storage>(mut req: Request<ApplicationState<S>>) -> R webmention: None, microsub: None, }, - feeds: req.state().storage.get_channels(&owner).await.unwrap_or_else(|e| Vec::default()), + feeds: req + .state() + .storage + .get_channels(&owner) + .await + .unwrap_or_else(|_| Vec::default()), content: template, } .to_string(), @@ -387,7 +397,12 @@ where .get_setting("site_name", &owner) .await .unwrap_or_else(|_| "Kitty Box!".to_string()); - let feeds = request.state().storage.get_channels(&owner).await.unwrap_or_else(|_| Vec::default()); + let feeds = request + .state() + .storage + .get_channels(&owner) + .await + .unwrap_or_else(|_| Vec::default()); let mut res = next.run(request).await; let mut code: Option<StatusCode> = None; if let Some(err) = res.downcast_error::<FrontendError>() { diff --git a/src/frontend/templates/mod.rs b/src/frontend/templates/mod.rs index 3585804..100e16d 100644 --- a/src/frontend/templates/mod.rs +++ b/src/frontend/templates/mod.rs @@ -165,9 +165,9 @@ markup::define! { } } else { // This is a rich food object (mm, sounds tasty! I wanna eat something tasty) - a."u-ate"[href=food["properties"]["uid"][0].as_str().unwrap()] { + a."u-ate"[href=food["properties"]["uid"][0].as_str().unwrap_or("#")] { @food["properties"]["name"][0].as_str() - .unwrap_or(food["properties"]["uid"][0].as_str().unwrap().truncate_ellipse(24).as_ref()) + .unwrap_or(food["properties"]["uid"][0].as_str().unwrap_or("#").truncate_ellipse(24).as_ref()) } } } @@ -186,9 +186,9 @@ markup::define! { } } else { // This is a rich food object (mm, sounds tasty! I wanna eat something tasty) - a."u-drank"[href=food["properties"]["uid"][0].as_str().unwrap()] { + a."u-drank"[href=food["properties"]["uid"][0].as_str().unwrap_or("#")] { @food["properties"]["name"][0].as_str() - .unwrap_or(food["properties"]["uid"][0].as_str().unwrap().truncate_ellipse(24).as_ref()) + .unwrap_or(food["properties"]["uid"][0].as_str().unwrap_or("#").truncate_ellipse(24).as_ref()) } } } diff --git a/src/frontend/templates/onboarding.rs b/src/frontend/templates/onboarding.rs index aab2b31..ebf8881 100644 --- a/src/frontend/templates/onboarding.rs +++ b/src/frontend/templates/onboarding.rs @@ -190,4 +190,3 @@ markup::define! { } } } - |