Add text to _changes explaining the query. Add links to variants of the query
This commit is contained in:
parent
3fb3139d28
commit
5fc11abcfd
2 changed files with 59 additions and 1 deletions
|
@ -234,11 +234,57 @@ impl Resource for ChangesResource {
|
||||||
#[derive(BartDisplay)]
|
#[derive(BartDisplay)]
|
||||||
#[template="templates/changes.html"]
|
#[template="templates/changes.html"]
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
|
resource: &'a ChangesResource,
|
||||||
|
|
||||||
newer: Option<NavLinks>,
|
newer: Option<NavLinks>,
|
||||||
older: Option<NavLinks>,
|
older: Option<NavLinks>,
|
||||||
changes: &'a [Row<'a>],
|
changes: &'a [Row<'a>],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Template<'a> {
|
||||||
|
fn subject_clause(&self) -> String {
|
||||||
|
match self.resource.article_id {
|
||||||
|
Some(x) => format!(" <a href=\"_by_id/{}\">this article</a>", x),
|
||||||
|
None => format!(" the wiki"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn author_clause(&self) -> String {
|
||||||
|
#[derive(BartDisplay)]
|
||||||
|
#[template_string=" by <a href=\"{{link}}\">{{author}}</a>"]
|
||||||
|
struct AuthorClause<'a> {
|
||||||
|
link: &'a str,
|
||||||
|
author: &'a str,
|
||||||
|
}
|
||||||
|
|
||||||
|
match self.resource.author {
|
||||||
|
Some(ref x) => AuthorClause {
|
||||||
|
link: &self.resource.query_args()
|
||||||
|
.author(Some(x.clone()))
|
||||||
|
.into_link(),
|
||||||
|
author: &x
|
||||||
|
}.to_string(),
|
||||||
|
None => "".to_owned(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn all_articles_link(&self) -> Option<String> {
|
||||||
|
self.resource.article_id.map(|_| {
|
||||||
|
self.resource.query_args()
|
||||||
|
.article_id(None)
|
||||||
|
.into_link()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn all_authors_link(&self) -> Option<String> {
|
||||||
|
self.resource.author.as_ref().map(|_| {
|
||||||
|
self.resource.query_args()
|
||||||
|
.author(None)
|
||||||
|
.into_link()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let (before, article_id, author, limit) =
|
let (before, article_id, author, limit) =
|
||||||
(self.before.clone(), self.article_id.clone(), self.author.clone(), self.limit);
|
(self.before.clone(), self.article_id.clone(), self.author.clone(), self.limit);
|
||||||
let data = self.state.query_article_revision_stubs(move |query| {
|
let data = self.state.query_article_revision_stubs(move |query| {
|
||||||
|
@ -308,6 +354,7 @@ impl Resource for ChangesResource {
|
||||||
base: None, // Hmm, should perhaps accept `base` as argument
|
base: None, // Hmm, should perhaps accept `base` as argument
|
||||||
title: "Changes",
|
title: "Changes",
|
||||||
body: &Template {
|
body: &Template {
|
||||||
|
resource: &self,
|
||||||
newer,
|
newer,
|
||||||
older,
|
older,
|
||||||
changes
|
changes
|
||||||
|
|
|
@ -4,6 +4,16 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
|
<p>
|
||||||
|
These are the {{^newer}}most recent{{/newer}} changes that have been
|
||||||
|
made to{{{subject_clause()}}}{{{author_clause()}}}.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<nav><ul class="dense">
|
||||||
|
{{#all_articles_link()}}<li><a href="{{.}}">All articles</a></li>{{/all_articles_link()}}
|
||||||
|
{{#all_authors_link()}}<li><a href="{{.}}">All authors</a></li>{{/all_authors_link()}}
|
||||||
|
</ul></nav>
|
||||||
|
|
||||||
{{#newer}}<nav><ul class="dense"
|
{{#newer}}<nav><ul class="dense"
|
||||||
><li><a rel="prev" href="{{.more}}">More recent changes</a></li
|
><li><a rel="prev" href="{{.more}}">More recent changes</a></li
|
||||||
><li><a rel="first" href="{{.end}}">Most recent changes</a></li
|
><li><a rel="first" href="{{.end}}">Most recent changes</a></li
|
||||||
|
@ -25,12 +35,13 @@
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
</table>
|
</table>
|
||||||
{{^changes?}}
|
{{^changes?}}
|
||||||
<p>No hits</p>
|
<p>There are no changes to show.</p>
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
{{#older}}<nav><ul class="dense"
|
{{#older}}<nav><ul class="dense"
|
||||||
><li><a rel="next" href="{{.more}}">Older changes</a></li
|
><li><a rel="next" href="{{.more}}">Older changes</a></li
|
||||||
><li><a rel="last" href="{{.end}}">First changes</a></li
|
><li><a rel="last" href="{{.end}}">First changes</a></li
|
||||||
></ul></nav>{{/older}}
|
></ul></nav>{{/older}}
|
||||||
|
{{#changes?}}{{^older}}<p>There are no older changes.</p>{{/older}}{{/changes}}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue