Skip to content

Commit

Permalink
Identify collapsible nodes with class=collapse (ordinals#4055)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Nov 8, 2024
1 parent c525fcd commit 54adcf6
Show file tree
Hide file tree
Showing 27 changed files with 128 additions and 161 deletions.
56 changes: 28 additions & 28 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3242,9 +3242,9 @@ mod tests {
<dt>turbo</dt>
<dd>true</dd>
<dt>etching</dt>
<dd><a class=monospace href=/tx/{txid}>{txid}</a></dd>
<dd><a class=collapse href=/tx/{txid}>{txid}</a></dd>
<dt>parent</dt>
<dd><a class=monospace href=/inscription/{txid}i0>{txid}i0</a></dd>
<dd><a class=collapse href=/inscription/{txid}i0>{txid}i0</a></dd>
</dl>
.*"
),
Expand Down Expand Up @@ -3689,7 +3689,7 @@ mod tests {
<dd>.*</dd>
<dt>git commit</dt>
<dd>
<a class=monospace href=https://github.com/ordinals/ord/commit/[[:xdigit:]]{40}>
<a class=collapse href=https://github.com/ordinals/ord/commit/[[:xdigit:]]{40}>
[[:xdigit:]]{40}
</a>
</dd>
Expand Down Expand Up @@ -3842,7 +3842,7 @@ mod tests {
<dl>
<dt>value</dt><dd>5000000000</dd>
<dt>script pubkey</dt><dd class=monospace>OP_PUSHBYTES_65 [[:xdigit:]]{{130}} OP_CHECKSIG</dd>
<dt>transaction</dt><dd><a class=monospace href=/tx/{txid}>{txid}</a></dd>
<dt>transaction</dt><dd><a class=collapse href=/tx/{txid}>{txid}</a></dd>
<dt>spent</dt><dd>false</dd>
</dl>
<h2>1 Sat Range</h2>
Expand All @@ -3864,7 +3864,7 @@ mod tests {
<dl>
<dt>value</dt><dd>5000000000</dd>
<dt>script pubkey</dt><dd class=monospace>OP_PUSHBYTES_65 [[:xdigit:]]{{130}} OP_CHECKSIG</dd>
<dt>transaction</dt><dd><a class=monospace href=/tx/{txid}>{txid}</a></dd>
<dt>transaction</dt><dd><a class=collapse href=/tx/{txid}>{txid}</a></dd>
<dt>spent</dt><dd>false</dd>
</dl>.*"
),
Expand All @@ -3887,7 +3887,7 @@ mod tests {
<dl>
<dt>value</dt><dd>5000000000</dd>
<dt>script pubkey</dt><dd class=monospace></dd>
<dt>transaction</dt><dd><a class=monospace href=/tx/{txid}>{txid}</a></dd>
<dt>transaction</dt><dd><a class=collapse href=/tx/{txid}>{txid}</a></dd>
<dt>spent</dt><dd>false</dd>
</dl>
<h2>1 Sat Range</h2>
Expand Down Expand Up @@ -3935,8 +3935,8 @@ mod tests {
format!(
".*<dl>
<dt>id</dt>
<dd class=monospace>{inscription_id}</dd>.*<dt>output</dt>
<dd><a class=monospace href=/output/0000000000000000000000000000000000000000000000000000000000000000:0>0000000000000000000000000000000000000000000000000000000000000000:0</a></dd>.*"
<dd class=collapse>{inscription_id}</dd>.*<dt>output</dt>
<dd><a class=collapse href=/output/0000000000000000000000000000000000000000000000000000000000000000:0>0000000000000000000000000000000000000000000000000000000000000000:0</a></dd>.*"
),
);

Expand Down Expand Up @@ -4057,7 +4057,7 @@ mod tests {
test_server.assert_response_regex(
"/blocks",
StatusCode::OK,
".*<ol start=96 reversed class=block-list>\n( <li><a class=monospace href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>\n){95}</ol>.*"
".*<ol start=96 reversed class=block-list>\n( <li><a class=collapse href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>\n){95}</ol>.*"
);
}

Expand Down Expand Up @@ -4155,12 +4155,12 @@ mod tests {
</dl>
<h2>1 Input</h2>
<ul>
<li><a class=monospace href=/output/0000000000000000000000000000000000000000000000000000000000000000:4294967295>0000000000000000000000000000000000000000000000000000000000000000:4294967295</a></li>
<li><a class=collapse href=/output/0000000000000000000000000000000000000000000000000000000000000000:4294967295>0000000000000000000000000000000000000000000000000000000000000000:4294967295</a></li>
</ul>
<h2>1 Output</h2>
<ul class=monospace>
<li>
<a href=/output/{txid}:0 class=monospace>
<a href=/output/{txid}:0 class=collapse>
{txid}:0
</a>
<dl>
Expand Down Expand Up @@ -5492,7 +5492,7 @@ next
format!(
".*<title>Inscription 1</title>.*
.*<dt>id</dt>
.*<dd class=monospace>{child0}</dd>.*"
.*<dd class=collapse>{child0}</dd>.*"
),
);

Expand All @@ -5507,7 +5507,7 @@ next
format!(
".*<title>Inscription -1</title>.*
.*<dt>id</dt>
.*<dd class=monospace>{child1}</dd>.*"
.*<dd class=collapse>{child1}</dd>.*"
),
);
}
Expand Down Expand Up @@ -5668,7 +5668,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{inscription_id}</dd>.*"
<dd class=collapse>{inscription_id}</dd>.*"
),
);
server.assert_response_regex(
Expand All @@ -5678,7 +5678,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{inscription_id}</dd>.*"
<dd class=collapse>{inscription_id}</dd>.*"
),
);

