change search placeholder text depending if custom lmdb exists

master
moneroexamples 8 years ago
parent 346855dd2f
commit aa32af635f

@ -259,6 +259,8 @@ class page {
bool enable_pusher; bool enable_pusher;
bool have_custom_lmdb;
uint64_t no_of_mempool_tx_of_frontpage; uint64_t no_of_mempool_tx_of_frontpage;
@ -274,10 +276,40 @@ public:
server_timestamp {std::time(nullptr)}, server_timestamp {std::time(nullptr)},
lmdb2_path {_lmdb2_path}, lmdb2_path {_lmdb2_path},
testnet {_testnet}, testnet {_testnet},
enable_pusher {_enable_pusher} enable_pusher {_enable_pusher},
have_custom_lmdb {false}
{ {
css_styles = xmreg::read(TMPL_CSS_STYLES); css_styles = xmreg::read(TMPL_CSS_STYLES);
no_of_mempool_tx_of_frontpage = 25; no_of_mempool_tx_of_frontpage = 25;
// just moneky patching now, to check
// if custom lmdb database exist, so that
// we can search for, e.g., key images,
// payments ids. try to open this database.
// if it fails, we assume it does not exist.
// this is ugly check, but will do for now.
// it does not even check if this custom lmdb
// is up to date.
try
{
unique_ptr<xmreg::MyLMDB> mylmdb;
if (bf::is_directory(lmdb2_path))
{
mylmdb = make_unique<xmreg::MyLMDB>(lmdb2_path);
// if we got to here, it seems that database exist
have_custom_lmdb = true;
}
}
catch (const std::exception& e)
{
cerr << "Custom lmdb databse seem not to exist. Its not big deal. "
"Just some searches wont be possible"
<< endl;
}
} }
/** /**
@ -302,6 +334,7 @@ public:
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb", have_custom_lmdb},
{"refresh" , refresh_page}, {"refresh" , refresh_page},
{"height" , std::to_string(height)}, {"height" , std::to_string(height)},
{"server_timestamp", xmreg::timestamp_to_str(server_timestamp)}, {"server_timestamp", xmreg::timestamp_to_str(server_timestamp)},
@ -710,6 +743,7 @@ public:
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb},
{"blk_hash" , blk_hash_str}, {"blk_hash" , blk_hash_str},
{"blk_height" , _blk_height}, {"blk_height" , _blk_height},
{"blk_timestamp" , blk_timestamp}, {"blk_timestamp" , blk_timestamp},
@ -894,7 +928,8 @@ public:
} }
mstch::map context { mstch::map context {
{"testnet" , this->testnet} {"testnet" , this->testnet},
{"have_custom_lmdb" , have_custom_lmdb}
}; };
context.emplace("txs" , mstch::array{}); context.emplace("txs" , mstch::array{});
@ -1108,6 +1143,7 @@ public:
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb},
{"tx_hash" , tx_hash_str}, {"tx_hash" , tx_hash_str},
{"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)}, {"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)},
{"xmr_address" , xmr_address_str}, {"xmr_address" , xmr_address_str},
@ -1619,7 +1655,8 @@ public:
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet} {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb}
}; };
// read rawtx.html // read rawtx.html
@ -1657,6 +1694,7 @@ public:
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb},
{"unsigned_tx_given" , unsigned_tx_given}, {"unsigned_tx_given" , unsigned_tx_given},
{"have_raw_tx" , true}, {"have_raw_tx" , true},
{"data_prefix" , data_prefix}, {"data_prefix" , data_prefix},
@ -2281,6 +2319,7 @@ public:
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb},
{"have_raw_tx" , true}, {"have_raw_tx" , true},
{"has_error" , false}, {"has_error" , false},
{"error_msg" , string {}}, {"error_msg" , string {}},
@ -2462,7 +2501,8 @@ public:
{ {
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet} {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb}
}; };
// read rawkeyimgs.html // read rawkeyimgs.html
@ -2482,7 +2522,8 @@ public:
{ {
// initalize page template context map // initalize page template context map
mstch::map context { mstch::map context {
{"testnet" , testnet} {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb}
}; };
// read rawoutputkeys.html // read rawoutputkeys.html
@ -2510,9 +2551,10 @@ public:
// initalize page template context map // initalize page template context map
mstch::map context{ mstch::map context{
{"testnet" , testnet}, {"testnet" , testnet},
{"has_error", false}, {"have_custom_lmdb", have_custom_lmdb},
{"error_msg", string{}}, {"has_error" , false},
{"error_msg" , string{}},
}; };
// read page template // read page template
@ -2873,9 +2915,10 @@ public:
// initalize page template context map // initalize page template context map
mstch::map context{ mstch::map context{
{"testnet", testnet}, {"testnet" , testnet},
{"has_error", false}, {"have_custom_lmdb", have_custom_lmdb},
{"error_msg", string{}}, {"has_error" , false},
{"error_msg" , string{}}
}; };
@ -3639,6 +3682,7 @@ public:
{"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)}, {"public_spendkey" , REMOVE_HASH_BRAKETS(pub_spendkey_str)},
{"is_integrated_addr" , false}, {"is_integrated_addr" , false},
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb}
}; };
// read address.html // read address.html
@ -3672,6 +3716,7 @@ public:
{"encrypted_payment_id" , REMOVE_HASH_BRAKETS(enc_payment_id_str)}, {"encrypted_payment_id" , REMOVE_HASH_BRAKETS(enc_payment_id_str)},
{"is_integrated_addr" , true}, {"is_integrated_addr" , true},
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb}
}; };
// read address.html // read address.html
@ -3786,10 +3831,11 @@ public:
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"search_text" , search_text}, {"search_text" , search_text},
{"no_results" , true}, {"no_results" , true},
{"to_many_results", false} {"to_many_results" , false},
{"have_custom_lmdb", have_custom_lmdb}
}; };
for (const pair<string, vector<string>>& found_txs: all_possible_tx_hashes) for (const pair<string, vector<string>>& found_txs: all_possible_tx_hashes)
@ -4000,6 +4046,7 @@ private:
// initalise page tempate map with basic info about blockchain // initalise page tempate map with basic info about blockchain
mstch::map context { mstch::map context {
{"testnet" , testnet}, {"testnet" , testnet},
{"have_custom_lmdb" , have_custom_lmdb},
{"tx_hash" , tx_hash_str}, {"tx_hash" , tx_hash_str},
{"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)}, {"tx_prefix_hash" , pod_to_hex(txd.prefix_hash)},
{"tx_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.pk))}, {"tx_pub_key" , REMOVE_HASH_BRAKETS(fmt::format("{:s}", txd.pk))},

@ -22,7 +22,8 @@
</div> </div>
{{^testnet}}
{{#have_custom_lmdb}}
<div class="center"> <div class="center">
<form action="/search" method="get" style="width:100%; margin-top:15px" class="style-1"> <form action="/search" method="get" style="width:100%; margin-top:15px" class="style-1">
<input type="text" name="value" size="120" <input type="text" name="value" size="120"
@ -30,13 +31,14 @@
<input type="submit" value="Search"> <input type="submit" value="Search">
</form> </form>
</div> </div>
{{/testnet}} {{/have_custom_lmdb}}
{{#testnet}} {{^have_custom_lmdb}}
<div class="center"> <div class="center">
<form action="/search" method="get" style="width:100%; margin-top:15px" class="style-1"> <form action="/search" method="get" style="width:100%; margin-top:15px" class="style-1">
<input type="text" name="value" size="90" <input type="text" name="value" size="120"
placeholder="blk height, blk hash, tx hash, tx payment id"> placeholder="blk height, blk hash, tx hash">
<input type="submit" value="Search"> <input type="submit" value="Search">
</form> </form>
</div> </div>
{{/testnet}} {{/have_custom_lmdb}}

Loading…
Cancel
Save