summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Reeder <colin@vpzom.click>2020-07-13 20:24:38 -0600
committerColin Reeder <colin@vpzom.click>2020-07-13 20:24:38 -0600
commitaaa2e14d4f0eaebe5896edfcd4212f8b464f9924 (patch)
treeff2f66f7be9d9976faa4d36525376328f3435d7e
parentd4949e7eddcf38f59fa79dbb906450c1930aba2c (diff)
Rearrange community page layout
-rw-r--r--res/main.css15
-rw-r--r--src/resp_types.rs4
-rw-r--r--src/routes/communities.rs76
3 files changed, 62 insertions, 33 deletions
diff --git a/res/main.css b/res/main.css
index 208e8c0..7a32928 100644
--- a/res/main.css
+++ b/res/main.css
@@ -36,3 +36,18 @@ body {
margin-top: .5em;
margin-bottom: .5em;
}
+
+.communitySidebar {
+ float: right;
+ width: 300px;
+}
+
+.communitySidebar > h2 {
+ margin-bottom: 0;
+}
+
+@media (max-width: 768px) {
+ .communitySidebar {
+ display: none; /* TODO still show this somewhere */
+ }
+}
diff --git a/src/resp_types.rs b/src/resp_types.rs
index dfe7619..f1e5bc1 100644
--- a/src/resp_types.rs
+++ b/src/resp_types.rs
@@ -83,6 +83,10 @@ pub struct RespYourFollow {
pub struct RespCommunityInfoMaybeYour<'a> {
#[serde(flatten)]
pub base: RespMinimalCommunityInfo<'a>,
+
+ pub description: Cow<'a, str>,
+
+ pub you_are_moderator: Option<bool>,
pub your_follow: Option<RespYourFollow>,
}
diff --git a/src/routes/communities.rs b/src/routes/communities.rs
index dd58825..57e0172 100644
--- a/src/routes/communities.rs
+++ b/src/routes/communities.rs
@@ -142,42 +142,52 @@ async fn page_community(
Ok(html_response(render::html! {
<HTPage base_data={&base_data} title>
- <h1 style={"margin-bottom: 0"}>{title}</h1>
- <em>{format!("@{}@{}", community_info.as_ref().name, community_info.as_ref().host)}</em>
- <p>
- {
- if base_data.login.is_some() {
- Some(match community_info.your_follow {
- Some(RespYourFollow { accepted: true }) => {
- render::rsx! {
- <form method={"POST"} action={format!("/communities/{}/unfollow", community_id)}>
- <button type={"submit"}>{"Unfollow"}</button>
- </form>
- }
- },
- Some(RespYourFollow { accepted: false }) => {
- render::rsx! {
- <form>
- <button disabled={""}>{"Follow request sent!"}</button>
- </form>
- }
- },
- None => {
- render::rsx! {
- <form method={"POST"} action={format!("/communities/{}/follow", community_id)}>
- <button type={"submit"}>{"Follow"}</button>
- </form>
+ <div class={"communitySidebar"}>
+ <h2>{title}</h2>
+ <em>{format!("@{}@{}", community_info.as_ref().name, community_info.as_ref().host)}</em>
+ <p>
+ {
+ if base_data.login.is_some() {
+ Some(match community_info.your_follow {
+ Some(RespYourFollow { accepted: true }) => {
+ render::rsx! {
+ <form method={"POST"} action={format!("/communities/{}/unfollow", community_id)}>
+ <button type={"submit"}>{"Unfollow"}</button>
+ </form>
+ }
+ },
+ Some(RespYourFollow { accepted: false }) => {
+ render::rsx! {
+ <form>
+ <button disabled={""}>{"Follow request sent!"}</button>
+ </form>
+ }
+ },
+ None => {
+ render::rsx! {
+ <form method={"POST"} action={format!("/communities/{}/follow", community_id)}>
+ <button type={"submit"}>{"Follow"}</button>
+ </form>
+ }
}
- }
- })
- } else {
- None
+ })
+ } else {
+ None
+ }
}
+ </p>
+ <p>
+ <a href={&new_post_url}>{"New Post"}</a>
+ </p>
+ <p>{community_info.description.as_ref()}</p>
+ </div>
+ {
+ if posts.is_empty() {
+ Some(render::rsx! { <p>{"Looks like there's nothing here."}</p> })
+ } else {
+ None
}
- </p>
- <p>
- <a href={&new_post_url}>{"New Post"}</a>
- </p>
+ }
<ul>
{posts.iter().map(|post| {
PostItem { post, in_community: true }