2024-04-21 17:43:36 +02:00
|
|
|
use leptos::*;
|
|
|
|
use crate::prelude::*;
|
|
|
|
|
2024-04-21 18:56:25 +02:00
|
|
|
use apb::{target::Addressed, Base, Object};
|
2024-04-21 17:43:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
#[component]
|
|
|
|
pub fn Object(object: serde_json::Value) -> impl IntoView {
|
2024-04-22 01:01:20 +02:00
|
|
|
let uid = object.id().unwrap_or_default().to_string();
|
2024-04-21 17:43:36 +02:00
|
|
|
let summary = object.summary().unwrap_or_default().to_string();
|
|
|
|
let content = dissolve::strip_html_tags(object.content().unwrap_or_default());
|
2024-04-21 18:56:25 +02:00
|
|
|
let author_id = object.attributed_to().id().unwrap_or_default();
|
|
|
|
let author = CACHE.get_or(&author_id, serde_json::Value::String(author_id.clone()));
|
2024-04-22 01:01:20 +02:00
|
|
|
let attachments = object.attachment()
|
|
|
|
.map(|x| view! {
|
|
|
|
<p><img class="attachment" src={x.url().id().unwrap_or_default()} /></p>
|
|
|
|
})
|
|
|
|
.collect_view();
|
2024-04-21 17:43:36 +02:00
|
|
|
view! {
|
|
|
|
<table class="align w-100">
|
|
|
|
<tr>
|
|
|
|
<td><ActorBanner object=author /></td>
|
|
|
|
<td class="rev" >
|
2024-04-22 01:01:20 +02:00
|
|
|
{object.in_reply_to().id().map(|reply| view! {
|
|
|
|
<small><i><a class="clean mr-1" href={Uri::web(FetchKind::Object, &reply)} title={reply}>reply</a></i></small>
|
|
|
|
})}
|
2024-04-21 18:56:25 +02:00
|
|
|
<a class="clean hover" href={Uri::web(FetchKind::Object, object.id().unwrap_or_default())}>
|
2024-04-21 17:43:36 +02:00
|
|
|
<DateTime t=object.published() />
|
|
|
|
</a>
|
2024-04-22 01:01:20 +02:00
|
|
|
<sup><small><a class="clean" href={uid} target="_blank">"↗"</a></small></sup>
|
2024-04-21 17:43:36 +02:00
|
|
|
<PrivacyMarker addressed=object.addressed() />
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<blockquote class="tl">
|
|
|
|
{if summary.is_empty() { None } else { Some(view! { <code class="color ml-1">{summary}</code> })}}
|
|
|
|
{content.into_iter().map(|x| view! { <p>{x}</p> }).collect_view()}
|
|
|
|
</blockquote>
|
2024-04-22 01:01:20 +02:00
|
|
|
{attachments}
|
2024-04-21 17:43:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|