index2 amended

master
moneroexamples 9 years ago
parent 6d84e1e7a5
commit 9f8ead6323

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

@ -442,6 +442,12 @@ namespace xmreg {
continue; 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 // get block age
pair<string, string> age = get_age(server_timestamp, blk.timestamp); pair<string, string> age = get_age(server_timestamp, blk.timestamp);
@ -476,6 +482,8 @@ namespace xmreg {
mstch::map txd_map = txd.get_mstch_map(); mstch::map txd_map = txd.get_mstch_map();
//add age to the txd 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({"time_delta", time_delta_str});
txd_map.insert({"age" , age.first}); txd_map.insert({"age" , age.first});
@ -503,10 +511,10 @@ namespace xmreg {
context["mempool_info"] = mempool_html; context["mempool_info"] = mempool_html;
// read index.html // read index.html
string index_html = xmreg::read(TMPL_INDEX2); string index2_html = xmreg::read(TMPL_INDEX2);
// add header and footer // add header and footer
string full_page = get_full_page(index_html); string full_page = get_full_page(index2_html);
// render the page // render the page
return mstch::render(full_page, context); return mstch::render(full_page, context);

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

Loading…
Cancel
Save