Skip to content

Commit

Permalink
Use numbers in page titles (#1221)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 16, 2023
1 parent 7c8c93c commit 57ab257
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
31 changes: 30 additions & 1 deletion src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,16 @@ mod tests {
TestServer::new().assert_response_regex(
"/sat/0",
StatusCode::OK,
".*<title>0°0′0″0‴</title>.*<h1>Sat 0</h1>.*",
".*<title>Sat 0</title>.*<h1>Sat 0</h1>.*",
);
}

#[test]
fn block() {
TestServer::new().assert_response_regex(
"/block/0",
StatusCode::OK,
".*<title>Block 0</title>.*<h1>Block 0</h1>.*",
);
}

Expand Down Expand Up @@ -1886,6 +1895,26 @@ mod tests {
);
}

#[test]
fn inscription_page_title() {
let server = TestServer::new_with_sat_index();
server.mine_blocks(1);

let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate {
inputs: &[(1, 0, 0)],
witness: inscription("text/foo", "hello").to_witness(),
..Default::default()
});

server.mine_blocks(1);

server.assert_response_regex(
format!("/inscription/{}", InscriptionId::from(txid)),
StatusCode::OK,
".*<title>Inscription 0</title>.*",
);
}

#[test]
fn inscription_page_has_sat_when_sats_are_tracked() {
let server = TestServer::new_with_sat_index();
Expand Down
2 changes: 1 addition & 1 deletion src/templates/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl BlockHtml {

impl PageContent for BlockHtml {
fn title(&self) -> String {
format!("Block {}", self.hash)
format!("Block {}", self.height)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/templates/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) struct InscriptionHtml {

impl PageContent for InscriptionHtml {
fn title(&self) -> String {
format!("Inscription {}", self.inscription_id)
format!("Inscription {}", self.number)
}

fn preview_image_url(&self) -> Option<Trusted<String>> {
Expand Down
2 changes: 1 addition & 1 deletion src/templates/sat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(crate) struct SatHtml {

impl PageContent for SatHtml {
fn title(&self) -> String {
self.sat.degree().to_string()
format!("Sat {}", self.sat)
}
}

Expand Down

0 comments on commit 57ab257

Please sign in to comment.