1
0
Fork 0
forked from alemi/upub

feat(web): show hastag badges on posts

This commit is contained in:
əlemi 2024-07-04 02:36:31 +02:00
parent 9b4fa37e52
commit 0e3d97ae97
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -58,23 +58,37 @@ pub fn Object(
content = content.replace(&from, &to); content = content.replace(&from, &to);
} }
let audience_badge = object.audience().id().str() let audience_badge = object.audience().id().str()
.map(|x| view! { .map(|x| view! {
<a class="clean dim" href={Uri::web(U::Actor, &x)} rel="nofollow noreferrer"> <a class="clean dim" href={Uri::web(U::Actor, &x)}>
<span <span class="border-button ml-1" title={x.clone()}>
class="border-button"
title="this is a group: all interactions will be broadcasted to group members!"
>
<code class="color mr-s">&</code> <code class="color mr-s">&</code>
<small> <small class="mr-s">
{Uri::pretty(&x, 30)} {Uri::pretty(&x, 30)}
</small> </small>
</span> </span>
</a> </a>
}); });
let hashtag_badges = object.tag().filter_map(|x| {
if let Ok(apb::LinkType::Hashtag) = apb::Link::link_type(&x) {
let name = apb::Link::name(&x).unwrap_or_default().replace('#', "");
let href = Uri::web(U::Hashtag, &name);
Some(view! {
<a class="clean dim" href={href}>
<span class="border-button ml-1">
<code class="color mr-s">#</code>
<small class="mr-s">
{name}
</small>
</span>
</a>
})
} else {
None
}
}).collect_view();
let post_image = object.image().get().and_then(|x| x.url().id().str()).map(|x| { let post_image = object.image().get().and_then(|x| x.url().id().str()).map(|x| {
let (expand, set_expand) = create_signal(false); let (expand, set_expand) = create_signal(false);
view! { view! {
@ -140,6 +154,7 @@ pub fn Object(
</table> </table>
{post} {post}
<div class="mt-s ml-1 rev"> <div class="mt-s ml-1 rev">
{if !reply { Some(hashtag_badges) } else { None }}
{if !reply { audience_badge } else { None }} {if !reply { audience_badge } else { None }}
<ReplyButton n=comments target=oid.clone() /> <ReplyButton n=comments target=oid.clone() />
<LikeButton n=likes liked=already_liked target=oid.clone() author=author_id private=!public /> <LikeButton n=likes liked=already_liked target=oid.clone() author=author_id private=!public />