From b0221b364a2614a5a053237b8176e280bc87f6ba Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Sun, 18 Sep 2022 01:10:00 -0500 Subject: [PATCH] Use boilerplate 0.2.0 (#531) --- Cargo.lock | 55 ++++++++++++++++++- Cargo.toml | 3 +- src/subcommand/server/templates.rs | 8 ++- src/subcommand/server/templates/block.rs | 2 +- src/subcommand/server/templates/clock.rs | 2 +- src/subcommand/server/templates/home.rs | 2 +- src/subcommand/server/templates/ordinal.rs | 2 +- src/subcommand/server/templates/output.rs | 2 +- src/subcommand/server/templates/range.rs | 2 +- .../server/templates/transaction.rs | 2 +- templates/page.html | 2 +- 11 files changed, 68 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8941e515ac..c411a935d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -614,12 +614,13 @@ dependencies = [ [[package]] name = "boilerplate" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71362005b3b60c66851b461ca10c2d3802df01e4f741e25e481e1390be86aab0" +version = "0.2.0" dependencies = [ + "darling", + "mime", "new_mime_guess", "proc-macro2", + "quote", "syn", ] @@ -918,6 +919,41 @@ dependencies = [ "winapi", ] +[[package]] +name = "darling" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4529658bdda7fd6769b8614be250cdcfc3aeb0ee72fe66f9e41e5e5eb73eac02" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "649c91bc01e8b1eac09fb91e8dbc7d517684ca6be8ebc75bb9cafc894f9fdb6f" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc69c5bfcbd2fc09a0f38451d2daf0e372e367986a83906d1b0dbc88134fb5" +dependencies = [ + "darling_core", + "quote", + "syn", +] + [[package]] name = "data-encoding" version = "2.3.2" @@ -1438,6 +1474,12 @@ dependencies = [ "digest 0.9.0", ] +[[package]] +name = "html-escaper" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459a0ca33ee92551e0a3bb1774f2d3bdd1c09fb6341845736662dd25e1fcb52a" + [[package]] name = "http" version = "0.2.8" @@ -1557,6 +1599,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + [[package]] name = "idna" version = "0.1.5" @@ -2093,6 +2141,7 @@ dependencies = [ "executable-path", "futures 0.3.24", "hex", + "html-escaper", "http", "jsonrpc-core", "jsonrpc-core-client", diff --git a/Cargo.toml b/Cargo.toml index 29aa63655e..e2bb85037d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ axum-server = "0.4.0" bdk = { version = "0.22.0", features = ["rpc", "keys-bip39", "sqlite"] } bitcoin = "0.28.1" bitcoincore-rpc = "0.15.0" -boilerplate = { version = "0.0.2", features = ["axum"] } +boilerplate = { version = "0.2.0", features = ["axum"] } chrono = "0.4.19" clap = { version = "3.1.0", features = ["derive"] } ctrlc = "3.2.1" @@ -21,6 +21,7 @@ derive_more = "0.99.17" dirs = "4.0.0" env_logger = "0.9.0" futures = "0.3.21" +html-escaper = "0.2.0" http = "0.2.6" log = "0.4.14" mime_guess = "2.0.4" diff --git a/src/subcommand/server/templates.rs b/src/subcommand/server/templates.rs index 54cb716646..b76fe638e4 100644 --- a/src/subcommand/server/templates.rs +++ b/src/subcommand/server/templates.rs @@ -1,4 +1,8 @@ -use {super::*, boilerplate::Display}; +use { + super::*, + boilerplate::Boilerplate, + html_escaper::{Escape, Trusted}, +}; pub(crate) mod block; pub(crate) mod clock; @@ -8,7 +12,7 @@ pub(crate) mod output; pub(crate) mod range; pub(crate) mod transaction; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct PageHtml { content: Box, } diff --git a/src/subcommand/server/templates/block.rs b/src/subcommand/server/templates/block.rs index cd8f4eccd1..76fa098143 100644 --- a/src/subcommand/server/templates/block.rs +++ b/src/subcommand/server/templates/block.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct BlockHtml { hash: BlockHash, txids: Vec, diff --git a/src/subcommand/server/templates/clock.rs b/src/subcommand/server/templates/clock.rs index 9114335f76..8b7f8b7669 100644 --- a/src/subcommand/server/templates/clock.rs +++ b/src/subcommand/server/templates/clock.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct ClockSvg { height: Height, hour: f64, diff --git a/src/subcommand/server/templates/home.rs b/src/subcommand/server/templates/home.rs index ff901bff7f..0aafb45a8c 100644 --- a/src/subcommand/server/templates/home.rs +++ b/src/subcommand/server/templates/home.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct HomeHtml { last: u64, blocks: Vec<(Rarity, BlockHash)>, diff --git a/src/subcommand/server/templates/ordinal.rs b/src/subcommand/server/templates/ordinal.rs index e8a2cd637d..2d570dd849 100644 --- a/src/subcommand/server/templates/ordinal.rs +++ b/src/subcommand/server/templates/ordinal.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct OrdinalHtml { pub(crate) ordinal: Ordinal, pub(crate) blocktime: Blocktime, diff --git a/src/subcommand/server/templates/output.rs b/src/subcommand/server/templates/output.rs index b6aea3d68b..474e7ea632 100644 --- a/src/subcommand/server/templates/output.rs +++ b/src/subcommand/server/templates/output.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct OutputHtml { pub(crate) outpoint: OutPoint, pub(crate) list: List, diff --git a/src/subcommand/server/templates/range.rs b/src/subcommand/server/templates/range.rs index e813f3ba79..61b8eed741 100644 --- a/src/subcommand/server/templates/range.rs +++ b/src/subcommand/server/templates/range.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct RangeHtml { pub(crate) start: Ordinal, pub(crate) end: Ordinal, diff --git a/src/subcommand/server/templates/transaction.rs b/src/subcommand/server/templates/transaction.rs index 8e03c816a0..b48824998b 100644 --- a/src/subcommand/server/templates/transaction.rs +++ b/src/subcommand/server/templates/transaction.rs @@ -1,6 +1,6 @@ use super::*; -#[derive(Display)] +#[derive(Boilerplate)] pub(crate) struct TransactionHtml { txid: Txid, outputs: Vec, diff --git a/templates/page.html b/templates/page.html index 503a87e5ed..d82054fe6d 100644 --- a/templates/page.html +++ b/templates/page.html @@ -9,6 +9,6 @@ -$$ self.content +$$ Trusted(&self.content)