summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/mod.rs38
-rw-r--r--src/resp_types.rs6
-rw-r--r--src/routes/communities.rs8
-rw-r--r--src/routes/mod.rs4
4 files changed, 46 insertions, 10 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 793c54c..5c529ca 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -4,9 +4,9 @@ use std::borrow::{Borrow, Cow};
use std::collections::HashMap;
use crate::resp_types::{
- RespCommentInfo, RespMinimalAuthorInfo, RespMinimalCommentInfo, RespMinimalCommunityInfo,
- RespNotification, RespNotificationInfo, RespPostCommentInfo, RespPostInfo, RespPostListPost,
- RespThingComment, RespThingInfo,
+ RespCommentInfo, RespCommunityInfoMaybeYour, RespMinimalAuthorInfo, RespMinimalCommentInfo,
+ RespMinimalCommunityInfo, RespNotification, RespNotificationInfo, RespPostCommentInfo,
+ RespPostInfo, RespPostListPost, RespThingComment, RespThingInfo, RespUserInfo,
};
use crate::util::{abbreviate_link, author_is_me};
use crate::PageBaseData;
@@ -194,6 +194,38 @@ impl<'a> HavingContent for RespPostInfo<'a> {
}
}
+pub struct HavingContentRef<'a> {
+ content_html: Option<&'a str>,
+ content_text: Option<&'a str>,
+}
+
+impl<'a> HavingContent for HavingContentRef<'a> {
+ fn content_text(&self) -> Option<&str> {
+ self.content_text
+ }
+ fn content_html(&self) -> Option<&str> {
+ self.content_html
+ }
+}
+
+impl<'a> RespUserInfo<'a> {
+ pub fn description(&'a self) -> HavingContentRef<'a> {
+ HavingContentRef {
+ content_html: self.description_html.as_deref(),
+ content_text: self.description_text.as_deref(),
+ }
+ }
+}
+
+impl<'a> RespCommunityInfoMaybeYour<'a> {
+ pub fn description(&'a self) -> HavingContentRef<'a> {
+ HavingContentRef {
+ content_html: self.description_html.as_deref(),
+ content_text: self.description_text.as_deref(),
+ }
+ }
+}
+
pub struct Content<'a, T: HavingContent + 'a> {
pub src: &'a T,
}
diff --git a/src/resp_types.rs b/src/resp_types.rs
index e77d03d..03cce9f 100644
--- a/src/resp_types.rs
+++ b/src/resp_types.rs
@@ -158,7 +158,8 @@ pub struct RespMinimalCommunityInfo<'a> {
pub struct RespUserInfo<'a> {
#[serde(flatten)]
pub base: RespMinimalAuthorInfo<'a>,
- pub description: Cow<'a, str>,
+ pub description_html: Option<Cow<'a, str>>,
+ pub description_text: Option<Cow<'a, str>>,
pub suspended: Option<bool>,
pub your_note: Option<JustContentText<'a>>,
}
@@ -204,7 +205,8 @@ pub struct RespCommunityInfoMaybeYour<'a> {
#[serde(flatten)]
pub base: RespMinimalCommunityInfo<'a>,
- pub description: Cow<'a, str>,
+ pub description_html: Option<Cow<'a, str>>,
+ pub description_text: Option<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 44fc1ec..fe02857 100644
--- a/src/routes/communities.rs
+++ b/src/routes/communities.rs
@@ -1,4 +1,6 @@
-use crate::components::{CommunityLink, HTPage, MaybeFillInput, MaybeFillTextArea, PostItem};
+use crate::components::{
+ CommunityLink, Content, HTPage, MaybeFillInput, MaybeFillTextArea, PostItem,
+};
use crate::resp_types::{
JustContentHTML, JustStringID, RespCommunityInfoMaybeYour, RespMinimalAuthorInfo,
RespMinimalCommunityInfo, RespPostListPost, RespYourFollow,
@@ -229,7 +231,7 @@ async fn page_community(
None
}
}
- <p>{community_info.description.as_ref()}</p>
+ <Content src={&community_info.description()} />
{
if community_info.as_ref().local {
Some(render::rsx! {
@@ -333,7 +335,7 @@ async fn page_community_edit_inner(
<form method={"POST"} action={format!("/communities/{}/edit/submit", community_id)}>
<label>
{lang.tr("description", None)}{":"}<br />
- <MaybeFillTextArea values={&prev_values} name={"description"} default_value={Some(community_info.description.as_ref())} />
+ <MaybeFillTextArea values={&prev_values} name={"description"} default_value={Some(community_info.description_text.as_deref().unwrap_or(""))} />
</label>
<div>
<button r#type={"submit"}>{lang.tr("submit", None)}</button>
diff --git a/src/routes/mod.rs b/src/routes/mod.rs
index 5affcf9..bd22bf5 100644
--- a/src/routes/mod.rs
+++ b/src/routes/mod.rs
@@ -1427,7 +1427,7 @@ async fn page_user(
None
}
}
- <p>{user.description.as_ref()}</p>
+ <Content src={&user.description()} />
{
if things.is_empty() {
Some(render::rsx! { <p>{lang.tr("nothing", None)}</p> })
@@ -1502,7 +1502,7 @@ async fn page_user_edit(
<div>
<label>
{lang.tr("user_edit_description_prompt", None)}<br />
- <textarea name={"description"}>{user.description.as_ref()}</textarea>
+ <textarea name={"description"}>{user.description_text.as_deref().unwrap_or("")}</textarea>
</label>
</div>
<div>