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:
@@ -1,66 +0,0 @@
|
||||
{% extends "base" %}
|
||||
{% import "macros" as macros %}
|
||||
|
||||
{% block title %}
|
||||
{{ "Notifications" | _ }}
|
||||
{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ "Notifications" | _ }}</h1>
|
||||
<div class="list">
|
||||
{% for notification in notifications %}
|
||||
<div class="card flex">
|
||||
{% if notification.kind == "COMMENT" %}
|
||||
<i class="icon icon-message-circle left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3><a href="{{ notification.object.post.url }}#comment-{{ notification.object.id }}">
|
||||
{{ "{{ user }} commented your article." | _(user=notification.object.user.name | escape) }}
|
||||
</a></h3>
|
||||
<p><a href="{{ notification.object.post.url }}">{{ notification.object.post.post.title }}</a></p>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%M") }}</small></p>
|
||||
|
||||
{% elif notification.kind == "FOLLOW" %}
|
||||
<i class="icon icon-user-plus left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3><a href="/@/{{ notification.object.follower.fqn }}/">
|
||||
{{ "{{ user }} is now following you." | _(user=notification.object.follower.name | escape) }}
|
||||
</a></h3>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%M") }}</small></p>
|
||||
|
||||
{% elif notification.kind == "LIKE" %}
|
||||
<i class="icon icon-heart left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3>
|
||||
{{ "{{ user }} liked your article." | _(user=notification.object.user.name | escape) }}
|
||||
</h3>
|
||||
<p><a href="{{ notification.object.post.url }}">{{ notification.object.post.post.title }}</a></p>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%M") }}</small></p>
|
||||
|
||||
{% elif notification.kind == "MENTION" %}
|
||||
<i class="icon icon-at-sign left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3><a href="{{ notification.object.url }}">
|
||||
{{ "{{ user }} mentioned you." | _(user=notification.object.user.name | escape) }}
|
||||
</a></h3>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%M") }}</small></p>
|
||||
|
||||
{% elif notification.kind == "RESHARE" %}
|
||||
<i class="icon icon-repeat left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3>
|
||||
{{ "{{ user }} boosted your article." | _(user=notification.object.user.name | escape) }}
|
||||
</h3>
|
||||
<p><a href="{{ notification.object.post.url }}">{{ notification.object.post.post.title }}</a></p>
|
||||
</main>
|
||||
<p><small>{{ notification.creation_date | date(format="%B %e, %H:%M") }}</small></p>
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{{ macros::paginate(page=page, total=n_pages) }}
|
||||
{% endblock content %}
|
||||
@@ -0,0 +1,33 @@
|
||||
@use templates::base;
|
||||
@use template_utils::*;
|
||||
@use plume_models::notifications::Notification;
|
||||
|
||||
@(ctx: BaseContext, notifications: Vec<Notification>, page: i32, n_pages: i32)
|
||||
|
||||
@:base(ctx, "Notifications", {}, {}, {
|
||||
<h1>@i18n!(ctx.1, "Notifications")</h1>
|
||||
|
||||
<div class="list">
|
||||
@for notification in notifications {
|
||||
<div class="card flex">
|
||||
<i class="icon @notification.icon_class() left-icon"></i>
|
||||
<main class="grow">
|
||||
<h3>
|
||||
@if let Some(url) = notification.get_url(ctx.0) {
|
||||
<a href="@url">
|
||||
@i18n!(ctx.1, notification.get_message(); notification.get_actor(ctx.0).name(ctx.0))
|
||||
</a>
|
||||
} else {
|
||||
@i18n!(ctx.1, notification.get_message(); notification.get_actor(ctx.0).name(ctx.0))
|
||||
}
|
||||
</h3>
|
||||
@if let Some(post) = notification.get_post(ctx.0) {
|
||||
<p><a href="@post.url(ctx.0)">@post.title</a></p>
|
||||
}
|
||||
</main>
|
||||
<p><small>@notification.creation_date.format("%B %e, %H:%M")</small></p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@paginate(ctx.1, page, n_pages)
|
||||
})
|
||||
Reference in New Issue
Block a user