index2 amended

This commit is contained in:
moneroexamples 2016-05-01 10:13:44 +08:00
parent 6d84e1e7a5
commit 9f8ead6323
3 changed files with 18 additions and 12 deletions

View File

@ -71,12 +71,12 @@ int main(int ac, const char* av[]) {
CROW_ROUTE(app, "/")
([&]() {
return xmrblocks.index();
return xmrblocks.index2();
});
CROW_ROUTE(app, "/page/<uint>")
([&](size_t page_no) {
return xmrblocks.index(page_no);
return xmrblocks.index2(page_no);
});
CROW_ROUTE(app, "/block/<uint>")

View File

@ -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<string, string> 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);

View File

@ -16,7 +16,7 @@
{{{mempool_info}}}
{{#is_page_zero}}
<h2>100 recent blocks<!--(height: {{height}})--></h2>
<h2>20 recent blocks<!--(height: {{height}})--></h2>
{{/is_page_zero}}
{{^is_page_zero}}
<h2>older blocks<!--(height: {{height}})--></h2>
@ -28,8 +28,7 @@
<tr>
<td>height</td>
<td>age {{age_format}} (Δm)</td>
<td>block hash</td>
<td>txs</td>
<td>tx hash</td>
<td>fees</td>
<td>outputs</td>
<td>mixins</td>
@ -39,12 +38,11 @@
<tr>
<td><a href="/block/{{height}}">{{height}}</a></td>
<td>{{age}} ({{time_delta}})</td>
<td><a href="/block/{{hash}}">{{hash}}</a></td>
<td>{{notx}}</td>
<td><a href="/tx/{{hash}}">{{hash}}</a></td>
<td>{{fees}}</td>
<td>{{xmr_outputs}}</td>
<td>{{mixin_range}}</td>
<td>{{blksize}}</td>
<td>{{sum_outputs}}</td>
<td>{{mixin}}</td>
<td>{{tx_size}}</td>
</tr>
{{/blocks}}
</table>