Avoid generating invalid diff links in changes feed
This commit is contained in:
parent
5acca0ddb7
commit
f9905e6548
2 changed files with 14 additions and 9 deletions
|
@ -219,7 +219,7 @@ impl Resource for ChangesResource {
|
|||
|
||||
_latest: bool,
|
||||
|
||||
diff_link: String,
|
||||
diff_link: Option<String>,
|
||||
}
|
||||
|
||||
impl<'a> Row<'a> {
|
||||
|
@ -337,13 +337,18 @@ impl Resource for ChangesResource {
|
|||
_slug: x.slug,
|
||||
title: x.title,
|
||||
_latest: x.latest,
|
||||
diff_link: format!("_diff/{}?{}",
|
||||
x.article_id,
|
||||
diff_resource::QueryParameters::new(
|
||||
x.revision as u32 - 1,
|
||||
x.revision as u32,
|
||||
)
|
||||
),
|
||||
diff_link:
|
||||
if x.revision > 1 {
|
||||
Some(format!("_diff/{}?{}",
|
||||
x.article_id,
|
||||
diff_resource::QueryParameters::new(
|
||||
x.revision as u32 - 1,
|
||||
x.revision as u32,
|
||||
)
|
||||
))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<td><a href="_revisions/{{.article_id}}/{{.revision}}">{{.title}}</a></td>
|
||||
<td>{{.created}}</td>
|
||||
{{#show_authors?}}<td>{{#..author}}<a href="{{...author_link()}}">{{.}}</a>{{/..author}}{{^..author}}<i>Anonymous</i>{{/..author}}</td>{{/show_authors}}
|
||||
<td><a href="{{.diff_link}}">change</a></td>
|
||||
<td>{{#.diff_link}}<a href="{{.}}">change</a>{{/.diff_link}}{{^.diff_link}}new{{/.diff_link}}</td>
|
||||
</tr>
|
||||
{{/changes}}
|
||||
</table>
|
||||
|
|
Loading…
Reference in a new issue