Simplify _changes list

This commit is contained in:
Magnus Hoff 2017-10-03 22:31:27 +02:00
parent f22ffc112a
commit 1aeba7b2e3
2 changed files with 10 additions and 20 deletions

View file

@ -37,14 +37,14 @@ impl Resource for ChangesResource {
use chrono::{TimeZone, Local};
struct Row {
article_id: i32,
revision: i32,
_article_id: i32,
_revision: i32,
created: String,
slug: String,
title: String,
latest: bool,
_latest: bool,
}
#[derive(BartDisplay)]
@ -62,12 +62,12 @@ impl Resource for ChangesResource {
let changes = &data.into_iter().map(|x| {
Row {
article_id: x.article_id,
revision: x.revision,
created: Local.from_utc_datetime(&x.created).to_string(),
_article_id: x.article_id,
_revision: x.revision,
created: Local.from_utc_datetime(&x.created).to_rfc2822(),
slug: x.slug,
title: x.title,
latest: x.latest,
_latest: x.latest,
}
}).collect::<Vec<_>>();

View file

@ -6,22 +6,12 @@
<article>
<table>
<tr>
<th>Title</th>
<th>Slug</th>
<th>Article ID</th>
<th>Revision</th>
<th>Created</th>
<th>Article</th>
<th>Updated</th>
</tr>
{{#changes}}
<tr>
<td>
{{#.latest?}}<a href="{{#..slug.is_empty()?}}.{{/..slug.is_empty()}}{{..slug}}">{{/.latest}}
{{.title}}
{{#.latest?}}</a>{{/.latest}}
</td>
<td>{{#.slug.is_empty()?}}/{{/.slug.is_empty()}}{{.slug}}</td>
<td>{{.article_id}}</td>
<td>{{.revision}}</td>
<td><a href="{{#.slug.is_empty()?}}.{{/.slug.is_empty()}}{{.slug}}">{{.title}}</a></td>
<td>{{.created}}</td>
</tr>
{{/changes}}