Skip to content

Commit

Permalink
Rename / page from "root" to "home" (ordinals#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Aug 18, 2022
1 parent f61972b commit 9dd9cce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use {
self::{
deserialize_ordinal_from_str::DeserializeOrdinalFromStr,
templates::{
block::BlockHtml, ordinal::OrdinalHtml, output::OutputHtml, range::RangeHtml, root::RootHtml,
block::BlockHtml, home::HomeHtml, ordinal::OrdinalHtml, output::OutputHtml, range::RangeHtml,
transaction::TransactionHtml, Content,
},
tls_acceptor::TlsAcceptor,
Expand Down Expand Up @@ -94,7 +94,7 @@ impl Server {
});

let app = Router::new()
.route("/", get(Self::root))
.route("/", get(Self::home))
.route("/api/list/:outpoint", get(Self::api_list))
.route("/block/:hash", get(Self::block))
.route("/bounties", get(Self::bounties))
Expand Down Expand Up @@ -241,9 +241,9 @@ impl Server {
}
}

async fn root(index: extract::Extension<Arc<Index>>) -> impl IntoResponse {
async fn home(index: extract::Extension<Arc<Index>>) -> impl IntoResponse {
match index.blocks(100) {
Ok(blocks) => RootHtml { blocks }.page().into_response(),
Ok(blocks) => HomeHtml { blocks }.page().into_response(),
Err(err) => {
eprintln!("Error getting blocks: {err}");
(
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/server/templates.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use {super::*, boilerplate::Display};

pub(crate) mod block;
pub(crate) mod home;
pub(crate) mod ordinal;
pub(crate) mod output;
pub(crate) mod range;
pub(crate) mod root;
pub(crate) mod transaction;

#[derive(Display)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::*;

#[derive(Display)]
pub(crate) struct RootHtml {
pub(crate) struct HomeHtml {
pub(crate) blocks: Vec<(u64, BlockHash)>,
}

impl Content for RootHtml {
impl Content for HomeHtml {
fn title(&self) -> String {
"Ordinals".to_string()
}
Expand All @@ -30,7 +30,7 @@ mod tests {
}

#[test]
fn root_html() {
fn home_html() {
assert_regex_match!(
"<h1>Ordinals</h1>
<nav>.*</nav>
Expand All @@ -40,7 +40,7 @@ mod tests {
<li>0 - <a href=/block/0000000000000000000000000000000000000000000000000000000000000000>0000000000000000000000000000000000000000000000000000000000000000</a></li>
</ul>
",
&RootHtml {
&HomeHtml {
blocks: vec![
(
1,
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fn invalid_vout_returns_404() {
}

#[test]
fn root() {
fn home() {
let mut state = State::new();

state.blocks(1);
Expand All @@ -167,7 +167,7 @@ fn root() {
}

#[test]
fn root_block_limit() {
fn home_block_limit() {
let mut state = State::new();

state.blocks(200);
Expand Down

0 comments on commit 9dd9cce

Please sign in to comment.