From 6c92328b8d5201ef6171dac63fc0ecfe3d58c275 Mon Sep 17 00:00:00 2001 From: alemi Date: Wed, 24 Apr 2024 05:38:09 +0200 Subject: [PATCH] feat(web): hide sensitive posts, add posting option --- web/src/components/object.rs | 16 +++++++++++----- web/src/control.rs | 13 +++++++++++-- web/src/lib.rs | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/web/src/components/object.rs b/web/src/components/object.rs index b1a7c210..ad6c9c44 100644 --- a/web/src/components/object.rs +++ b/web/src/components/object.rs @@ -1,5 +1,5 @@ use leptos::*; -use crate::prelude::*; +use crate::{prelude::*, URL_SENSITIVE}; use apb::{target::Addressed, Base, Object}; @@ -10,15 +10,21 @@ pub fn Object(object: serde_json::Value) -> impl IntoView { let content = dissolve::strip_html_tags(object.content().unwrap_or_default()); let author_id = object.attributed_to().id().unwrap_or_default(); let author = CACHE.get_or(&author_id, serde_json::Value::String(author_id.clone())); + let sensitive = object.sensitive().unwrap_or_default(); let attachments = object.attachment() .map(|x| { let (expand, set_expand) = create_signal(false); + let href = x.url().id().unwrap_or_default(); view! {

@@ -48,7 +54,7 @@ pub fn Object(object: serde_json::Value) -> impl IntoView {

- + {content.into_iter().map(|x| view! {

{x}

}).collect_view()} {attachments_padding} {attachments} @@ -58,11 +64,11 @@ pub fn Object(object: serde_json::Value) -> impl IntoView { } #[component] -pub fn Summary(summary: Option, children: Children) -> impl IntoView { +pub fn Summary(summary: Option, open: bool, children: Children) -> impl IntoView { match summary.filter(|x| !x.is_empty()) { None => children().into_view(), Some(summary) => view! { -
+
{summary} diff --git a/web/src/control.rs b/web/src/control.rs index 128265a7..9602e2ee 100644 --- a/web/src/control.rs +++ b/web/src/control.rs @@ -95,6 +95,7 @@ pub fn AdvancedPostBox(username: Signal>, advanced: WriteSignal = create_node_ref(); let summary_ref: NodeRef = create_node_ref(); let content_ref: NodeRef = create_node_ref(); let context_ref: NodeRef = create_node_ref(); @@ -139,12 +140,20 @@ pub fn AdvancedPostBox(username: Signal>, advanced: WriteSignal
- - + + + + + +
+ + +
+
diff --git a/web/src/lib.rs b/web/src/lib.rs index 4bb03e6b..f2161dd7 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -10,6 +10,7 @@ pub mod prelude; pub const URL_BASE: &str = "https://feditest.alemi.dev"; pub const URL_PREFIX: &str = "/web"; +pub const URL_SENSITIVE: &str = "https://cdn.alemi.dev/social/nsfw.png"; pub const NAME: &str = "μ"; use std::sync::Arc;