2018-12-06 18:54:16 +01:00
|
|
|
@use plume_models::blogs::Blog;
|
2018-12-24 11:23:04 +01:00
|
|
|
@use plume_models::comments::{Comment, CommentTree};
|
2018-12-06 18:54:16 +01:00
|
|
|
@use plume_models::posts::Post;
|
|
|
|
@use plume_models::tags::Tag;
|
|
|
|
@use plume_models::users::User;
|
2019-08-21 00:42:04 +02:00
|
|
|
@use std::path::Path;
|
2020-01-21 07:02:03 +01:00
|
|
|
@use validator::ValidationErrors;
|
|
|
|
@use crate::templates::{base, partials::comment};
|
|
|
|
@use crate::template_utils::*;
|
|
|
|
@use crate::routes::comments::NewCommentForm;
|
|
|
|
@use crate::routes::*;
|
2018-12-06 18:54:16 +01:00
|
|
|
|
2018-12-24 11:23:04 +01:00
|
|
|
@(ctx: BaseContext, article: Post, blog: Blog, comment_form: &NewCommentForm, comment_errors: ValidationErrors, tags: Vec<Tag>, comments: Vec<CommentTree>, previous_comment: Option<Comment>, n_likes: i64, n_reshares: i64, has_liked: bool, has_reshared: bool, is_following: bool, author: User)
|
2018-12-06 18:54:16 +01:00
|
|
|
|
2019-02-02 15:23:50 +01:00
|
|
|
@:base(ctx, article.title.clone(), {
|
2018-12-07 12:05:01 +01:00
|
|
|
<meta property="og:title" content="@article.title"/>
|
2018-12-06 18:54:16 +01:00
|
|
|
<meta property="og:type" content="article"/>
|
|
|
|
@if article.cover_id.is_some() {
|
|
|
|
<meta property="og:image" content="@Html(article.cover_url(ctx.0).unwrap_or_default())"/>
|
|
|
|
}
|
2019-03-06 18:28:10 +01:00
|
|
|
<meta property="og:url" content="@uri!(posts::details: blog = &blog.fqn, slug = &article.slug, responding_to = _)"/>
|
2018-12-06 18:54:16 +01:00
|
|
|
<meta property="og:description" content="@article.subtitle"/>
|
2019-12-16 22:55:02 +01:00
|
|
|
<link rel="canonical" href="@article.ap_url"/>
|
2019-08-21 00:42:04 +02:00
|
|
|
|
|
|
|
@if !ctx.2.clone().map(|u| u.hide_custom_css).unwrap_or(false) {
|
|
|
|
@if let Some(ref theme) = blog.theme {
|
2021-01-15 15:58:48 +01:00
|
|
|
<link rel="stylesheet" href="@uri!(plume_static_files: file = Path::new("css").join(theme).join("theme.css"), build_id = CACHE_NAME)">
|
2019-08-21 00:42:04 +02:00
|
|
|
}
|
|
|
|
}
|
2018-12-06 18:54:16 +01:00
|
|
|
}, {
|
2019-03-06 18:28:10 +01:00
|
|
|
<a href="@uri!(blogs::details: name = &blog.fqn, page = _)">@blog.title</a>
|
2018-12-06 18:54:16 +01:00
|
|
|
}, {
|
2018-12-08 21:52:46 +01:00
|
|
|
<div class="h-entry">
|
2019-05-18 14:09:51 +02:00
|
|
|
<header
|
|
|
|
class="article @if article.cover_id.is_some() { illustrated }"
|
|
|
|
@if article.cover_id.is_some() { style="background-image: url('@article.cover_url(ctx.0).unwrap_or_default()'" }
|
|
|
|
>
|
|
|
|
<div>
|
2019-07-11 09:34:27 +02:00
|
|
|
<h1 class="article p-name" dir="auto">@article.title</h1>
|
|
|
|
<div class="article-info" dir="auto">
|
2019-05-18 14:09:51 +02:00
|
|
|
<span class="author">
|
|
|
|
@Html(i18n!(ctx.1, "Written by {0}"; format!("<a href=\"{}\">{}</a>",
|
2020-05-05 23:48:29 +02:00
|
|
|
escape(&uri!(user::details: name = &author.fqn).to_string()),
|
2019-05-18 14:09:51 +02:00
|
|
|
escape(&author.name()))))
|
|
|
|
</span>
|
|
|
|
—
|
|
|
|
<span class="date dt-published" datetime="@article.creation_date.format("%F %T")">@article.creation_date.format("%B %e, %Y")</span><a class="u-url" href="@article.ap_url"></a>
|
|
|
|
</div>
|
2019-07-11 09:34:27 +02:00
|
|
|
<h2 class="article p-summary" dir="auto">@article.subtitle</h2>
|
2019-05-18 14:09:51 +02:00
|
|
|
</div>
|
|
|
|
@if article.cover_id.is_some() {
|
|
|
|
<div class="shadow"></div>
|
|
|
|
<img class="u-photo hidden" src="@article.cover_url(ctx.0).unwrap_or_default()"/>
|
2018-12-06 18:54:16 +01:00
|
|
|
}
|
2019-05-18 14:09:51 +02:00
|
|
|
</header>
|
|
|
|
|
2019-07-11 09:34:27 +02:00
|
|
|
<article class="e-content" dir="auto">
|
2018-12-06 18:54:16 +01:00
|
|
|
@Html(&article.content)
|
|
|
|
</article>
|
|
|
|
<div class="article-meta">
|
2019-05-18 14:09:51 +02:00
|
|
|
<section class="split">
|
2019-07-11 09:34:27 +02:00
|
|
|
<ul class="tags" dir="auto">
|
2019-05-18 14:09:51 +02:00
|
|
|
@for tag in tags {
|
|
|
|
@if !tag.is_hashtag {
|
|
|
|
<li><a class="p-category" href="@uri!(tags::tag: name = &tag.tag, page = _)">@tag.tag</a></li>
|
|
|
|
} else {
|
|
|
|
<span class="hidden p-category">@tag.tag</span>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</ul>
|
2019-07-11 09:34:27 +02:00
|
|
|
<p class="right" dir="auto">
|
2019-05-18 14:09:51 +02:00
|
|
|
@if article.license.is_empty() {
|
|
|
|
@i18n!(ctx.1, "All rights reserved."; &article.license)
|
2018-12-08 21:52:46 +01:00
|
|
|
} else {
|
2019-05-18 14:09:51 +02:00
|
|
|
@i18n!(ctx.1, "This article is under the {0} license."; &article.license)
|
2018-12-06 18:54:16 +01:00
|
|
|
}
|
2019-05-18 14:09:51 +02:00
|
|
|
</p>
|
|
|
|
</section>
|
2018-12-06 18:54:16 +01:00
|
|
|
@if ctx.2.is_some() {
|
2019-05-18 14:09:51 +02:00
|
|
|
<section class="actions">
|
2019-03-06 18:28:10 +01:00
|
|
|
<form class="likes" action="@uri!(likes::create: blog = &blog.fqn, slug = &article.slug)" method="POST">
|
2019-02-02 15:23:50 +01:00
|
|
|
<p aria-label="@i18n!(ctx.1, "One like", "{0} likes"; n_likes)" title="@i18n!(ctx.1, "One like", "{0} likes"; n_likes)">
|
2018-12-06 18:54:16 +01:00
|
|
|
@n_likes
|
|
|
|
</p>
|
|
|
|
|
|
|
|
@if has_liked {
|
|
|
|
<button type="submit" class="action liked">@icon!("heart") @i18n!(ctx.1, "I don't like this anymore")</button>
|
2019-05-18 14:09:51 +02:00
|
|
|
} else {
|
2018-12-06 18:54:16 +01:00
|
|
|
<button type="submit" class="action">@icon!("heart") @i18n!(ctx.1, "Add yours")</button>
|
|
|
|
}
|
|
|
|
</form>
|
2019-03-06 18:28:10 +01:00
|
|
|
<form class="reshares" action="@uri!(reshares::create: blog = &blog.fqn, slug = &article.slug)" method="POST">
|
2019-04-04 21:06:37 +02:00
|
|
|
<p aria-label="@i18n!(ctx.1, "One boost", "{0} boosts"; n_reshares)" title="@i18n!(ctx.1, "One boost", "{0} boosts"; n_reshares)">
|
2018-12-06 18:54:16 +01:00
|
|
|
@n_reshares
|
|
|
|
</p>
|
|
|
|
|
|
|
|
@if has_reshared {
|
|
|
|
<button type="submit" class="action reshared">@icon!("repeat") @i18n!(ctx.1, "I don't want to boost this anymore")</button>
|
|
|
|
} else {
|
|
|
|
<button type="submit" class="action">@icon!("repeat") @i18n!(ctx.1, "Boost")</button>
|
|
|
|
}
|
|
|
|
</form>
|
2019-05-18 14:09:51 +02:00
|
|
|
</section>
|
2018-12-06 18:54:16 +01:00
|
|
|
} else {
|
2019-05-18 14:09:51 +02:00
|
|
|
<p class="center">@Html(i18n!(ctx.1, "{0}Log in{1}, or {2}use your Fediverse account{3} to interact with this article";
|
2020-05-05 23:48:29 +02:00
|
|
|
format!("<a href='{}'>", escape(&uri!(session::new: m = _).to_string())), "</a>",
|
|
|
|
format!("<a href='{}'>", escape(&uri!(posts::remote_interact: blog_name = &blog.fqn, slug = &article.slug).to_string())), "</a>"
|
2019-05-18 14:09:51 +02:00
|
|
|
))
|
|
|
|
</p>
|
|
|
|
<section class="actions">
|
2018-12-06 18:54:16 +01:00
|
|
|
<div class="likes">
|
2019-02-02 15:23:50 +01:00
|
|
|
<p aria-label="@i18n!(ctx.1, "One like", "{0} likes"; n_likes)" title="@i18n!(ctx.1, "One like", "{0} likes"; n_likes)">
|
2018-12-06 18:54:16 +01:00
|
|
|
@n_likes
|
|
|
|
</p>
|
2019-05-18 14:09:51 +02:00
|
|
|
<a href="@uri!(posts::remote_interact: blog_name = &blog.fqn, slug = &article.slug)" class="action">@icon!("heart") @i18n!(ctx.1, "Add yours")</a>
|
2018-12-06 18:54:16 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="reshares">
|
2019-02-02 15:23:50 +01:00
|
|
|
<p aria-label="@i18n!(ctx.1, "One boost", "{0} boost"; n_reshares)" title="@i18n!(ctx.1, "One boost", "{0} boosts"; n_reshares)">
|
2018-12-06 18:54:16 +01:00
|
|
|
@n_reshares
|
|
|
|
</p>
|
2019-04-17 22:09:07 +02:00
|
|
|
<a href="@uri!(posts::remote_interact: blog_name = &blog.fqn, slug = &article.slug)" class="action">@icon!("repeat") @i18n!(ctx.1, "Boost")</a>
|
2018-12-06 18:54:16 +01:00
|
|
|
</div>
|
2019-05-18 14:09:51 +02:00
|
|
|
</section>
|
2018-12-06 18:54:16 +01:00
|
|
|
}
|
2019-05-18 14:09:51 +02:00
|
|
|
<section class="banner">
|
2019-07-11 09:34:27 +02:00
|
|
|
<div class="flex p-author h-card user" dir="auto">
|
2019-05-18 14:09:51 +02:00
|
|
|
@avatar(ctx.0, &author, Size::Medium, true, ctx.1)
|
|
|
|
<div class="grow">
|
|
|
|
<h2 class="p-name">
|
|
|
|
<a href="@uri!(user::details: name = &author.fqn)">@author.name()</a>
|
|
|
|
<a rel="author" class="u-url" href="@author.ap_url"></a>
|
|
|
|
</h2>
|
|
|
|
<p>@Html(&author.summary_html)</p>
|
|
|
|
</div>
|
|
|
|
@if !ctx.2.as_ref().map(|u| u.id == author.id).unwrap_or(false) {
|
|
|
|
<form action="@uri!(user::follow: name = &author.fqn)" method="POST">
|
|
|
|
<input type="submit" class="button" value="@if is_following {@i18n!(ctx.1, "Unsubscribe")} else {@i18n!(ctx.1, "Subscribe")}">
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</section>
|
2019-07-11 09:34:27 +02:00
|
|
|
<section class="comments" dir="auto">
|
2018-12-06 18:54:16 +01:00
|
|
|
<h2>@i18n!(ctx.1, "Comments")</h2>
|
|
|
|
|
|
|
|
@if ctx.2.is_some() {
|
2019-03-06 18:28:10 +01:00
|
|
|
<form method="post" action="@uri!(comments::create: blog_name = &blog.fqn, slug = &article.slug)">
|
2019-08-27 16:50:24 +02:00
|
|
|
@(Input::new("warning", i18n!(ctx.1, "Content warning"))
|
|
|
|
.default(&comment_form.warning)
|
|
|
|
.error(&comment_errors)
|
|
|
|
.optional()
|
|
|
|
.html(ctx.1))
|
2018-12-06 18:54:16 +01:00
|
|
|
|
|
|
|
<label for="plume-editor">@i18n!(ctx.1, "Your comment")</label>
|
|
|
|
@if let Some(ref prev) = previous_comment {
|
|
|
|
<input type="hidden" name="responding_to" value="@prev.id"/>
|
|
|
|
}
|
2019-07-11 09:34:27 +02:00
|
|
|
<textarea id="plume-editor" name="content" dir="auto">@comment_form.content</textarea>
|
2018-12-06 18:54:16 +01:00
|
|
|
<input type="submit" value="@i18n!(ctx.1, "Submit comment")" />
|
|
|
|
</form>
|
|
|
|
}
|
|
|
|
|
|
|
|
@if !comments.is_empty() {
|
2019-05-18 14:09:51 +02:00
|
|
|
@for comm in comments {
|
|
|
|
@:comment(ctx, &comm, Some(&article.ap_url), &blog.fqn, &article.slug)
|
|
|
|
}
|
2018-12-06 18:54:16 +01:00
|
|
|
} else {
|
2019-07-11 09:34:27 +02:00
|
|
|
<p class="center" dir="auto">@i18n!(ctx.1, "No comments yet. Be the first to react!")</p>
|
2018-12-06 18:54:16 +01:00
|
|
|
}
|
2019-05-18 14:09:51 +02:00
|
|
|
</section>
|
2018-12-06 18:54:16 +01:00
|
|
|
</div>
|
2018-12-08 21:52:46 +01:00
|
|
|
</div>
|
2019-05-18 14:09:51 +02:00
|
|
|
@if ctx.2.clone().and_then(|u| article.is_author(ctx.0, u.id).ok()).unwrap_or(false) {
|
|
|
|
<aside class="bottom-bar">
|
|
|
|
<div>
|
|
|
|
<form class="inline" method="post" action="@uri!(posts::delete: blog_name = &blog.fqn, slug = &article.slug)">
|
|
|
|
<input class="button destructive" onclick="return confirm('@i18n!(ctx.1, "Are you sure?")')" type="submit" value="@i18n!(ctx.1, "Delete")">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
@if !article.published {
|
|
|
|
<p>@i18n!(ctx.1, "This article is still a draft. Only you and other authors can see it.")</p>
|
|
|
|
} else {
|
|
|
|
<p>@i18n!(ctx.1, "Only you and other authors can edit this article.")</p>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
@if !article.published {
|
|
|
|
<a class="button secondary" href="@uri!(posts::edit: blog = &blog.fqn, slug = &article.slug)">@i18n!(ctx.1, "Publish")</a>
|
|
|
|
}
|
|
|
|
<a class="button" href="@uri!(posts::edit: blog = &blog.fqn, slug = &article.slug)">@i18n!(ctx.1, "Edit")</a>
|
|
|
|
</div>
|
|
|
|
</aside>
|
|
|
|
}
|
2018-12-06 18:54:16 +01:00
|
|
|
})
|