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

View file

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