aboutsummaryrefslogtreecommitdiffhomepage
path: root/sundry
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2021-08-11 03:06:47 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2021-08-11 11:03:07 -0400
commit118ea61dc79bf9b1c45bbf81b31361a749e32fdd (patch)
tree3d803e1b7d9e99187c82cbb1b1af735972c09510 /sundry
parentspine_search (work on) (diff)
spine search and configuration related
Diffstat (limited to 'sundry')
-rw-r--r--sundry/spine_search_cgi/src/spine_search.d47
-rwxr-xr-xsundry/spine_search_cgi/src/spine_search.d_48
-rw-r--r--sundry/spine_search_cgi/views/configuration.txt19
-rw-r--r--sundry/spine_search_cgi/views/configuration_suggested.txt19
4 files changed, 69 insertions, 64 deletions
diff --git a/sundry/spine_search_cgi/src/spine_search.d b/sundry/spine_search_cgi/src/spine_search.d
index 2ddc11b..a2d290a 100644
--- a/sundry/spine_search_cgi/src/spine_search.d
+++ b/sundry/spine_search_cgi/src/spine_search.d
@@ -71,26 +71,26 @@ void cgi_function_intro(Cgi cgi) {
string web_doc_root_path;
string doc_collection_sub_root;
string cgi_root;
- string cgi_script;
+ string cgi_script_name;
string data_path_html;
- string db_path;
- string query_string;
string http_url;
+ string query_base_url;
+ string query_string;
string request_method;
- string query_base;
+ string db_path;
}
auto conf = Config();
conf.http_request_type = environment.get("REQUEST_SCHEME", _cfg.http_request_type);
- conf.http_host = environment.get("HTTP_HOST", _cfg.http_host);
- conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", _cfg.doc_root_www);
+ conf.http_host = environment.get("SERVER_NAME", _cfg.http_host);
+ conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", _cfg.www_doc_root);
conf.doc_collection_sub_root = "/spine/static"; // (output_path - web_doc_root_path)
- conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", _cfg.host_cgi_subpath);
- conf.cgi_script = environment.get("SCRIPT_NAME", _cfg.filename_cgi);
+ conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", _cfg.cgi_bin_subpath);
+ conf.cgi_script_name = environment.get("SCRIPT_NAME", _cfg.cgi_filename);
+ conf.query_base_url = conf.http_request_type ~ "://" ~ conf.http_host ~ "/" ~ conf.cgi_script_name ~ "?";
conf.query_string = environment.get("QUERY_STRING", "");
- conf.db_path = _cfg.doc_root_db;
+ conf.http_url = environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string);
conf.request_method = environment.get("REQUEST_METHOD", "POST");
- conf.query_base = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?";
- conf.http_url = environment.get("HTTP_REFERER", conf.query_base ~ conf.query_string);
+ conf.db_path = _cfg.db_sqlite_path;
struct CGI_val {
string db_selected = "";
string sql_match_limit = ""; // radio: ( 1000 | 2500 )
@@ -105,7 +105,7 @@ void cgi_function_intro(Cgi cgi) {
bool checked_sql = false;
}
auto cv = CGI_val();
- cv.db_selected = _cfg.filename_db;
+ cv.db_selected = _cfg.db_sqlite_filename;
auto text_fields() {
string canned_query_str = environment.get("QUERY_STRING", "");
if ("query_string" in cgi.post) {
@@ -444,9 +444,9 @@ void cgi_function_intro(Cgi cgi) {
string canned_url () {
string _url = "";
if (environment.get("REQUEST_METHOD", "POST") == "POST") {
- _url = conf.query_base ~ tf.canned_query;
+ _url = conf.query_base_url ~ tf.canned_query;
} else if (environment.get("REQUEST_METHOD", "POST") == "GET") {
- _url = conf.query_base ~ environment.get("QUERY_STRING", "");
+ _url = conf.query_base_url ~ environment.get("QUERY_STRING", "");
}
return _url;
}
@@ -516,7 +516,7 @@ void cgi_function_intro(Cgi cgi) {
_set_offset_previous = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int - cv.sql_match_limit.to!int).to!string;
_url_previous = _url.replace(rgx.track_offset, _set_offset_previous);
}
- } else {// _current_offset_value = 0;
+ } else { // _current_offset_value = 0;
_url_next = _url ~= "&smo=" ~ cv.sql_match_limit.to!string;
}
if (_url_previous.empty) {
@@ -1412,9 +1412,9 @@ void cgi_function_intro(Cgi cgi) {
string _the_can = "";
if (show_the_can == "checked") {
tf = text_fields;
- string method_get_url = conf.query_base ~ environment.get("QUERY_STRING", "");
- string method_post_url_construct = conf.query_base ~ tf.canned_query;
- // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base ~ conf.query_string));
+ string method_get_url = conf.query_base_url ~ environment.get("QUERY_STRING", "");
+ string method_post_url_construct = conf.query_base_url ~ tf.canned_query;
+ // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string));
if (conf.request_method == "POST") {
_the_can =
"<font size=\"2\" color=\"#666666\">"
@@ -1435,7 +1435,7 @@ void cgi_function_intro(Cgi cgi) {
~ method_get_url
~ "</a></font>";
}
- conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query;
+ conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script_name ~ tf.canned_query;
}
return _the_can;
}
@@ -1501,7 +1501,7 @@ void cgi_function_intro(Cgi cgi) {
</table>
</form>
┃",
- _cfg.filename_cgi,
+ _cfg.cgi_filename,
(post_value("ec") == "checked") ? post_value("sf", "field") : "",
provide_tip,
search_note,
@@ -1537,7 +1537,7 @@ void cgi_function_intro(Cgi cgi) {
} else { val = false; }
return val;
}
- cv.db_selected = set_value("selected_db", _cfg.filename_db); // selected_db_name == db (spine.search.db or whatever)
+ cv.db_selected = set_value("selected_db", _cfg.db_sqlite_filename); // selected_db_name == db (spine.search.db or whatever)
cv.sql_match_limit = set_value("sml", "1000");
cv.sql_match_offset = set_value("smo", "0");
cv.search_text = set_value("sf", "");
@@ -1562,6 +1562,9 @@ void cgi_function_intro(Cgi cgi) {
// }
}
{ // debug cgi info:
+ // cgi.write("db with path: " ~ conf.db_path ~ "/" ~ cv.db_selected ~ "<br>\n");
+ // cgi.write("http url: " ~ conf.http_url ~ "<br>\n");
+ // cgi.write("query base url: " ~ conf.query_base_url ~ "<br>\n");
// cgi.write("db_selected: " ~ cv.db_selected ~ "<br>\n");
// cgi.write("search_text: " ~ cv.search_text ~ "<br>\n");
// cgi.write("sql_match_limit: " ~ cv.sql_match_limit ~ ";\n");
@@ -1575,7 +1578,7 @@ void cgi_function_intro(Cgi cgi) {
// cgi.write("cv.checked_sql: " ~ (cv.checked_sql ? "checked" : "off") ~ "<br>\n");
}
}
- auto db = Database(conf.db_path ~ cv.db_selected);
+ auto db = Database(conf.db_path ~ "/" ~ cv.db_selected);
{
uint sql_match_offset_counter(T)(T cv) {
sql_match_offset_count += cv.sql_match_limit.to!uint;
diff --git a/sundry/spine_search_cgi/src/spine_search.d_ b/sundry/spine_search_cgi/src/spine_search.d_
index 5907b73..fca2b2b 100755
--- a/sundry/spine_search_cgi/src/spine_search.d_
+++ b/sundry/spine_search_cgi/src/spine_search.d_
@@ -72,26 +72,27 @@ void cgi_function_intro(Cgi cgi) {
string web_doc_root_path;
string doc_collection_sub_root;
string cgi_root;
- string cgi_script;
+ string cgi_script_name;
string data_path_html;
- string db_path;
- string query_string;
string http_url;
+ string query_base_url;
+ string query_string;
string request_method;
- string query_base;
+ string db_path;
}
auto conf = Config();
conf.http_request_type = environment.get("REQUEST_SCHEME", _cfg.http_request_type);
- conf.http_host = environment.get("HTTP_HOST", _cfg.http_host);
- conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", _cfg.doc_root_www);
+ conf.http_host = environment.get("SERVER_NAME", _cfg.http_host);
+ // conf.http_host = environment.get("HTTP_HOST", _cfg.http_host);
+ conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", _cfg.www_doc_root);
conf.doc_collection_sub_root = "/spine/static"; // (output_path - web_doc_root_path)
- conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", _cfg.host_cgi_subpath);
- conf.cgi_script = environment.get("SCRIPT_NAME", _cfg.filename_cgi);
+ conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", _cfg.cgi_bin_subpath);
+ conf.cgi_script_name = environment.get("SCRIPT_NAME", _cfg.cgi_filename);
+ conf.query_base_url = conf.http_request_type ~ "://" ~ conf.http_host ~ "/" ~ conf.cgi_script_name ~ "?";
conf.query_string = environment.get("QUERY_STRING", "");
- conf.db_path = _cfg.doc_root_db;
+ conf.http_url = environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string);
conf.request_method = environment.get("REQUEST_METHOD", "POST");
- conf.query_base = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?";
- conf.http_url = environment.get("HTTP_REFERER", conf.query_base ~ conf.query_string);
+ conf.db_path = _cfg.db_sqlite_path;
struct CGI_val {
string db_selected = "";
string sql_match_limit = ""; // radio: ( 1000 | 2500 )
@@ -106,7 +107,7 @@ void cgi_function_intro(Cgi cgi) {
bool checked_sql = false;
}
auto cv = CGI_val();
- cv.db_selected = _cfg.filename_db;
+ cv.db_selected = _cfg.db_sqlite_filename;
auto text_fields() {
string canned_query_str = environment.get("QUERY_STRING", "");
if ("query_string" in cgi.post) {
@@ -445,9 +446,9 @@ void cgi_function_intro(Cgi cgi) {
string canned_url () {
string _url = "";
if (environment.get("REQUEST_METHOD", "POST") == "POST") {
- _url = conf.query_base ~ tf.canned_query;
+ _url = conf.query_base_url ~ tf.canned_query;
} else if (environment.get("REQUEST_METHOD", "POST") == "GET") {
- _url = conf.query_base ~ environment.get("QUERY_STRING", "");
+ _url = conf.query_base_url ~ environment.get("QUERY_STRING", "");
}
return _url;
}
@@ -517,7 +518,7 @@ void cgi_function_intro(Cgi cgi) {
_set_offset_previous = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int - cv.sql_match_limit.to!int).to!string;
_url_previous = _url.replace(rgx.track_offset, _set_offset_previous);
}
- } else {// _current_offset_value = 0;
+ } else { // _current_offset_value = 0;
_url_next = _url ~= "&smo=" ~ cv.sql_match_limit.to!string;
}
if (_url_previous.empty) {
@@ -1413,9 +1414,9 @@ void cgi_function_intro(Cgi cgi) {
string _the_can = "";
if (show_the_can == "checked") {
tf = text_fields;
- string method_get_url = conf.query_base ~ environment.get("QUERY_STRING", "");
- string method_post_url_construct = conf.query_base ~ tf.canned_query;
- // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base ~ conf.query_string));
+ string method_get_url = conf.query_base_url ~ environment.get("QUERY_STRING", "");
+ string method_post_url_construct = conf.query_base_url ~ tf.canned_query;
+ // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string));
if (conf.request_method == "POST") {
_the_can =
"<font size=\"2\" color=\"#666666\">"
@@ -1436,7 +1437,7 @@ void cgi_function_intro(Cgi cgi) {
~ method_get_url
~ "</a></font>";
}
- conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query;
+ conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script_name ~ tf.canned_query;
}
return _the_can;
}
@@ -1502,7 +1503,7 @@ void cgi_function_intro(Cgi cgi) {
</table>
</form>
┃",
- _cfg.filename_cgi,
+ _cfg.cgi_filename,
(post_value("ec") == "checked") ? post_value("sf", "field") : "",
provide_tip,
search_note,
@@ -1538,7 +1539,7 @@ void cgi_function_intro(Cgi cgi) {
} else { val = false; }
return val;
}
- cv.db_selected = set_value("selected_db", _cfg.filename_db); // selected_db_name == db (spine.search.db or whatever)
+ cv.db_selected = set_value("selected_db", _cfg.db_sqlite_filename); // selected_db_name == db (spine.search.db or whatever)
cv.sql_match_limit = set_value("sml", "1000");
cv.sql_match_offset = set_value("smo", "0");
cv.search_text = set_value("sf", "");
@@ -1563,6 +1564,9 @@ void cgi_function_intro(Cgi cgi) {
// }
}
{ // debug cgi info:
+ // cgi.write("db with path: " ~ conf.db_path ~ "/" ~ cv.db_selected ~ "<br>\n");
+ // cgi.write("http url: " ~ conf.http_url ~ "<br>\n");
+ // cgi.write("query base url: " ~ conf.query_base_url ~ "<br>\n");
// cgi.write("db_selected: " ~ cv.db_selected ~ "<br>\n");
// cgi.write("search_text: " ~ cv.search_text ~ "<br>\n");
// cgi.write("sql_match_limit: " ~ cv.sql_match_limit ~ ";\n");
@@ -1576,7 +1580,7 @@ void cgi_function_intro(Cgi cgi) {
// cgi.write("cv.checked_sql: " ~ (cv.checked_sql ? "checked" : "off") ~ "<br>\n");
}
}
- auto db = Database(conf.db_path ~ cv.db_selected);
+ auto db = Database(conf.db_path ~ "/" ~ cv.db_selected);
{
uint sql_match_offset_counter(T)(T cv) {
sql_match_offset_count += cv.sql_match_limit.to!uint;
diff --git a/sundry/spine_search_cgi/views/configuration.txt b/sundry/spine_search_cgi/views/configuration.txt
index bd3c7ad..0138149 100644
--- a/sundry/spine_search_cgi/views/configuration.txt
+++ b/sundry/spine_search_cgi/views/configuration.txt
@@ -1,13 +1,12 @@
struct Cfg {
- string http_request_type = "http";
- string http_host = "localhost";
- string doc_root_www = "/srv/www/spine/static";
- string doc_root_cgi = "/var/www/cgi/cgi-bin/";
- string doc_root_db = "/srv/www/spine/static/sqlite/";
- string host_cgi_subpath = "/cgi-bin";
- // string subpath_cgi = "/cgi-bin/";
- string filename_cgi = "spine_search";
- string cgi_script_filename_with_any_subpath = "/cgi-bin/spine_search";
- string filename_db = "spine.search.db";
+ string http_request_type = "http";
+ string http_host = "localhost";
+ string www_url_doc_root = "http://localhost";
+ string www_doc_root = "/srv/www/spine/static"; // "/var/www/html"
+ string cgi_bin_root = "/var/www/cgi/cgi-bin/"; // "/usr/lib/cgi-bin"
+ string cgi_bin_subpath = "/cgi-bin";
+ string cgi_filename = "spine_search"; // "spine-search"
+ string db_sqlite_path = "/var/www/sqlite";
+ string db_sqlite_filename = "spine.search.db";
}
enum _cfg = Cfg();
diff --git a/sundry/spine_search_cgi/views/configuration_suggested.txt b/sundry/spine_search_cgi/views/configuration_suggested.txt
index 028cfc9..c66da03 100644
--- a/sundry/spine_search_cgi/views/configuration_suggested.txt
+++ b/sundry/spine_search_cgi/views/configuration_suggested.txt
@@ -1,14 +1,13 @@
/+ obt - org-mode generated file +/
struct Cfg {
- string http_request_type = "http";
- string http_host = "localhost";
- string doc_root_www = "/srv/www/spine/static";
- string doc_root_cgi = "/var/www/cgi/cgi-bin/";
- string doc_root_db = "/srv/www/spine/static/sqlite/";
- string host_cgi_subpath = "/cgi-bin";
- // string subpath_cgi = "/cgi-bin/";
- string filename_cgi = "spine_search";
- string cgi_script_filename_with_any_subpath = "/cgi-bin/spine_search";
- string filename_db = "spine.search.db";
+ string http_request_type = "http";
+ string http_host = "localhost";
+ string www_url_doc_root = "http://localhost";
+ string www_doc_root = "/srv/www/spine/static"; // "/var/www/html"
+ string cgi_bin_root = "/var/www/cgi/cgi-bin/"; // "/usr/lib/cgi-bin"
+ string cgi_bin_subpath = "/cgi-bin";
+ string cgi_filename = "spine_search"; // "spine-search"
+ string db_sqlite_path = "/var/www/sqlite";
+ string db_sqlite_filename = "spine.search.db";
}
enum _cfg = Cfg();