From 9f8ead6323ab47a0db661dcfb8e575607c7acb65 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Sun, 1 May 2016 10:13:44 +0800 Subject: [PATCH] index2 amended --- main.cpp | 4 ++-- src/page.h | 12 ++++++++++-- src/templates/index2.html | 14 ++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/main.cpp b/main.cpp index 52d7873..3d7136a 100644 --- a/main.cpp +++ b/main.cpp @@ -71,12 +71,12 @@ int main(int ac, const char* av[]) { CROW_ROUTE(app, "/") ([&]() { - return xmrblocks.index(); + return xmrblocks.index2(); }); CROW_ROUTE(app, "/page/") ([&](size_t page_no) { - return xmrblocks.index(page_no); + return xmrblocks.index2(page_no); }); CROW_ROUTE(app, "/block/") diff --git a/src/page.h b/src/page.h index 52a7ceb..c970da4 100644 --- a/src/page.h +++ b/src/page.h @@ -442,6 +442,12 @@ namespace xmreg { continue; } + // get block's hash + crypto::hash blk_hash = core_storage->get_block_id_by_height(i); + + // remove "<" and ">" from the hash string + string blk_hash_str = REMOVE_HASH_BRAKETS(fmt::format("{:s}", blk_hash)); + // get block age pair age = get_age(server_timestamp, blk.timestamp); @@ -476,6 +482,8 @@ namespace xmreg { mstch::map txd_map = txd.get_mstch_map(); //add age to the txd mstch map + txd_map.insert({"height" , i}); + txd_map.insert({"blk_hash" , blk_hash_str}); txd_map.insert({"time_delta", time_delta_str}); txd_map.insert({"age" , age.first}); @@ -503,10 +511,10 @@ namespace xmreg { context["mempool_info"] = mempool_html; // read index.html - string index_html = xmreg::read(TMPL_INDEX2); + string index2_html = xmreg::read(TMPL_INDEX2); // add header and footer - string full_page = get_full_page(index_html); + string full_page = get_full_page(index2_html); // render the page return mstch::render(full_page, context); diff --git a/src/templates/index2.html b/src/templates/index2.html index 46b0272..cc673be 100644 --- a/src/templates/index2.html +++ b/src/templates/index2.html @@ -16,7 +16,7 @@ {{{mempool_info}}} {{#is_page_zero}} -

100 recent blocks

+

20 recent blocks

{{/is_page_zero}} {{^is_page_zero}}

older blocks

@@ -28,8 +28,7 @@ height age {{age_format}} (Δm) - block hash - txs + tx hash fees outputs mixins @@ -39,12 +38,11 @@ {{height}} {{age}} ({{time_delta}}) - {{hash}} - {{notx}} + {{hash}} {{fees}} - {{xmr_outputs}} - {{mixin_range}} - {{blksize}} + {{sum_outputs}} + {{mixin}} + {{tx_size}} {{/blocks}}