Add links to the article before and after diff

This commit is contained in:
Magnus Hoff 2017-11-06 15:58:16 +01:00
parent ac5ff0dbcc
commit 5acca0ddb7
2 changed files with 6 additions and 1 deletions

View file

@ -102,6 +102,8 @@ impl Resource for DiffResource {
consecutive: bool, consecutive: bool,
article_id: u32, article_id: u32,
article_history_link: &'a str, article_history_link: &'a str,
from_link: &'a str,
to_link: &'a str,
title: &'a [Diff<char>], title: &'a [Diff<char>],
lines: &'a [Diff<&'a str>], lines: &'a [Diff<&'a str>],
} }
@ -130,6 +132,8 @@ impl Resource for DiffResource {
.pagination(Pagination::After(self.from.revision)) .pagination(Pagination::After(self.from.revision))
.into_link() .into_link()
), ),
from_link: &format!("_revisions/{}/{}", self.from.article_id, self.from.revision),
to_link: &format!("_revisions/{}/{}", self.to.article_id, self.to.revision),
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

@ -7,7 +7,8 @@
</p> </p>
<p> <p>
See the <a href="{{article_history_link}}">list of all changes</a> to this article. See also the <a href="{{article_history_link}}">list of all changes</a> to this article
or the article as it was <a href="{{from_link}}">before</a> and <a href="{{to_link}}">after</a> this change.
</p> </p>
</div> </div>