From f923b5b6c076c332d462da16df6564dd32058b5b Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Wed, 18 Oct 2017 16:53:27 +0200 Subject: [PATCH] Display author name in articles and _changes. This fixes #6 --- src/resources/article_resource.rs | 2 ++ src/resources/changes_resource.rs | 2 ++ src/resources/new_article_resource.rs | 2 ++ templates/article_revision.html | 2 +- templates/changes.html | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/resources/article_resource.rs b/src/resources/article_resource.rs index 5b68b6e..7663e71 100644 --- a/src/resources/article_resource.rs +++ b/src/resources/article_resource.rs @@ -47,6 +47,7 @@ impl Resource for ArticleResource { article_id: i32, revision: i32, created: &'a str, + author: Option<&'a str>, edit: bool, cancel_url: Option<&'a str>, @@ -71,6 +72,7 @@ impl Resource for ArticleResource { article_id: data.article_id, revision: data.revision, created: &Local.from_utc_datetime(&data.created).to_rfc2822(), + author: data.author.as_ref().map(|x| &**x), edit: self.edit, cancel_url: Some(&data.slug), title: &data.title, diff --git a/src/resources/changes_resource.rs b/src/resources/changes_resource.rs index cbfa3f2..82d211e 100644 --- a/src/resources/changes_resource.rs +++ b/src/resources/changes_resource.rs @@ -40,6 +40,7 @@ impl Resource for ChangesResource { _article_id: i32, _revision: i32, created: String, + author: Option, slug: String, title: String, @@ -84,6 +85,7 @@ impl Resource for ChangesResource { _article_id: x.article_id, _revision: x.revision, created: Local.from_utc_datetime(&x.created).to_rfc2822(), + author: x.author, slug: x.slug, title: x.title, _latest: x.latest, diff --git a/src/resources/new_article_resource.rs b/src/resources/new_article_resource.rs index 2464aa5..ba209e9 100644 --- a/src/resources/new_article_resource.rs +++ b/src/resources/new_article_resource.rs @@ -55,6 +55,7 @@ impl Resource for NewArticleResource { article_id: &'a str, revision: &'a str, created: &'a str, + author: Option<&'a str>, edit: bool, cancel_url: Option<&'a str>, @@ -78,6 +79,7 @@ impl Resource for NewArticleResource { article_id: NDASH, revision: NDASH, created: NDASH, + author: None, // Implicitly start in edit-mode when no slug is given. This // currently directly corresponds to the /_new endpoint diff --git a/templates/article_revision.html b/templates/article_revision.html index 9dc5448..fe8fa6a 100644 --- a/templates/article_revision.html +++ b/templates/article_revision.html @@ -43,7 +43,7 @@
{{revision}}
Last updated
-
{{created}}
+
{{created}}{{#author}} by {{.}}{{/author}}
{{>footer/items.html}} diff --git a/templates/changes.html b/templates/changes.html index a3afbfa..0f15518 100644 --- a/templates/changes.html +++ b/templates/changes.html @@ -9,11 +9,13 @@ Article Updated + Author {{#changes}} {{.title}} {{.created}} + {{#.author}}{{.}}{{/.author}}{{^.author}}Anonymous{{/.author}} {{/changes}}