Plume/templates/partials/comment.rs.html

51 lines
2.2 KiB
HTML
Raw Normal View History

@use plume_models::comments::CommentTree;
2020-01-21 07:02:03 +01:00
@use crate::template_utils::*;
@use crate::routes::*;
@(ctx: BaseContext, comment_tree: &CommentTree, in_reply_to: Option<&str>, blog: &str, slug: &str)
2021-11-28 00:46:41 +01:00
@if let Some(comm) = Some(&comment_tree.comment) {
@if let Ok(author) = comm.get_author(ctx.0) {
2022-01-02 18:06:59 +01:00
@* comment-@comm.id is used for link *@
<div class="comment u-comment h-cite" id="comment-@comm.id">
<main class="content">
<header>
<a class="author u-author h-card" href="@uri!(user::details: name = &author.fqn)" dir="auto">
@avatar(ctx.0, &author, Size::Small, true, ctx.1)
<span class="display-name p-name">@author.name()</span>
<small>@author.fqn</small>
</a>
<p class="dt-published" datetime="@comm.creation_date.format("%F %T")">
2022-01-02 18:06:59 +01:00
@if let Ok(post) = comm.get_post(ctx.0) {
@* comment-@comm.id is same to this div's id attribute *@
<a class="u-url" href="@post.ap_url#comment-@comm.id">@comm.creation_date.format("%B %e, %Y %H:%M")</a>
}
</p>
@if let Some(ref in_reply_to) = in_reply_to {
<a class="u-in-reply-to hidden" href="@in_reply_to"></a>
}
</header>
<div class="text p-content">
@if comm.sensitive {
<details>
<summary dir="auto">@comm.spoiler_text</summary>
}
@Html(&comm.content)
@if comm.sensitive {
</details>
}
</div>
<a class="button icon icon-message-circle" href="?responding_to=@comm.id">@i18n!(ctx.1, "Respond")</a>
@if ctx.2.clone().map(|u| u.id == author.id).unwrap_or(false) {
<form class="inline icon icon-trash" method="post" action="@uri!(comments::delete: blog = blog, slug = slug, id = comm.id)">
<input onclick="return confirm('@i18n!(ctx.1, "Are you sure?")')" type="submit" value="@i18n!(ctx.1, "Delete this comment")">
</form>
}
</main>
@for res in &comment_tree.responses {
2021-01-15 15:21:33 +01:00
@:comment_html(ctx, res, comm.ap_url.as_deref(), blog, slug)
}
</div>
}}