Skip to content

Commit

Permalink
Enable pointer events on inscription page iframes (#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 23, 2023
1 parent 8fa253c commit 806c0c6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2030,7 +2030,7 @@ mod tests {
server.assert_response_regex(
format!("/inscription/{}", InscriptionId::from(txid)),
StatusCode::OK,
r".*<dt>sat</dt>\s*<dd><a href=/sat/5000000000>5000000000</a></dd>\s*<dt>content</dt>.*",
r".*<dt>sat</dt>\s*<dd><a href=/sat/5000000000>5000000000</a></dd>\s*<dt>preview</dt>.*",
);
}

Expand All @@ -2050,7 +2050,7 @@ mod tests {
server.assert_response_regex(
format!("/inscription/{}", InscriptionId::from(txid)),
StatusCode::OK,
r".*<dt>output value</dt>\s*<dd>5000000000</dd>\s*<dt>content</dt>.*",
r".*<dt>output value</dt>\s*<dd>5000000000</dd>\s*<dt>preview</dt>.*",
);
}

Expand Down
8 changes: 3 additions & 5 deletions src/templates/iframe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ impl Display for Iframe {
} else {
write!(
f,
"<a href=/preview/{}><iframe sandbox=allow-scripts scrolling=no src=/preview/{}></iframe></a>",
self.inscription_id,
"<iframe sandbox=allow-scripts scrolling=no src=/preview/{}></iframe>",
self.inscription_id,
)
}
Expand All @@ -57,9 +56,8 @@ mod tests {
#[test]
fn main() {
assert_regex_match!(
Iframe::main(inscription_id(1))
.0.to_string(),
"<a href=/preview/1{64}i1><iframe sandbox=allow-scripts scrolling=no src=/preview/1{64}i1></iframe></a>",
Iframe::main(inscription_id(1)).0.to_string(),
"<iframe sandbox=allow-scripts scrolling=no src=/preview/1{64}i1></iframe>",
);
}
}
8 changes: 5 additions & 3 deletions src/templates/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ mod tests {
<h1>Inscription 1</h1>
<div class=inscription>
<div>❮</div>
<a href=/preview/1{64}i1><iframe .* src=/preview/1{64}i1></iframe></a>
<iframe .* src=/preview/1{64}i1></iframe>
<div>❯</div>
</div>
<dl>
Expand All @@ -59,6 +59,8 @@ mod tests {
<dd class=monospace>bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4</dd>
<dt>output value</dt>
<dd>1</dd>
<dt>preview</dt>
<dd><a href=/preview/1{64}i1>link</a></dd>
<dt>content</dt>
<dd><a href=/content/1{64}i1>link</a></dd>
<dt>content length</dt>
Expand Down Expand Up @@ -106,7 +108,7 @@ mod tests {
.*
<dt>sat</dt>
<dd><a href=/sat/1>1</a></dd>
<dt>content</dt>
<dt>preview</dt>
.*
</dl>
"
Expand Down Expand Up @@ -134,7 +136,7 @@ mod tests {
<h1>Inscription 1</h1>
<div class=inscription>
<a class=previous href=/inscription/1{64}i1>❮</a>
<a href=/preview/2{64}i2><iframe .* src=/preview/2{64}i2></iframe></a>
<iframe .* src=/preview/2{64}i2></iframe>
<a class=next href=/inscription/3{64}i3>❯</a>
</div>
.*
Expand Down
2 changes: 1 addition & 1 deletion static/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ h1 {
iframe {
aspect-ratio: 1 / 1;
border: none;
pointer-events: none;
}

a {
Expand Down Expand Up @@ -185,6 +184,7 @@ a.mythic {

.thumbnails iframe {
height: 100%;
pointer-events: none;
width: 100%;
}

Expand Down
2 changes: 2 additions & 0 deletions templates/inscription.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ <h1>Inscription {{ self.number }}</h1>
<dd><a href=/sat/{{sat}}>{{sat}}</a></dd>
%% }
%% if let Some(content_length) = self.inscription.content_length() {
<dt>preview</dt>
<dd><a href=/preview/{{self.inscription_id}}>link</a></dd>
<dt>content</dt>
<dd><a href=/content/{{self.inscription_id}}>link</a></dd>
<dt>content length</dt>
Expand Down
6 changes: 4 additions & 2 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,16 @@ fn inscription_page() {
format!(
".*<meta property=og:image content='/content/{inscription}'>.*
<h1>Inscription 0</h1>
.*<a href=/preview/{inscription}><iframe .* src=/preview/{inscription}></iframe></a>.*
.*<iframe .* src=/preview/{inscription}></iframe>.*
<dl>
<dt>id</dt>
<dd class=monospace>{inscription}</dd>
<dt>address</dt>
<dd class=monospace>bc1.*</dd>
<dt>output value</dt>
<dd>10000</dd>
<dt>preview</dt>
<dd><a href=/preview/{inscription}>link</a></dd>
<dt>content</dt>
<dd><a href=/content/{inscription}>link</a></dd>
<dt>content length</dt>
Expand Down Expand Up @@ -275,7 +277,7 @@ fn inscriptions_page_has_next_and_previous() {
".*<h1>Inscription 1</h1>.*
<div class=inscription>
<a class=previous href=/inscription/{a}>❮</a>
<a href=/preview/{b}>.*</a>
<iframe .* src=/preview/{b}></iframe>
<a class=next href=/inscription/{c}>❯</a>
</div>.*",
),
Expand Down

0 comments on commit 806c0c6

Please sign in to comment.