From edfbfa4de63cb3fdf77c70d4aa415b1cb2a6bdc4 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 22 Dec 2022 13:04:09 -0800 Subject: [PATCH 1/4] Add white background to inscription content --- src/subcommand/server/templates/content.rs | 12 ++++++++++-- static/index.css | 22 ++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/subcommand/server/templates/content.rs b/src/subcommand/server/templates/content.rs index 760d4e16f2..bd9be82073 100644 --- a/src/subcommand/server/templates/content.rs +++ b/src/subcommand/server/templates/content.rs @@ -13,9 +13,17 @@ impl<'a> Display for ContentHtml<'a> { text.escape(f, false)?; write!(f, "") } - Some(Content::Image) => write!(f, "", self.inscription_id), + Some(Content::Image) => write!( + f, + "", + self.inscription_id + ), Some(Content::IFrame) => { - write!(f, "", self.inscription_id) + write!( + f, + "", + self.inscription_id + ) } None => write!(f, "

UNKNOWN

"), } diff --git a/static/index.css b/static/index.css index ec639f7463..8c2ed58575 100644 --- a/static/index.css +++ b/static/index.css @@ -171,16 +171,16 @@ a.mythic { border-radius: 2%; } -.inscriptions a img { +.inscriptions img.inscription { overflow: auto; max-width: 100%; min-width: 100%; - image-rendering: pixelated; } -.inscriptions a iframe { - width: 100%; - height: 100%; +.inscriptions iframe.inscription { + width: 102%; + height: 102%; + overflow: hidden; } .content { @@ -190,7 +190,6 @@ a.mythic { .content img { min-width: 50%; - image-rendering: pixelated; } iframe { @@ -208,3 +207,14 @@ a.content { color: inherit; text-decoration: none; } + +img.inscription { + image-rendering: pixelated; + background-color: white; +} + +iframe.inscription { + border: none; + pointer-events: none; + background-color: white; +} From 82c79ea579a7e1b63163587aa90e2824be1d5bdc Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 22 Dec 2022 13:10:23 -0800 Subject: [PATCH 2/4] tweak --- static/index.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/index.css b/static/index.css index 8c2ed58575..d129071067 100644 --- a/static/index.css +++ b/static/index.css @@ -178,8 +178,8 @@ a.mythic { } .inscriptions iframe.inscription { - width: 102%; - height: 102%; + width: 101%; + height: 101%; overflow: hidden; } From abe2184d38ac241f5a58c30e2d475187ac09c4d2 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 22 Dec 2022 13:18:18 -0800 Subject: [PATCH 3/4] Refactor tests --- src/subcommand/server/templates/content.rs | 28 +++++++- .../server/templates/inscription.rs | 68 +------------------ 2 files changed, 27 insertions(+), 69 deletions(-) diff --git a/src/subcommand/server/templates/content.rs b/src/subcommand/server/templates/content.rs index bd9be82073..82e207152f 100644 --- a/src/subcommand/server/templates/content.rs +++ b/src/subcommand/server/templates/content.rs @@ -34,6 +34,18 @@ impl<'a> Display for ContentHtml<'a> { mod tests { use super::*; + #[test] + fn unknown() { + assert_eq!( + ContentHtml { + content: None, + inscription_id: txid(1), + } + .to_string(), + "

UNKNOWN

" + ); + } + #[test] fn text() { assert_eq!( @@ -46,6 +58,18 @@ mod tests { ); } + #[test] + fn text_is_escaped() { + assert_eq!( + ContentHtml { + content: Some(Content::Text("")), + inscription_id: txid(1), + } + .to_string(), + "
<script>alert('hello!')</script>
", + ); + } + #[test] fn image() { assert_eq!( @@ -54,7 +78,7 @@ mod tests { inscription_id: txid(1), } .to_string(), - "" + "" ); } @@ -66,7 +90,7 @@ mod tests { inscription_id: txid(1), } .to_string(), - "" + "" ); } } diff --git a/src/subcommand/server/templates/inscription.rs b/src/subcommand/server/templates/inscription.rs index 6b612eaeec..853789c85e 100644 --- a/src/subcommand/server/templates/inscription.rs +++ b/src/subcommand/server/templates/inscription.rs @@ -23,7 +23,7 @@ mod tests { use super::*; #[test] - fn txt_inscription() { + fn html() { pretty_assert_eq!( InscriptionHtml { genesis_height: 0, @@ -56,70 +56,4 @@ mod tests { .unindent() ); } - - #[test] - fn png_inscription() { - pretty_assert_eq!( - InscriptionHtml { - genesis_height: 0, - inscription_id: InscriptionId::from_str( - "ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc" - ) - .unwrap(), - inscription: inscription("image/png", [1; 100]), - satpoint: satpoint(1, 0), - } - .to_string(), - " -

Inscription ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc

- - - -
-
content size
-
100 bytes
-
content type
-
image/png
-
genesis height
-
0
-
genesis transaction
-
ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc
-
location
-
1111111111111111111111111111111111111111111111111111111111111111:1:0
-
- " - .unindent() - ); - } - - #[test] - fn empty_inscription() { - pretty_assert_eq!( - InscriptionHtml { - genesis_height: 0, - inscription_id: InscriptionId::from_str( - "ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc" - ) - .unwrap(), - inscription: Inscription::new(None, None), - satpoint: satpoint(1, 0), - } - .to_string(), - " -

Inscription ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc

- -

UNKNOWN

-
-
-
genesis height
-
0
-
genesis transaction
-
ec90757eb3b164aa43fc548faa2fa0c52025494f2c15d5ddf11260b4034ac6dc
-
location
-
1111111111111111111111111111111111111111111111111111111111111111:1:0
-
- " - .unindent() - ); - } } From b464156c578cda2750b4d78141bc1c447d8b1190 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Thu, 22 Dec 2022 13:19:01 -0800 Subject: [PATCH 4/4] tweak --- tests/wallet.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/wallet.rs b/tests/wallet.rs index 4e2faa9a11..5bf28e3a1f 100644 --- a/tests/wallet.rs +++ b/tests/wallet.rs @@ -308,7 +308,7 @@ fn inscribe_png() { ord_server.assert_response_regex( "/sat/5000000000", &format!( - ".*
inscription
\n
inscription\n
inscription\n
inscription\n