feat: make site name configurable
Changes: + add Config::site_name, which defaults to "Neptune Explorer" + remove HeaderHtml::site_name + use Config::site_name in the html templates
This commit is contained in:
parent
48966fa69d
commit
df14092d61
@ -5,6 +5,5 @@ use std::sync::Arc;
|
|||||||
#[derive(boilerplate::Boilerplate)]
|
#[derive(boilerplate::Boilerplate)]
|
||||||
#[boilerplate(filename = "web/html/components/header.html")]
|
#[boilerplate(filename = "web/html/components/header.html")]
|
||||||
pub struct HeaderHtml {
|
pub struct HeaderHtml {
|
||||||
pub site_name: String,
|
|
||||||
pub state: Arc<AppState>,
|
pub state: Arc<AppState>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,6 @@ pub async fn block_page_with_value(
|
|||||||
.map_err(|e| not_found_html_response(State(state.clone()), Some(e.to_string())))?;
|
.map_err(|e| not_found_html_response(State(state.clone()), Some(e.to_string())))?;
|
||||||
|
|
||||||
let header = HeaderHtml {
|
let header = HeaderHtml {
|
||||||
site_name: "Neptune Explorer".to_string(),
|
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,6 @@ pub fn not_found_page(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let header = HeaderHtml {
|
let header = HeaderHtml {
|
||||||
site_name: "Neptune Explorer".to_string(),
|
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,6 @@ pub async fn utxo_page(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let header = HeaderHtml {
|
let header = HeaderHtml {
|
||||||
site_name: "Neptune Explorer".to_string(),
|
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
#[derive(Debug, clap::Parser, Clone)]
|
#[derive(Debug, clap::Parser, Clone)]
|
||||||
#[clap(name = "neptune-explorer", about = "Neptune Block Explorer")]
|
#[clap(name = "neptune-explorer", about = "Neptune Block Explorer")]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
|
/// Sets the website name
|
||||||
|
#[clap(long, default_value = "Neptune Explorer", value_name = "site-name")]
|
||||||
|
pub site_name: String,
|
||||||
|
|
||||||
/// Sets the server address to connect to.
|
/// Sets the server address to connect to.
|
||||||
#[clap(long, default_value = "9799", value_name = "PORT")]
|
#[clap(long, default_value = "9799", value_name = "PORT")]
|
||||||
pub port: u16,
|
pub port: u16,
|
||||||
|
|||||||
@ -1,3 +1,3 @@
|
|||||||
<header class="container">
|
<header class="container">
|
||||||
<h1>{{self.site_name}} : {{self.state.network}}</h1>
|
<h1>{{self.state.config.site_name}} : {{self.state.network}}</h1>
|
||||||
</header>
|
</header>
|
||||||
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Neptune Block Explorer: Block Height {{self.block_info.height}}</title>
|
<title>{{self.header.state.config.site_name}}: Block Height {{self.block_info.height}}</title>
|
||||||
{{html_escaper::Trusted(include_str!(concat!(env!("CARGO_MANIFEST_DIR"),"/templates/web/html/components/head.html")))}}
|
{{html_escaper::Trusted(include_str!(concat!(env!("CARGO_MANIFEST_DIR"),"/templates/web/html/components/head.html")))}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@ -16,10 +16,10 @@
|
|||||||
|
|
||||||
<!-- special_block_notice -->
|
<!-- special_block_notice -->
|
||||||
%% if self.block_info.is_genesis {
|
%% if self.block_info.is_genesis {
|
||||||
<p>This is the Genesis Block</p>
|
<p>This is the genesis block</p>
|
||||||
%% }
|
%% }
|
||||||
%% if self.block_info.is_tip {
|
%% if self.block_info.is_tip {
|
||||||
<p>This is the Latest Block (tip)</p>
|
<p>This is the latest block (tip)</p>
|
||||||
%% }
|
%% }
|
||||||
|
|
||||||
<table class="striped">
|
<table class="striped">
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Neptune Block Explorer: Not Found</title>
|
<title>{{self.header.state.config.site_name}}: Not Found</title>
|
||||||
{{html_escaper::Trusted(include_str!( concat!(env!("CARGO_MANIFEST_DIR"), "/templates/web/html/components/head.html")))}}
|
{{html_escaper::Trusted(include_str!( concat!(env!("CARGO_MANIFEST_DIR"), "/templates/web/html/components/head.html")))}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Neptune Block Explorer: (network: {{self.state.network}})</title>
|
<title>{{self.state.config.site_name}}: (network: {{self.state.network}})</title>
|
||||||
{{ html_escaper::Trusted(include_str!( concat!(env!("CARGO_MANIFEST_DIR"), "/templates/web/html/components/head.html"))) }}
|
{{ html_escaper::Trusted(include_str!( concat!(env!("CARGO_MANIFEST_DIR"), "/templates/web/html/components/head.html"))) }}
|
||||||
<script>
|
<script>
|
||||||
function handle_submit(form) {
|
function handle_submit(form) {
|
||||||
@ -23,7 +23,7 @@
|
|||||||
<header class="container">
|
<header class="container">
|
||||||
<h1>
|
<h1>
|
||||||
<img src="/image/neptune-logo.png" align="right"/>
|
<img src="/image/neptune-logo.png" align="right"/>
|
||||||
Neptune Block Explorer (network: {{self.state.network}})
|
{{self.state.config.site_name}} (network: {{self.state.network}})
|
||||||
</h1>
|
</h1>
|
||||||
The blockchain tip is at height: {{self.tip_height}}
|
The blockchain tip is at height: {{self.tip_height}}
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<title>Neptune Block Explorer: Utxo {{self.index}}</title>
|
<title>{{self.header.state.config.site_name}}: Utxo {{self.index}}</title>
|
||||||
{{html_escaper::Trusted(include_str!( concat!(env!("CARGO_MANIFEST_DIR"), "/templates/web/html/components/head.html")))}}
|
{{html_escaper::Trusted(include_str!( concat!(env!("CARGO_MANIFEST_DIR"), "/templates/web/html/components/head.html")))}}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user