Add link to article history from diff page

This commit is contained in:
Magnus Hoff 2017-11-06 15:52:51 +01:00
parent bfd2acda4f
commit ac5ff0dbcc
2 changed files with 14 additions and 0 deletions

View file

@ -14,6 +14,9 @@ use site::Layout;
use state::State;
use web::{Resource, ResponseFuture};
use super::changes_resource;
use super::pagination::Pagination;
type BoxResource = Box<Resource + Sync + Send>;
#[derive(Clone)]
@ -98,6 +101,7 @@ impl Resource for DiffResource {
struct Template<'a> {
consecutive: bool,
article_id: u32,
article_history_link: &'a str,
title: &'a [Diff<char>],
lines: &'a [Diff<&'a str>],
}
@ -120,6 +124,12 @@ impl Resource for DiffResource {
body: &Template {
consecutive: self.to.revision - self.from.revision == 1,
article_id: self.from.article_id as u32,
article_history_link: &format!("_changes{}",
changes_resource::QueryParameters::default()
.article_id(Some(self.from.article_id))
.pagination(Pagination::After(self.from.revision))
.into_link()
),
title: &diff::chars(&self.from.title, &self.to.title)
.into_iter()
.map(|x| match x {

View file

@ -5,6 +5,10 @@
You are viewing the difference between two {{#consecutive?}}consecutive{{/consecutive}}
revisions of <a href="_by_id/{{article_id}}">this article</a>.
</p>
<p>
See the <a href="{{article_history_link}}">list of all changes</a> to this article.
</p>
</div>
<header>