Tweak links to _changes feed
This commit is contained in:
parent
de413f69bf
commit
3fb3139d28
3 changed files with 18 additions and 6 deletions
|
@ -38,7 +38,7 @@ pub fn timestamp_and_author(sequence_number: i32, article_id: i32, created: &Dat
|
|||
author: Option<Author<'a>>,
|
||||
}
|
||||
|
||||
let pagination = Pagination::Before(sequence_number + 1);
|
||||
let pagination = Pagination::After(sequence_number - 1);
|
||||
|
||||
Template {
|
||||
created: &created.to_rfc2822(),
|
||||
|
@ -53,6 +53,7 @@ pub fn timestamp_and_author(sequence_number: i32, article_id: i32, created: &Dat
|
|||
history: format!("_changes{}",
|
||||
QueryParameters::default()
|
||||
.pagination(pagination)
|
||||
.article_id(Some(article_id))
|
||||
.author(Some(author.to_owned()))
|
||||
.into_link()
|
||||
),
|
||||
|
|
|
@ -202,8 +202,9 @@ impl Resource for ChangesResource {
|
|||
fn get(self: Box<Self>) -> ResponseFuture {
|
||||
use chrono::{TimeZone, Local};
|
||||
|
||||
struct Row {
|
||||
sequence_number_plus_one: i32,
|
||||
struct Row<'a> {
|
||||
resource: &'a ChangesResource,
|
||||
sequence_number: i32,
|
||||
|
||||
article_id: i32,
|
||||
revision: i32,
|
||||
|
@ -216,6 +217,15 @@ impl Resource for ChangesResource {
|
|||
_latest: bool,
|
||||
}
|
||||
|
||||
impl<'a> Row<'a> {
|
||||
fn author_link(&self) -> String {
|
||||
self.resource.query_args()
|
||||
.pagination(Pagination::After(self.sequence_number))
|
||||
.author(self.author.clone())
|
||||
.into_link()
|
||||
}
|
||||
}
|
||||
|
||||
struct NavLinks {
|
||||
more: String,
|
||||
end: String,
|
||||
|
@ -226,7 +236,7 @@ impl Resource for ChangesResource {
|
|||
struct Template<'a> {
|
||||
newer: Option<NavLinks>,
|
||||
older: Option<NavLinks>,
|
||||
changes: &'a [Row],
|
||||
changes: &'a [Row<'a>],
|
||||
}
|
||||
|
||||
let (before, article_id, author, limit) =
|
||||
|
@ -281,7 +291,8 @@ impl Resource for ChangesResource {
|
|||
|
||||
let changes = &data.into_iter().map(|x| {
|
||||
Row {
|
||||
sequence_number_plus_one: x.sequence_number + 1,
|
||||
resource: &self,
|
||||
sequence_number: x.sequence_number,
|
||||
article_id: x.article_id,
|
||||
revision: x.revision,
|
||||
created: Local.from_utc_datetime(&x.created).to_rfc2822(),
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<tr>
|
||||
<td><a href="_revisions/{{.article_id}}/{{.revision}}">{{.title}}</a></td>
|
||||
<td>{{.created}}</td>
|
||||
<td>{{#.author}}<a href="_changes?before={{..sequence_number_plus_one}}&author={{.}}">{{.}}</a>{{/.author}}{{^.author}}<i>Anonymous</i>{{/.author}}</td>
|
||||
<td>{{#.author}}<a href="{{..author_link()}}">{{.}}</a>{{/.author}}{{^.author}}<i>Anonymous</i>{{/.author}}</td>
|
||||
</tr>
|
||||
{{/changes}}
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue