Works on template

Use uri! to generate links instead of hardcoded urls
Fix #110
Fix invalid links needing to be POST forms
Translate login message for boost and like directly from template
Put js for search in its own file
This commit is contained in:
Trinity Pointard
2018-12-07 12:05:01 +01:00
parent 70af57c6e1
commit b4e4b497ee
30 changed files with 218 additions and 175 deletions
+6 -5
View File
@@ -3,18 +3,19 @@
@use plume_models::users::User;
@use templates::{base, partials::post_card};
@use template_utils::*;
@use routes::*;
@(ctx: BaseContext, blog: Blog, fqn: String, authors: &Vec<User>, total_articles: usize, page: i32, n_pages: i32, is_author: bool, posts: Vec<Post>)
@:base(ctx, blog.title.as_ref(), {}, {
<a href="/~/@fqn">@blog.title</a>
<a href="@uri!(blogs::details: name = &fqn)">@blog.title</a>
}, {
<h1>@blog.title <small>~@fqn</small></h1>
<p>@blog.summary</p>
<p>
@i18n!(ctx.1, "One author in this blog: ", "{0} authors in this blog: ", authors.len())
@for author in authors {
<a class="author" href="/@@/@author.get_fqn(ctx.0)">@author.name(ctx.0)</a>
<a class="author" href="@uri!(user::details: name = author.get_fqn(ctx.0))">@author.name(ctx.0)</a>
}
</p>
<p>
@@ -24,13 +25,13 @@
<section>
<h2>
@i18n!(ctx.1, "Latest articles")
<small><a href="/~/@fqn/atom.xml" title="Atom feed">@icon!("rss")</a></small>
<small><a href="@uri!(blogs::atom_feed: name = &fqn)" title="Atom feed">@icon!("rss")</a></small>
</h2>
@if posts.len() < 1 {
<p>@i18n!(ctx.1, "No posts to see here yet.")</p>
}
@if is_author {
<a href="/~/@fqn/new/" class="button inline-block">@i18n!(ctx.1, "New article")</a>
<a href="@uri!(posts::new: blog = &fqn)" class="button inline-block">@i18n!(ctx.1, "New article")</a>
}
<div class="cards">
@for article in posts {
@@ -42,7 +43,7 @@
@if is_author {
<h2>@i18n!(ctx.1, "Danger zone")</h2>
<p>@i18n!(ctx.1, "Be very careful, any action taken here can't be cancelled.")</p>
<form method="post" action="/~/@fqn/delete">
<form method="post" action="@uri!(blogs::delete: name = &fqn)">
<input type="submit" class="inline-block button destructive" value="@i18n!(ctx.1, "Delete this blog")">
</form>
}