From c6bbe1d47d1e8822b4e0ee5571cad94da4ccc892 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 18:43:47 -0400 Subject: [PATCH 1/4] Add block colors --- src/subcommand/server/templates/home.rs | 11 +++++++---- static/index.css | 25 ++++++++++++++++++++++++- templates/home.html | 4 ++-- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/subcommand/server/templates/home.rs b/src/subcommand/server/templates/home.rs index ba3246c458..89df83136d 100644 --- a/src/subcommand/server/templates/home.rs +++ b/src/subcommand/server/templates/home.rs @@ -3,7 +3,7 @@ use super::*; #[derive(Display)] pub(crate) struct HomeHtml { last: u64, - hashes: Vec, + blocks: Vec<(String, BlockHash)>, } impl HomeHtml { @@ -14,7 +14,10 @@ impl HomeHtml { .map(|(height, _)| height) .cloned() .unwrap_or(0), - hashes: blocks.into_iter().map(|(_, hash)| hash).collect(), + blocks: blocks + .into_iter() + .map(|(height, hash)| (Height(height).starting_ordinal().rarity().to_string(), hash)) + .collect(), } } } @@ -50,8 +53,8 @@ mod tests {

Recent Blocks

    -
  1. 1{64}
  2. -
  3. 0{64}
  4. +
  5. 1{64}
  6. +
  7. 0{64}
", &HomeHtml::new(vec![ diff --git a/static/index.css b/static/index.css index 1629896881..3101b1925f 100644 --- a/static/index.css +++ b/static/index.css @@ -63,5 +63,28 @@ nav { .mythic { background-color: #f2a900; - color: white; +} + +.common-foo { + color: whitesmoke; +} + +.uncommon-foo { + color: forestgreen; +} + +.rare-foo { + color: cornflowerblue; +} + +.epic-foo { + color: darkorchid; +} + +.legendary-foo { + color: gold; +} + +.mythic-foo { + color: #f2a900; } diff --git a/templates/home.html b/templates/home.html index 600d82b601..355eee6b77 100644 --- a/templates/home.html +++ b/templates/home.html @@ -9,7 +9,7 @@

Ordinals

Recent Blocks

    -%% for hash in &self.hashes { -
  1. {{hash}}
  2. +%% for (rarity, hash) in &self.blocks { +
  3. {{hash}}
  4. %% }
From 22c0d952842ee6018dae0e61d1f320c6856a844a Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 19:00:41 -0400 Subject: [PATCH 2/4] Make pass --- src/subcommand/server/templates/home.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subcommand/server/templates/home.rs b/src/subcommand/server/templates/home.rs index 89df83136d..173adafe23 100644 --- a/src/subcommand/server/templates/home.rs +++ b/src/subcommand/server/templates/home.rs @@ -53,8 +53,8 @@ mod tests {

Recent Blocks

    -
  1. 1{64}
  2. -
  3. 0{64}
  4. +
  5. 1{64}
  6. +
  7. 0{64}
", &HomeHtml::new(vec![ From d7c4c3afa6cdf0708c7684c1e1c8755626223554 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 19:29:06 -0400 Subject: [PATCH 3/4] Fix tests --- src/subcommand/server/templates/home.rs | 4 ++-- static/index.css | 24 ------------------------ templates/home.html | 2 +- tests/server.rs | 6 +++--- 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/src/subcommand/server/templates/home.rs b/src/subcommand/server/templates/home.rs index 173adafe23..89df83136d 100644 --- a/src/subcommand/server/templates/home.rs +++ b/src/subcommand/server/templates/home.rs @@ -53,8 +53,8 @@ mod tests {

Recent Blocks

    -
  1. 1{64}
  2. -
  3. 0{64}
  4. +
  5. 1{64}
  6. +
  7. 0{64}
", &HomeHtml::new(vec![ diff --git a/static/index.css b/static/index.css index c576ddcb55..7b3aedd60b 100644 --- a/static/index.css +++ b/static/index.css @@ -65,30 +65,6 @@ span.mythic { background-color: #f2a900; } -.common-foo { - color: whitesmoke; -} - -.uncommon-foo { - color: forestgreen; -} - -.rare-foo { - color: cornflowerblue; -} - -.epic-foo { - color: darkorchid; -} - -.legendary-foo { - color: gold; -} - -.mythic-foo { - color: #f2a900; -} - a.common { color: grey; } diff --git a/templates/home.html b/templates/home.html index 355eee6b77..c980bb69fe 100644 --- a/templates/home.html +++ b/templates/home.html @@ -10,6 +10,6 @@

Ordinals

Recent Blocks

    %% for (rarity, hash) in &self.blocks { -
  1. {{hash}}
  2. +
  3. {{hash}}
  4. %% }
diff --git a/tests/server.rs b/tests/server.rs index c06f5a3953..7965d7f23d 100644 --- a/tests/server.rs +++ b/tests/server.rs @@ -203,8 +203,8 @@ fn home() {

Recent Blocks

    -
  1. [[:xdigit:]]{64}
  2. -
  3. 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
  4. +
  5. [[:xdigit:]]{64}
  6. +
  7. 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206
.*", ); } @@ -218,7 +218,7 @@ fn home_block_limit() { state.request_regex( "/", 200, - ".*
    \n(
  1. [[:xdigit:]]{64}
  2. \n){100}
.*" + ".*
    \n(
  1. [[:xdigit:]]{64}
  2. \n){100}
.*" ); } From 30ab599c921b922ccb805f574971c783e3c999c8 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Aug 2022 19:30:21 -0400 Subject: [PATCH 4/4] Static str --- src/subcommand/server/templates/home.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subcommand/server/templates/home.rs b/src/subcommand/server/templates/home.rs index 89df83136d..be6c3bd469 100644 --- a/src/subcommand/server/templates/home.rs +++ b/src/subcommand/server/templates/home.rs @@ -3,7 +3,7 @@ use super::*; #[derive(Display)] pub(crate) struct HomeHtml { last: u64, - blocks: Vec<(String, BlockHash)>, + blocks: Vec<(&'static str, BlockHash)>, } impl HomeHtml { @@ -16,7 +16,7 @@ impl HomeHtml { .unwrap_or(0), blocks: blocks .into_iter() - .map(|(height, hash)| (Height(height).starting_ordinal().rarity().to_string(), hash)) + .map(|(height, hash)| (Height(height).starting_ordinal().rarity(), hash)) .collect(), } }