From c753268bdea5bee18288863981afd0483f565206 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Mon, 5 Sep 2022 14:19:06 +0200 Subject: [PATCH 1/5] added blockheight; SVG still needs scaling because text is squished --- src/subcommand/server/templates/clock.rs | 2 ++ templates/clock.svg | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/src/subcommand/server/templates/clock.rs b/src/subcommand/server/templates/clock.rs index 8912c1b256..71b3f13a9f 100644 --- a/src/subcommand/server/templates/clock.rs +++ b/src/subcommand/server/templates/clock.rs @@ -2,6 +2,7 @@ use super::*; #[derive(Display)] pub(crate) struct ClockSvg { + height: u64, hour: f64, minute: f64, second: f64, @@ -12,6 +13,7 @@ impl ClockSvg { let min = height.min(Epoch::FIRST_POST_SUBSIDY.starting_height()); Self { + height: height.n(), hour: (min.n() % Epoch::FIRST_POST_SUBSIDY.starting_height().n()) as f64 / Epoch::FIRST_POST_SUBSIDY.starting_height().n() as f64 * 360.0, diff --git a/templates/clock.svg b/templates/clock.svg index 121c7c12b8..52344836ca 100644 --- a/templates/clock.svg +++ b/templates/clock.svg @@ -1,6 +1,7 @@ + {{self.height}} @@ -38,4 +39,12 @@ + From c418472b42356478f2cd45769ccbc70494eac4d1 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 7 Sep 2022 13:11:48 +0200 Subject: [PATCH 2/5] fixed squished lettering; deleted css class definitions --- templates/clock.svg | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/templates/clock.svg b/templates/clock.svg index 52344836ca..76d82e14cd 100644 --- a/templates/clock.svg +++ b/templates/clock.svg @@ -1,7 +1,7 @@ - {{self.height}} + {{self.height}} @@ -39,12 +39,4 @@ - From fa7d43acd4609e975ddb9cd063987ecfe81e8814 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 7 Sep 2022 21:50:55 +0200 Subject: [PATCH 3/5] use default font-family and us absolute values --- templates/clock.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/clock.svg b/templates/clock.svg index 76d82e14cd..9fcfe29029 100644 --- a/templates/clock.svg +++ b/templates/clock.svg @@ -1,7 +1,7 @@ - {{self.height}} + {{self.height}} From f6c159bc7d5a60498ab4fed48babcf4b5cc4acc6 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 7 Sep 2022 22:06:09 +0200 Subject: [PATCH 4/5] added unit test --- src/subcommand/server/templates/clock.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/subcommand/server/templates/clock.rs b/src/subcommand/server/templates/clock.rs index 71b3f13a9f..bbee3959cf 100644 --- a/src/subcommand/server/templates/clock.rs +++ b/src/subcommand/server/templates/clock.rs @@ -83,10 +83,11 @@ mod tests { } #[test] - fn foo_svg() { + fn clock_svg() { assert_regex_match!( ClockSvg::new(Height(6929999)).to_string(), - r##" + r##"6929999.* + .* "##, From 53f20e608895dfad8db0fd451526d1de59aaf0fa Mon Sep 17 00:00:00 2001 From: raphjaph Date: Wed, 7 Sep 2022 22:36:46 +0200 Subject: [PATCH 5/5] use Height instead of u64 --- src/subcommand/server/templates/clock.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/subcommand/server/templates/clock.rs b/src/subcommand/server/templates/clock.rs index bbee3959cf..9114335f76 100644 --- a/src/subcommand/server/templates/clock.rs +++ b/src/subcommand/server/templates/clock.rs @@ -2,7 +2,7 @@ use super::*; #[derive(Display)] pub(crate) struct ClockSvg { - height: u64, + height: Height, hour: f64, minute: f64, second: f64, @@ -13,7 +13,7 @@ impl ClockSvg { let min = height.min(Epoch::FIRST_POST_SUBSIDY.starting_height()); Self { - height: height.n(), + height, hour: (min.n() % Epoch::FIRST_POST_SUBSIDY.starting_height().n()) as f64 / Epoch::FIRST_POST_SUBSIDY.starting_height().n() as f64 * 360.0,