diff options
author | Colin Reeder <colin@vpzom.click> | 2020-07-19 15:17:53 -0600 |
---|---|---|
committer | Colin Reeder <colin@vpzom.click> | 2020-07-19 15:17:53 -0600 |
commit | e541aecb0cf772762b27047158b1b7eaf56c042a (patch) | |
tree | ec4e81bfdd080f76c73cc7db7b044aef9eed3236 | |
parent | 371a0e8aded22869ad1ec352125a81f121150fb8 (diff) |
Add versions to /about
-rw-r--r-- | src/resp_types.rs | 11 | ||||
-rw-r--r-- | src/routes/mod.rs | 23 |
2 files changed, 32 insertions, 2 deletions
diff --git a/src/resp_types.rs b/src/resp_types.rs index e24b303..cad9d36 100644 --- a/src/resp_types.rs +++ b/src/resp_types.rs @@ -143,3 +143,14 @@ impl<'a> AsRef<RespMinimalCommunityInfo<'a>> for RespCommunityInfoMaybeYour<'a> &self.base } } + +#[derive(Deserialize, Debug)] +pub struct RespInstanceSoftwareInfo<'a> { + pub name: Cow<'a, str>, + pub version: Cow<'a, str>, +} + +#[derive(Deserialize, Debug)] +pub struct RespInstanceInfo<'a> { + pub software: RespInstanceSoftwareInfo<'a>, +} diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 6a38e2c..0bd02bd 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -5,7 +5,9 @@ use std::sync::Arc; use crate::components::{ Comment, Content, HTPage, MaybeFillInput, MaybeFillTextArea, PostItem, ThingItem, UserLink, }; -use crate::resp_types::{RespPostCommentInfo, RespPostListPost, RespThingInfo, RespUserInfo}; +use crate::resp_types::{ + RespInstanceInfo, RespPostCommentInfo, RespPostListPost, RespThingInfo, RespUserInfo, +}; use crate::util::author_is_me; use crate::PageBaseData; @@ -107,12 +109,29 @@ async fn page_about( ctx: Arc<crate::RouteContext>, req: hyper::Request<hyper::Body>, ) -> Result<hyper::Response<hyper::Body>, crate::Error> { + use std::convert::TryInto; + let cookies = get_cookie_map_for_req(&req)?; let base_data = fetch_base_data(&ctx.backend_host, &ctx.http_client, &cookies).await?; + let api_res = res_to_error( + ctx.http_client + .get( + format!("{}/api/unstable/instance", ctx.backend_host) + .try_into() + .unwrap(), + ) + .await?, + ) + .await?; + let api_res = hyper::body::to_bytes(api_res.into_body()).await?; + let api_res: RespInstanceInfo = serde_json::from_slice(&api_res)?; + Ok(html_response(render::html! { - <HTPage base_data={&base_data} title={"About lotide"}> + <HTPage base_data={&base_data} title={"About"}> + <h1>{"About this instance"}</h1> + {"This instance is running hitide "}{env!("CARGO_PKG_VERSION")}{" on "}{api_res.software.name}{" "}{api_res.software.version}{"."} <h2>{"What is lotide?"}</h2> <p> {"lotide is an attempt to build a federated forum. "} |