Skip to content

Commit

Permalink
Add next and prev links to /ordinal (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
terror authored Aug 17, 2022
1 parent 9e35d31 commit f45f439
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/subcommand/server/templates/ordinal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,66 @@ mod tests {
<dt>rarity</dt><dd>mythic</dd>
<dt>block time</dt><dd>1970-01-01 00:00:00</dd>
</dl>
<a>prev</a>
<a href=/ordinal/1>next</a>
"
.unindent()
);
}

#[test]
fn ordinal_previous() {
assert_eq!(
OrdinalHtml {
ordinal: Ordinal::LAST,
blocktime: Blocktime::Confirmed(0),
}
.to_string(),
"
<h1>Ordinal 2099999997689999</h1>
<dl>
<dt>decimal</dt><dd>6929999.0</dd>
<dt>degree</dt><dd>5°209999′1007″0‴</dd>
<dt>name</dt><dd>a</dd>
<dt>height</dt><dd>6929999</dd>
<dt>cycle</dt><dd>5</dd>
<dt>epoch</dt><dd>32</dd>
<dt>period</dt><dd>3437</dd>
<dt>offset</dt><dd>0</dd>
<dt>rarity</dt><dd>uncommon</dd>
<dt>block time</dt><dd>1970-01-01 00:00:00</dd>
</dl>
<a href=/ordinal/2099999997689998>prev</a>
<a>next</a>
"
.unindent()
);
}

#[test]
fn ordinal_next_and_previous() {
assert_eq!(
OrdinalHtml {
ordinal: Ordinal(1),
blocktime: Blocktime::Confirmed(0),
}
.to_string(),
"
<h1>Ordinal 1</h1>
<dl>
<dt>decimal</dt><dd>0.1</dd>
<dt>degree</dt><dd>0°0′0″1‴</dd>
<dt>name</dt><dd>nvtdijuwxlo</dd>
<dt>height</dt><dd>0</dd>
<dt>cycle</dt><dd>0</dd>
<dt>epoch</dt><dd>0</dd>
<dt>period</dt><dd>0</dd>
<dt>offset</dt><dd>1</dd>
<dt>rarity</dt><dd>common</dd>
<dt>block time</dt><dd>1970-01-01 00:00:00</dd>
</dl>
<a href=/ordinal/0>prev</a>
<a href=/ordinal/2>next</a>
"
.unindent()
);
Expand Down
10 changes: 10 additions & 0 deletions templates/ordinal.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ <h1>Ordinal {{ self.ordinal.n() }}</h1>
<dt>rarity</dt><dd>{{ self.ordinal.rarity() }}</dd>
<dt>block time</dt><dd>{{ self.blocktime }}</dd>
</dl>
%% if self.ordinal.n() > 0 {
<a href=/ordinal/{{self.ordinal.n() - 1}}>prev</a>
%% } else {
<a>prev</a>
%% }
%% if self.ordinal < Ordinal::LAST {
<a href=/ordinal/{{self.ordinal.n() + 1}}>next</a>
%% } else {
<a>next</a>
%% }

0 comments on commit f45f439

Please sign in to comment.