diff --git a/src/main.rs b/src/main.rs index 08ca419..071b755 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,25 +40,25 @@ fn issue_raw_rpc(method: &str, params: JsonValue) -> RequestBuilder { } #[get("/block/hash/")] -fn get_block_by_hash(block_hash: String) -> Json { +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/")] -fn get_block_by_height(block_height: String) -> Json { +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/")] @@ -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::() { diff --git a/static/css/main.css b/static/css/main.css index ed8fa34..a557b3d 100755 --- a/static/css/main.css +++ b/static/css/main.css @@ -271,3 +271,11 @@ textarea { div.search input { margin-top: 1em; } + +section.box p { + font-size: 1.3em; +} + +p.subheader { + font-size: 1.3em; +} diff --git a/templates/base.html.tera b/templates/base.html.tera index 0b1e279..3869842 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -8,7 +8,36 @@ - {% block content %} - {% endblock content %} +
+ + {% block content %} + {% endblock content %} + +
diff --git a/templates/block.html.tera b/templates/block.html.tera new file mode 100644 index 0000000..7368dc6 --- /dev/null +++ b/templates/block.html.tera @@ -0,0 +1,101 @@ +{% extends "base" %} + +{% block content %} + +
+
+
+
+
+

Block {{ block_header.height }}

+

Hash: {{ block_header.hash }}

+

Timestamp: {{ block_header.timestamp }} +

+
+
+
+
+

Size

+
+

{{ block_header.block_size }} bytes

+
+
+
+
+
+

Depth

+
+

{{ block_header.depth }}

+
+
+
+
+
+

Difficulty

+
+

{{ block_header.difficulty }}

+
+
+
+
+
+

Transactions

+
+

{% if tx_hashes %}{{ tx_hashes | length }}{% else %}0{% endif %}

+
+
+
+
+
+

Orphaned

+
+

{{ block_header.orphan_status }}

+
+
+
+
+
+

Nonce

+
+

{{ block_header.nonce }}

+
+
+
+
+
+

+ + + + + + + + + + + + + + + + + {% if tx_hashes %} + {% for hash in tx_hashes %} + + + + + + + + {% endfor %} + {% endif %} +

Block Transactions

CoinbaseHashAmountFeeBytes
{{ block_header.miner_tx_hash }}{{ block_header.reward / 1000000000000 }} XMR0?
{{ hash }}???
+
+

Previous Block

+
+
+
+ +{% endblock content %} diff --git a/templates/index.html.tera b/templates/index.html.tera index 5c45b37..f7e2cc1 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -1,113 +1,86 @@ {% extends "base" %} {% block content %} -
- -
-
-
-
-
-
-

Network Stats

-
-
-
-
-
-

Version

-
-

{{ version }}

-
-
-
-
-
-

Difficulty

-
-

{{ difficulty }}

-
-
-
-
-
-

Height

-
-

{{ height }}

-
-
-
-
-
-

Network

-
-

{{ nettype }}

-
-
-
-
-
-
-
-

Transactions

-
-

{{ tx_count }}

-
-
-
-
-
-

Mempool Size

-
-

{{ tx_pool_size }}

-
-
-
-
-
-

Connections

-
-

{{ incoming_connections_count }} in / {{ outgoing_connections_count }} out

-
-
-
-
-
-

Status

-
-

{{ status }}

-
-
-
-
-
-
-
-
- -
+ + + {% endblock content %}