mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
started construction of template_file map
This commit is contained in:
parent
87ec3934f0
commit
381848c06d
1 changed files with 23 additions and 17 deletions
40
src/page.h
40
src/page.h
|
@ -270,6 +270,13 @@ class page {
|
||||||
uint64_t no_of_mempool_tx_of_frontpage;
|
uint64_t no_of_mempool_tx_of_frontpage;
|
||||||
uint64_t no_blocks_on_index;
|
uint64_t no_blocks_on_index;
|
||||||
|
|
||||||
|
// instead of constatnly reading template files
|
||||||
|
// from hard drive for each request, we can read
|
||||||
|
// them only once, when the explorer starts into this map
|
||||||
|
// this will improve performance of the explorer and reduce
|
||||||
|
// read operation in OS
|
||||||
|
map<string, string> template_file;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -324,6 +331,16 @@ public:
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// read template files for all the pages
|
||||||
|
// into template_file map
|
||||||
|
|
||||||
|
template_file["header"] = xmreg::read(TMPL_HEADER);
|
||||||
|
template_file["footer"] = get_footer();
|
||||||
|
template_file["index2"] = get_full_page(xmreg::read(TMPL_INDEX2));
|
||||||
|
template_file["mempool"] = xmreg::read(TMPL_MEMPOOL);
|
||||||
|
template_file["mempool_full"] = get_full_page(template_file["mempool"]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -494,16 +511,10 @@ public:
|
||||||
// append mempool_html to the index context map
|
// append mempool_html to the index context map
|
||||||
context["mempool_info"] = mempool_html;
|
context["mempool_info"] = mempool_html;
|
||||||
|
|
||||||
// read index.html
|
|
||||||
string index2_html = xmreg::read(TMPL_INDEX2);
|
|
||||||
|
|
||||||
// add header and footer
|
|
||||||
string full_page = get_full_page(index2_html);
|
|
||||||
|
|
||||||
add_css_style(context);
|
add_css_style(context);
|
||||||
|
|
||||||
// render the page
|
// render the page
|
||||||
return mstch::render(full_page, context);
|
return mstch::render(template_file["index2"], context);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -640,8 +651,6 @@ public:
|
||||||
return t1 > t2;
|
return t1 > t2;
|
||||||
});
|
});
|
||||||
|
|
||||||
// read mempool.html
|
|
||||||
string mempool_html = xmreg::read(TMPL_MEMPOOL);
|
|
||||||
|
|
||||||
if (add_header_and_footer)
|
if (add_header_and_footer)
|
||||||
{
|
{
|
||||||
|
@ -650,11 +659,8 @@ public:
|
||||||
|
|
||||||
context["partial_mempool_shown"] = false;
|
context["partial_mempool_shown"] = false;
|
||||||
|
|
||||||
// add header and footer
|
|
||||||
string full_page = get_full_page(mempool_html);
|
|
||||||
|
|
||||||
// render the page
|
// render the page
|
||||||
return mstch::render(full_page, context);
|
return mstch::render(template_file["mempool_full"], context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is for partial disply on front page.
|
// this is for partial disply on front page.
|
||||||
|
@ -672,7 +678,7 @@ public:
|
||||||
context["partial_mempool_shown"] = true;
|
context["partial_mempool_shown"] = true;
|
||||||
|
|
||||||
// render the page
|
// render the page
|
||||||
return mstch::render(mempool_html, context);
|
return mstch::render(template_file["mempool"], context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -4695,11 +4701,11 @@ private:
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
get_full_page(string& middle)
|
get_full_page(const string& middle)
|
||||||
{
|
{
|
||||||
return xmreg::read(TMPL_HEADER)
|
return template_file["header"]
|
||||||
+ middle
|
+ middle
|
||||||
+ get_footer();
|
+ template_file["footer"];
|
||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
|
|
Loading…
Reference in a new issue