Add links to newest and oldest changes
This commit is contained in:
parent
d918d614b4
commit
6c36e3cb49
3 changed files with 42 additions and 12 deletions
|
@ -140,6 +140,10 @@ img {
|
||||||
height: auto;
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Sticky footer */
|
/* Sticky footer */
|
||||||
html, body {
|
html, body {
|
||||||
|
|
|
@ -50,11 +50,16 @@ impl Resource for ChangesResource {
|
||||||
_latest: bool,
|
_latest: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct NavLinks {
|
||||||
|
more: String,
|
||||||
|
end: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(BartDisplay)]
|
#[derive(BartDisplay)]
|
||||||
#[template="templates/changes.html"]
|
#[template="templates/changes.html"]
|
||||||
struct Template<'a> {
|
struct Template<'a> {
|
||||||
link_newer: Option<String>,
|
newer: Option<NavLinks>,
|
||||||
link_older: Option<String>,
|
older: Option<NavLinks>,
|
||||||
changes: &'a [Row],
|
changes: &'a [Row],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,21 +97,36 @@ impl Resource for ChangesResource {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let (link_newer, link_older) = match self.pagination {
|
let (newer, older) = match self.pagination {
|
||||||
Pagination::After(x) => {
|
Pagination::After(x) => {
|
||||||
data.reverse();
|
data.reverse();
|
||||||
(
|
(
|
||||||
extra_element.map(|_| format!("?after={}", data.first().unwrap().sequence_number)),
|
extra_element.map(|_| NavLinks {
|
||||||
Some(format!("?before={}", x + 1))
|
more: format!("?after={}", data.first().unwrap().sequence_number),
|
||||||
|
end: format!("_changes"),
|
||||||
|
}),
|
||||||
|
Some(NavLinks {
|
||||||
|
more: format!("?before={}", x + 1),
|
||||||
|
end: format!("?after=0"),
|
||||||
|
})
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
Pagination::Before(x) => (
|
Pagination::Before(x) => (
|
||||||
Some(format!("?after={}", x - 1)),
|
Some(NavLinks {
|
||||||
extra_element.map(|_| format!("?before={}", data.last().unwrap().sequence_number)),
|
more: format!("?after={}", x - 1),
|
||||||
|
end: format!("_changes"),
|
||||||
|
}),
|
||||||
|
extra_element.map(|_| NavLinks {
|
||||||
|
more: format!("?before={}", data.last().unwrap().sequence_number),
|
||||||
|
end: format!("?after=0"),
|
||||||
|
})
|
||||||
),
|
),
|
||||||
Pagination::None => (
|
Pagination::None => (
|
||||||
None,
|
None,
|
||||||
extra_element.map(|_| format!("?before={}", data.last().unwrap().sequence_number)),
|
extra_element.map(|_| NavLinks {
|
||||||
|
more: format!("?before={}", data.last().unwrap().sequence_number),
|
||||||
|
end: format!("?after=0"),
|
||||||
|
}),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,8 +147,8 @@ 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 {
|
||||||
link_newer,
|
newer,
|
||||||
link_older,
|
older,
|
||||||
changes
|
changes
|
||||||
},
|
},
|
||||||
style_css_checksum: StyleCss::checksum(),
|
style_css_checksum: StyleCss::checksum(),
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
{{#link_newer}}<p><a rel="prev" href="{{.}}">Show more recent changes</a></p>{{/link_newer}}
|
{{#newer}}<nav><ul class="dense"
|
||||||
|
><li><a rel="prev" href="{{.more}}">More recent changes</a></li
|
||||||
|
><li><a rel="first" href="{{.end}}">Most recent changes</a></li
|
||||||
|
></ul></nav>{{/newer}}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Article</th>
|
<th>Article</th>
|
||||||
|
@ -19,7 +22,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
{{/changes}}
|
{{/changes}}
|
||||||
</table>
|
</table>
|
||||||
{{#link_older}}<p><a rel="next" href="{{.}}">Show older changes</a></p>{{/link_older}}
|
{{#older}}<nav><ul class="dense"
|
||||||
|
><li><a rel="next" href="{{.more}}">Older changes</a></li
|
||||||
|
><li><a rel="last" href="{{.end}}">First changes</a></li
|
||||||
|
></ul></nav>{{/older}}
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue