Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve page titles #1221

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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