Generate links to diffs from changes feed
This commit is contained in:
parent
9cb3da86e2
commit
c24c5a84d5
4 changed files with 14 additions and 2 deletions
|
@ -12,6 +12,7 @@ use site::Layout;
|
||||||
use state::State;
|
use state::State;
|
||||||
use web::{Resource, ResponseFuture};
|
use web::{Resource, ResponseFuture};
|
||||||
|
|
||||||
|
use super::diff_resource::{self, ArticleRevisionReference};
|
||||||
use super::pagination::Pagination;
|
use super::pagination::Pagination;
|
||||||
use super::TemporaryRedirectResource;
|
use super::TemporaryRedirectResource;
|
||||||
|
|
||||||
|
@ -217,6 +218,8 @@ impl Resource for ChangesResource {
|
||||||
title: String,
|
title: String,
|
||||||
|
|
||||||
_latest: bool,
|
_latest: bool,
|
||||||
|
|
||||||
|
diff_link: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Row<'a> {
|
impl<'a> Row<'a> {
|
||||||
|
@ -334,6 +337,10 @@ impl Resource for ChangesResource {
|
||||||
_slug: x.slug,
|
_slug: x.slug,
|
||||||
title: x.title,
|
title: x.title,
|
||||||
_latest: x.latest,
|
_latest: x.latest,
|
||||||
|
diff_link: diff_resource::QueryParameters::new(
|
||||||
|
ArticleRevisionReference::Some { article_id: x.article_id as u32, revision: x.revision as u32 - 1 },
|
||||||
|
ArticleRevisionReference::Some { article_id: x.article_id as u32, revision: x.revision as u32 },
|
||||||
|
).into_link()
|
||||||
}
|
}
|
||||||
}).collect::<Vec<_>>();
|
}).collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ impl QueryParameters {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_link(self) -> String {
|
pub fn into_link(self) -> String {
|
||||||
serde_urlencoded::to_string(self).expect("Serializing to String cannot fail")
|
format!("_diff?{}", serde_urlencoded::to_string(self).expect("Serializing to String cannot fail"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<th>Article</th>
|
<th>Article</th>
|
||||||
<th>Updated</th>
|
<th>Updated</th>
|
||||||
{{#show_authors?}}<th>Author</th>{{/show_authors}}
|
{{#show_authors?}}<th>Author</th>{{/show_authors}}
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
{{#changes}}
|
{{#changes}}
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
<td><a href="_revisions/{{.article_id}}/{{.revision}}">{{.title}}</a></td>
|
<td><a href="_revisions/{{.article_id}}/{{.revision}}">{{.title}}</a></td>
|
||||||
<td>{{.created}}</td>
|
<td>{{.created}}</td>
|
||||||
{{#show_authors?}}<td>{{#..author}}<a href="{{...author_link()}}">{{.}}</a>{{/..author}}{{^..author}}<i>Anonymous</i>{{/..author}}</td>{{/show_authors}}
|
{{#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>
|
||||||
</tr>
|
</tr>
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<header>
|
<header>
|
||||||
<h1>Diff</h1>
|
<h1>Difference</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<header>
|
||||||
<h1>{{#title}}{{#.removed}}<span class="removed">{{.}}</span>{{/.removed}}{{#.same}}{{.}}{{/.same}}{{#.added}}<span class="added">{{.}}</span>{{/.added}}{{/title}}</h1>
|
<h1>{{#title}}{{#.removed}}<span class="removed">{{.}}</span>{{/.removed}}{{#.same}}{{.}}{{/.same}}{{#.added}}<span class="added">{{.}}</span>{{/.added}}{{/title}}</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue