Add link to diff view from article revision
This commit is contained in:
parent
f9905e6548
commit
a796f299a4
2 changed files with 18 additions and 0 deletions
|
@ -11,6 +11,7 @@ use site::Layout;
|
||||||
use web::{Resource, ResponseFuture};
|
use web::{Resource, ResponseFuture};
|
||||||
|
|
||||||
use super::changes_resource::QueryParameters;
|
use super::changes_resource::QueryParameters;
|
||||||
|
use super::diff_resource;
|
||||||
use super::pagination::Pagination;
|
use super::pagination::Pagination;
|
||||||
|
|
||||||
pub struct ArticleRevisionResource {
|
pub struct ArticleRevisionResource {
|
||||||
|
@ -79,6 +80,7 @@ impl Resource for ArticleRevisionResource {
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
link_current: &'a str,
|
link_current: &'a str,
|
||||||
timestamp_and_author: &'a str,
|
timestamp_and_author: &'a str,
|
||||||
|
diff_link: Option<String>,
|
||||||
|
|
||||||
title: &'a str,
|
title: &'a str,
|
||||||
rendered: String,
|
rendered: String,
|
||||||
|
@ -101,6 +103,18 @@ impl Resource for ArticleRevisionResource {
|
||||||
&Local.from_utc_datetime(&data.created),
|
&Local.from_utc_datetime(&data.created),
|
||||||
data.author.as_ref().map(|x| &**x)
|
data.author.as_ref().map(|x| &**x)
|
||||||
),
|
),
|
||||||
|
diff_link:
|
||||||
|
if data.revision > 1 {
|
||||||
|
Some(format!("_diff/{}?{}",
|
||||||
|
data.article_id,
|
||||||
|
diff_resource::QueryParameters::new(
|
||||||
|
data.revision as u32 - 1,
|
||||||
|
data.revision as u32,
|
||||||
|
)
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
title: &data.title,
|
title: &data.title,
|
||||||
rendered: render_markdown(&data.body),
|
rendered: render_markdown(&data.body),
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
You are viewing an historical version of <a href="{{link_current}}">this article</a>,
|
You are viewing an historical version of <a href="{{link_current}}">this article</a>,
|
||||||
authored at {{{timestamp_and_author}}}.
|
authored at {{{timestamp_and_author}}}.
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
{{#diff_link}}See <a href="{{.}}">the changes</a> made for this revision.{{/diff_link}}
|
||||||
|
{{^diff_link}}This is the first revision of the article.{{/diff_link}}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="rendered">
|
<div class="rendered">
|
||||||
|
|
Loading…
Reference in a new issue