From 7d9385edf90ded82cb61c4173b8e65229b091fbb Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Tue, 4 Oct 2022 10:24:32 -0700 Subject: [PATCH] Display more information homepage (#610) --- src/subcommand/server.rs | 7 ++++++- src/subcommand/server/templates/home.rs | 19 ++++++++++++++----- templates/home.html | 9 ++++++++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 98e19bd1d4..3fcb6d2705 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -1026,7 +1026,12 @@ mod tests { ".*Ordinals.*

Ordinals

.* -

Recent Blocks

+

Latest Blocks

+
+
cycle
0
+
epoch
0
+
period
0
+
  1. [[:xdigit:]]{64}
  2. 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
  3. diff --git a/src/subcommand/server/templates/home.rs b/src/subcommand/server/templates/home.rs index e6300ea24b..c75644375a 100644 --- a/src/subcommand/server/templates/home.rs +++ b/src/subcommand/server/templates/home.rs @@ -4,11 +4,15 @@ use super::*; pub(crate) struct HomeHtml { last: u64, blocks: Vec<(Rarity, BlockHash)>, + starting_ordinal: Option, } impl HomeHtml { pub(crate) fn new(blocks: Vec<(u64, BlockHash)>) -> Self { Self { + starting_ordinal: blocks + .get(0) + .map(|(height, _)| Height(*height).starting_ordinal()), last: blocks .get(0) .map(|(height, _)| height) @@ -37,13 +41,13 @@ mod tests { assert_regex_match!( &HomeHtml::new(vec![ ( - 1, + 1260001, "1111111111111111111111111111111111111111111111111111111111111111" .parse() .unwrap() ), ( - 0, + 1260000, "0000000000000000000000000000000000000000000000000000000000000000" .parse() .unwrap() @@ -54,10 +58,15 @@ mod tests {

    Search

    .*
    -

    Recent Blocks

    -
      +

      Latest Blocks

      +
      +
      cycle
      1
      +
      epoch
      6
      +
      period
      625
      +
      +
      1. 1{64}
      2. -
      3. 0{64}
      4. +
      5. 0{64}
      ", ); diff --git a/templates/home.html b/templates/home.html index 35aef87283..acb0247085 100644 --- a/templates/home.html +++ b/templates/home.html @@ -13,7 +13,14 @@

      Search

      -

      Recent Blocks

      +

      Latest Blocks

      +%% if let Some(starting_ordinal) = self.starting_ordinal { +
      +
      cycle
      {{starting_ordinal.cycle()}}
      +
      epoch
      {{starting_ordinal.epoch()}}
      +
      period
      {{starting_ordinal.period()}}
      +
      +%% }
        %% for (rarity, hash) in &self.blocks {
      1. {{hash}}