about summary refs log tree commit diff
path: root/src/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend')
-rw-r--r--src/frontend/mod.rs11
-rw-r--r--src/frontend/templates/mod.rs8
2 files changed, 15 insertions, 4 deletions
diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs
index 890879c..6194249 100644
--- a/src/frontend/mod.rs
+++ b/src/frontend/mod.rs
@@ -257,6 +257,7 @@ pub async fn mainpage<S: Storage>(mut req: Request<ApplicationState<S>>) -> Resu
                             webmention: None,
                             microsub: None,
                         },
+                        feeds: Vec::default(),
                         content: OnboardingPage {}.to_string(),
                     }
                     .to_string(),
@@ -281,6 +282,7 @@ 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()),
                     content: MainPage {
                         feed: &feed?,
                         card: &card?,
@@ -335,6 +337,7 @@ pub async fn render_post<S: Storage>(mut req: Request<ApplicationState<S>>) -> R
         }
     };
     let origin = url.origin();
+    let owner = origin.ascii_serialization() + "/";
 
     Ok(Response::builder(200)
         .content_type("text/html; charset=utf-8")
@@ -346,7 +349,7 @@ pub async fn render_post<S: Storage>(mut req: Request<ApplicationState<S>>) -> R
                 blog_name: &req
                     .state()
                     .storage
-                    .get_setting("site_name", &(origin.ascii_serialization() + "/")) // XXX I'm pretty sure this is bound to cause issues with IDN-style domains
+                    .get_setting("site_name", &owner) // XXX I'm pretty sure this is bound to cause issues with IDN-style domains
                     .await
                     .unwrap_or_else(|_| "Kitty Box!".to_string()),
                 endpoints: IndiewebEndpoints {
@@ -355,6 +358,7 @@ 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()),
                 content: template,
             }
             .to_string(),
@@ -376,12 +380,14 @@ where
     ) -> Result {
         let authorization_endpoint = request.state().authorization_endpoint.to_string();
         let token_endpoint = request.state().token_endpoint.to_string();
+        let owner = request.url().origin().ascii_serialization().clone() + "/";
         let site_name = &request
             .state()
             .storage
-            .get_setting("site_name", &(request.url().origin().ascii_serialization().clone() + "/"))
+            .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 mut res = next.run(request).await;
         let mut code: Option<StatusCode> = None;
         if let Some(err) = res.downcast_error::<FrontendError>() {
@@ -406,6 +412,7 @@ where
                         webmention: None,
                         microsub: None,
                     },
+                    feeds: feeds,
                     content: ErrorPage { code }.to_string(),
                 }
                 .to_string(),
diff --git a/src/frontend/templates/mod.rs b/src/frontend/templates/mod.rs
index 290e215..a7c01e0 100644
--- a/src/frontend/templates/mod.rs
+++ b/src/frontend/templates/mod.rs
@@ -1,4 +1,5 @@
-use super::IndiewebEndpoints;
+use crate::database::MicropubChannel;
+use crate::frontend::IndiewebEndpoints;
 use ellipse::Ellipse;
 use http_types::StatusCode;
 use log::error;
@@ -24,7 +25,7 @@ mod onboarding;
 pub use onboarding::OnboardingPage;
 
 markup::define! {
-    Template<'a>(title: &'a str, blog_name: &'a str, endpoints: IndiewebEndpoints, content: String) {
+    Template<'a>(title: &'a str, blog_name: &'a str, endpoints: IndiewebEndpoints, feeds: Vec<MicropubChannel>, content: String) {
         @markup::doctype()
         html {
             head {
@@ -48,6 +49,9 @@ markup::define! {
                     ul {
                         // TODO print a list of feeds and allow jumping to them
                         li { a#homepage[href="/"] { @blog_name } }
+                        @for feed in feeds.iter() {
+                            li { a[href=&feed.uid] { @feed.name } }
+                        }
                         li.shiftright { a#login[href="/login"] { "Login" } }
                     }
                 }