Expand All @@ -5689,7 +5689,7 @@ next
".*<h1>Inscription -1</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{cursed_inscription_id}</dd>.*"
<dd class=collapse>{cursed_inscription_id}</dd>.*"
),
)
}
Expand Down Expand Up @@ -5720,7 +5720,7 @@ next
".*<h1>Inscription -1</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>
<span title=cursed>👹</span>
Expand Down Expand Up @@ -5759,7 +5759,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
.*
<dt>value</dt>
.*
Expand Down Expand Up @@ -5795,7 +5795,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>.*<span title=coin>🪙</span>.*</dd>
.*
Expand Down Expand Up @@ -5831,7 +5831,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>.*<span title=uncommon>🌱</span>.*</dd>
.*
Expand Down Expand Up @@ -5867,7 +5867,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>.*<span title=nineball>9️⃣</span>.*</dd>
.*
Expand Down Expand Up @@ -5907,7 +5907,7 @@ next
".*<h1>Inscription -1</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>
<span title=reinscription>♻️</span>
Expand Down Expand Up @@ -5971,7 +5971,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
.*
<dt>value</dt>
.*
Expand Down Expand Up @@ -6032,7 +6032,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
.*
<dt>value</dt>
.*
Expand Down Expand Up @@ -6082,7 +6082,7 @@ next
".*<h1>Inscription -1</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>
<span title=cursed>👹</span>
Expand Down Expand Up @@ -6118,7 +6118,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
.*
<dt>value</dt>
<dd>5000000000</dd>
Expand All @@ -6144,7 +6144,7 @@ next
".*<h1>Inscription 0</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
<dt>charms</dt>
<dd>
<span title=lost>🤔</span>
Expand Down Expand Up @@ -6603,7 +6603,7 @@ next
".*<h1>Inscription 1</h1>.*
<dl>
<dt>id</dt>
<dd class=monospace>{id}</dd>
<dd class=collapse>{id}</dd>
.*
<dt>delegate</dt>
<dd><a href=/inscription/{delegate}>{delegate}</a></dd>
Expand Down
2 changes: 1 addition & 1 deletion src/templates/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ mod tests {
#[test]
fn test_outputs_rendering() {
let address_html = setup();
let expected_pattern = r#".*<dt>outputs</dt>\n\s*<dd>\n\s*<ul>\n\s*<li><a class=monospace href=/output/1{64}:1>1{64}:1</a></li>\n\s*<li><a class=monospace href=/output/2{64}:2>2{64}:2</a></li>\n\s*</ul>\n\s*</dd>.*"#;
let expected_pattern = r#".*<dt>outputs</dt>\n\s*<dd>\n\s*<ul>\n\s*<li><a class=collapse href=/output/1{64}:1>1{64}:1</a></li>\n\s*<li><a class=collapse href=/output/2{64}:2>2{64}:2</a></li>\n\s*</ul>\n\s*</dd>.*"#;
assert_regex_match!(address_html, expected_pattern);
}
}
6 changes: 3 additions & 3 deletions src/templates/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ mod tests {
"
<h1>Block 0</h1>
<dl>
<dt>hash</dt><dd class=monospace>[[:xdigit:]]{64}</dd>
<dt>target</dt><dd class=monospace>[[:xdigit:]]{64}</dd>
<dt>hash</dt><dd class=collapse>[[:xdigit:]]{64}</dd>
<dt>target</dt><dd class=collapse>[[:xdigit:]]{64}</dd>
<dt>timestamp</dt><dd><time>2009-01-03 18:15:05 UTC</time></dd>
<dt>size</dt><dd>285</dd>
<dt>weight</dt><dd>1140</dd>
Expand All @@ -74,7 +74,7 @@ mod tests {
</div>
<h2>1 Transaction</h2>
<ul>
<li><a class=monospace href=/tx/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>
<li><a class=collapse href=/tx/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>
</ul>
"
.unindent()
Expand Down
4 changes: 2 additions & 2 deletions src/templates/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ mod tests {
</div>
</div>
<ol start=1260001 reversed class=block-list>
<li><a class=monospace href=/block/1{64}>1{64}</a></li>
<li><a class=monospace href=/block/0{64}>0{64}</a></li>
<li><a class=collapse href=/block/1{64}>1{64}</a></li>
<li><a class=collapse href=/block/0{64}>0{64}</a></li>
</ol>
"
.unindent(),
Expand Down
2 changes: 1 addition & 1 deletion src/templates/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod tests {
"
<h1>Input /1/2/3</h1>
<dl>
<dt>previous output</dt><dd class=monospace>0000000000000000000000000000000000000000000000000000000000000000:0</dd>
<dt>previous output</dt><dd class=collapse>0000000000000000000000000000000000000000000000000000000000000000:0</dd>
<dt>witness</dt><dd class=monospace>010101</dd>
<dt>script sig</dt><dd class=monospace>OP_PUSHBYTES_3 666f6f</dd>
<dt>text</dt><dd>\x03foo</dd>
Expand Down
Loading

0 comments on commit 54adcf6

Please sign in to comment.