Use Ructe (#327)
All the template are now compiled at compile-time with the `ructe` crate.
I preferred to use it instead of askama because it allows more complex Rust expressions, where askama only supports a small subset of expressions and doesn't allow them everywhere (for instance, `{{ macro!() | filter }}` would result in a parsing error).
The diff is quite huge, but there is normally no changes in functionality.
Fixes #161 and unblocks #110 and #273
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
@use template_utils::*;
|
||||
@use plume_models::comments::Comment;
|
||||
@use plume_models::users::User;
|
||||
|
||||
@(ctx: BaseContext, comm: &Comment, author: User)
|
||||
|
||||
<div class="comment" id="comment-@comm.id">
|
||||
<a class="author" href="/@@/@author.get_fqn(ctx.0)/">
|
||||
@avatar(ctx.0, &author, Size::Small, true, ctx.1)
|
||||
<span class="display-name">@author.name(ctx.0)</span>
|
||||
<small>@author.get_fqn(ctx.0)</small>
|
||||
</a>
|
||||
<div class="text">
|
||||
@if comm.sensitive {
|
||||
<details>
|
||||
<summary>@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>
|
||||
@for res in comm.get_responses(ctx.0) {
|
||||
@:comment(ctx, &res, res.get_author(ctx.0))
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,14 @@
|
||||
@use templates::partials::post_card;
|
||||
@use plume_models::posts::Post;
|
||||
@use template_utils::*;
|
||||
|
||||
@(ctx: BaseContext, articles: Vec<Post>, link: &str, title: &str)
|
||||
|
||||
@if articles.len() > 0 {
|
||||
<h2>@i18n!(ctx.1, title) — <a href="@link">@i18n!(ctx.1, "View all")</a></h2>
|
||||
<div class="cards spaced">
|
||||
@for article in articles {
|
||||
@:post_card(ctx, article)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
@use template_utils::*;
|
||||
@use plume_models::instance::Instance;
|
||||
|
||||
@(ctx: BaseContext, instance: Instance, n_users: i32, n_articles: i32)
|
||||
|
||||
<section class="spaced">
|
||||
<div class="cards">
|
||||
<div class="presentation card">
|
||||
<h2>@i18n!(ctx.1, "What is Plume?")</h2>
|
||||
<main>
|
||||
<p>@i18n!(ctx.1, "Plume is a decentralized blogging engine.")</p>
|
||||
<p>@i18n!(ctx.1, "Authors can manage various blogs from an unique website.")</p>
|
||||
<p>@i18n!(ctx.1, "Articles are also visible on other Plume websites, and you can interact with them directly from other platforms like Mastodon.")</p>
|
||||
</main>
|
||||
<a href="/users/new">@i18n!(ctx.1, "Create your account")</a>
|
||||
</div>
|
||||
<div class="presentation card">
|
||||
<h2>@i18n!(ctx.1, "About {0}"; instance.name)</h2>
|
||||
<main>
|
||||
@Html(instance.short_description_html)
|
||||
<section class="stats">
|
||||
<div>
|
||||
<p>@Html(i18n!(ctx.1, "Home to <em>{0}</em> people"; n_users))</p>
|
||||
</div>
|
||||
<div>
|
||||
<p>@Html(i18n!(ctx.1, "Who wrote <em>{0}</em> articles"; n_articles))</p>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<a href="/about">@i18n!(ctx.1, "Read the detailed rules")</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -0,0 +1,29 @@
|
||||
@use template_utils::*;
|
||||
@use plume_models::posts::Post;
|
||||
|
||||
@(ctx: BaseContext, article: Post)
|
||||
|
||||
<div class="card">
|
||||
@if article.cover_id.is_some() {
|
||||
<div class="cover" style="background-image: url('@Html(article.cover_url(ctx.0).unwrap_or_default())')"></div>
|
||||
}
|
||||
<h3><a href="@article.url(ctx.0)">@article.title</a></h3>
|
||||
<main>
|
||||
<p>@article.subtitle</p>
|
||||
</main>
|
||||
<p class="author">
|
||||
@Html(i18n!(ctx.1, "By {0}"; format!(
|
||||
"<a href=\"/@/{}/\">{}</a>",
|
||||
escape(&article.get_authors(ctx.0)[0].get_fqn(ctx.0)),
|
||||
escape(&article.get_authors(ctx.0)[0].name(ctx.0))
|
||||
)))
|
||||
@if article.published {
|
||||
⋅ @article.creation_date.format("%B %e, %Y")
|
||||
}
|
||||
⋅ <a href="/~/@article.get_blog(ctx.0).get_fqn(ctx.0)/">@article.get_blog(ctx.0).title</a>
|
||||
@if !article.published {
|
||||
⋅ @i18n!(ctx.1, "Draft")
|
||||
}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user