update static and templates

master
lalanza808 5 years ago
parent 098db79da5
commit 5f595d055f

@ -40,25 +40,25 @@ fn issue_raw_rpc(method: &str, params: JsonValue) -> RequestBuilder {
} }
#[get("/block/hash/<block_hash>")] #[get("/block/hash/<block_hash>")]
fn get_block_by_hash(block_hash: String) -> Json<GetBlockResult> { fn get_block_by_hash(block_hash: String) -> Template {
let params = RPCParams { let params = RPCParams {
hash: Some(block_hash), hash: Some(block_hash),
..Default::default() ..Default::default()
}; };
let res: GetBlock = issue_rpc(&"get_block", Some(params)) let res: GetBlock = issue_rpc(&"get_block", Some(params))
.send().unwrap().json().unwrap(); .send().unwrap().json().unwrap();
Json(res.result) Template::render("block", &res.result)
} }
#[get("/block/height/<block_height>")] #[get("/block/height/<block_height>")]
fn get_block_by_height(block_height: String) -> Json<GetBlockResult> { fn get_block_by_height(block_height: String) -> Template {
let params = RPCParams { let params = RPCParams {
height: Some(block_height), height: Some(block_height),
..Default::default() ..Default::default()
}; };
let res: GetBlock = issue_rpc(&"get_block", Some(params)) let res: GetBlock = issue_rpc(&"get_block", Some(params))
.send().unwrap().json().unwrap(); .send().unwrap().json().unwrap();
Json(res.result) Template::render("block", &res.result)
} }
#[get("/transaction/<tx_hash>")] #[get("/transaction/<tx_hash>")]
@ -75,10 +75,8 @@ fn search(value: &RawStr) -> Redirect {
// We basically check the length of the search value and // We basically check the length of the search value and
// attempt to redirect to the appropriate route. // attempt to redirect to the appropriate route.
let sl: usize = value.len(); let sl: usize = value.len();
println!("{}", sl); if sl < 8 {
// Less than 8 characters is probably a block height. If it can
if sl < 10 {
// Less than 10 characters is probably a block height. If it can
// be parsed as valid u32 then redirect to `get_block_by_height`, // be parsed as valid u32 then redirect to `get_block_by_height`,
// otherwise redirect to the error response. // otherwise redirect to the error response.
match value.parse::<u32>() { match value.parse::<u32>() {

@ -271,3 +271,11 @@ textarea {
div.search input { div.search input {
margin-top: 1em; margin-top: 1em;
} }
section.box p {
font-size: 1.3em;
}
p.subheader {
font-size: 1.3em;
}

@ -8,7 +8,36 @@
<link rel="stylesheet" href="/static/css/dopetrope.css"/> <link rel="stylesheet" href="/static/css/dopetrope.css"/>
</head> </head>
<body> <body>
{% block content %} <div id="page-wrapper">
{% endblock content %} <section id="header">
<h1><a href="/">Monero Block Explorer</a></h1>
<nav id="nav">
<div class="search">
<form action="/search" method="get">
<input type="text" name="value" placeholder="Enter a transaction hash, block hash, or block height.">
<input type="submit" value="Search">
</form>
</div>
</nav>
</section>
{% block content %}
{% endblock content %}
<section id="footer">
<div class="container">
<div class="row">
<div class="col-12">
<div id="copyright">
<ul class="links">
<li><a href="https://html5up.net" target=_blank>Design by HTML5 UP</a></li>
<li><a href="https://github.com/lalanza808/monero-block-explorer" target=_blank>Read the source</a></li>
<li><a href="https://github.com/lalanza808/monero-block-explorer/issues/new" target=_blank>File a bug or request</a></li>
<li><a href="https://twitter.com/lza_menace" target=_blank>Holler at me</a></li>
</ul>
</div>
</div>
</div>
</div>
</section>
</div>
</body> </body>
</html> </html>

@ -0,0 +1,101 @@
{% extends "base" %}
{% block content %}
<section id="main">
<div class="container">
<div class="col-12">
<section>
<header class="major">
<h2>Block {{ block_header.height }}</h2>
<p class="subheader"><strong>Hash</strong>: {{ block_header.hash }}</p>
<p class="subheader"><strong>Timestamp</strong>: {{ block_header.timestamp }}
</header>
<div class="row">
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Size</h3>
</header>
<p>{{ block_header.block_size }} bytes</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Depth</h3>
</header>
<p>{{ block_header.depth }}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Difficulty</h3>
</header>
<p>{{ block_header.difficulty }}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Transactions</h3>
</header>
<p>{% if tx_hashes %}{{ tx_hashes | length }}{% else %}0{% endif %}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Orphaned</h3>
</header>
<p>{{ block_header.orphan_status }}</p>
</section>
</div>
<div class="col-4 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Nonce</h3>
</header>
<p>{{ block_header.nonce }}</p>
</section>
</div>
</div>
</section>
</div>
<br><br>
<table>
<caption><h2>Block Transactions</h2></caption>
<tr>
<th>Coinbase</th>
<th>Hash</th>
<th>Amount</th>
<th>Fee</th>
<th>Bytes</th>
</tr>
<tr>
<td>√</td>
<td><a href="/transaction/{{ block_header.miner_tx_hash }}">{{ block_header.miner_tx_hash }}</a></td>
<td>{{ block_header.reward / 1000000000000 }} XMR</td>
<td>0</td>
<td>?</td>
</tr>
{% if tx_hashes %}
{% for hash in tx_hashes %}
<tr>
<td></td>
<td><a href="/transaction/{{ hash }}">{{ hash }}</a></td>
<td>?</td>
<td>?</td>
<td>?</td>
</tr>
{% endfor %}
{% endif %}
</table>
<header class="major">
<h2><a href="/block/hash/{{ block_header.prev_hash }}">Previous Block</a></h2>
</header>
</div>
</section>
{% endblock content %}

@ -1,113 +1,86 @@
{% extends "base" %} {% extends "base" %}
{% block content %} {% block content %}
<div id="page-wrapper"> <section id="main">
<section id="header"> <div class="container">
<h1><a href="/">Monero Block Explorer</a></h1> <div class="row">
<nav id="nav"> <div class="col-12">
<div class="search"> <section>
<form action="/search" method="get"> <header class="major">
<input type="text" name="value" placeholder="Enter a transaction hash, block hash, or block height."> <h2>Network Statistics</h2>
<input type="submit" value="Search"> </header>
</form> <div class="row">
</div> <div class="col-3 col-6-medium col-12-small">
</nav> <section class="box">
</section> <header>
<section id="main"> <h3>Version</h3>
<div class="container"> </header>
<div class="row"> <p>{{ version }}</p>
<div class="col-12"> </section>
<section> </div>
<header class="major"> <div class="col-3 col-6-medium col-12-small">
<h2>Network Stats</h2> <section class="box">
</header> <header>
<div class="row"> <h3>Difficulty</h3>
<div class="col-3 col-6-medium col-12-small"> </header>
<section class="box"> <p>{{ difficulty }}</p>
<header> </section>
<h3>Version</h3> </div>
</header> <div class="col-3 col-6-medium col-12-small">
<p>{{ version }}</p> <section class="box">
</section> <header>
</div> <h3>Height</h3>
<div class="col-3 col-6-medium col-12-small"> </header>
<section class="box"> <p>{{ height }}</p>
<header> </section>
<h3>Difficulty</h3> </div>
</header> <div class="col-3 col-6-medium col-12-small">
<p>{{ difficulty }}</p> <section class="box">
</section> <header>
</div> <h3>Network</h3>
<div class="col-3 col-6-medium col-12-small"> </header>
<section class="box"> <p>{{ nettype }}</p>
<header> </section>
<h3>Height</h3> </div>
</header> </div>
<p>{{ height }}</p> <div class="row">
</section> <div class="col-3 col-6-medium col-12-small">
</div> <section class="box">
<div class="col-3 col-6-medium col-12-small"> <header>
<section class="box"> <h3>Transactions</h3>
<header> </header>
<h3>Network</h3> <p>{{ tx_count }}</p>
</header> </section>
<p>{{ nettype }}</p> </div>
</section> <div class="col-3 col-6-medium col-12-small">
</div> <section class="box">
</div> <header>
<div class="row"> <h3>Mempool Size</h3>
<div class="col-3 col-6-medium col-12-small"> </header>
<section class="box"> <p>{{ tx_pool_size }}</p>
<header> </section>
<h3>Transactions</h3> </div>
</header> <div class="col-3 col-6-medium col-12-small">
<p>{{ tx_count }}</p> <section class="box">
</section> <header>
</div> <h3>Connections</h3>
<div class="col-3 col-6-medium col-12-small"> </header>
<section class="box"> <p>{{ incoming_connections_count }} in / {{ outgoing_connections_count }} out</p>
<header> </section>
<h3>Mempool Size</h3> </div>
</header> <div class="col-3 col-6-medium col-12-small">
<p>{{ tx_pool_size }}</p> <section class="box">
</section> <header>
</div> <h3>Status</h3>
<div class="col-3 col-6-medium col-12-small"> </header>
<section class="box"> <p>{{ status }}</p>
<header> </section>
<h3>Connections</h3>
</header>
<p>{{ incoming_connections_count }} in / {{ outgoing_connections_count }} out</p>
</section>
</div>
<div class="col-3 col-6-medium col-12-small">
<section class="box">
<header>
<h3>Status</h3>
</header>
<p>{{ status }}</p>
</section>
</div>
</div>
</section>
</div>
</div>
</div>
</section>
<section id="footer">
<div class="container">
<div class="row">
<div class="col-12">
<div id="copyright">
<ul class="links">
<li>Design: <a href="https://html5up.net" target=_blank>HTML5 UP</a></li>
<li>Source: <a href="https://github.com/lalanza808/monero-block-explorer" target=_blank>Github</a></li>
</ul>
</div> </div>
</div> </div>
</div> </section>
</div> </div>
</section> </div>
</div> </div>
</section>
{% endblock content %} {% endblock content %}

Loading…
Cancel
Save