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

View file

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