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

@ -271,3 +271,11 @@ textarea {
div.search input {
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"/>
</head>
<body>
<div id="page-wrapper">
<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>
</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,25 +1,13 @@
{% extends "base" %}
{% block content %}
<div id="page-wrapper">
<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>
<section id="main">
<div class="container">
<div class="row">
<div class="col-12">
<section>
<header class="major">
<h2>Network Stats</h2>
<h2>Network Statistics</h2>
</header>
<div class="row">
<div class="col-3 col-6-medium col-12-small">
@ -94,20 +82,5 @@
</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>
</section>
</div>
{% endblock content %}

Loading…
Cancel
Save