aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/cgi_spine_search.org
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 /org/cgi_spine_search.org
parentspine_search (work on) (diff)
spine search and configuration related
Diffstat (limited to 'org/cgi_spine_search.org')
-rw-r--r--org/cgi_spine_search.org97
1 files changed, 29 insertions, 68 deletions
diff --git a/org/cgi_spine_search.org b/org/cgi_spine_search.org
index 0168f66..b695783 100644
--- a/org/cgi_spine_search.org
+++ b/org/cgi_spine_search.org
@@ -20,34 +20,6 @@
[[./spine_build_scaffold.org][make/build]] VERSION
* 0. version.txt configuration.txt (set version & configuration)
-** set configuration tangle SET :configuration:
-
-##+HEADER: :tangle "../views/configuration_suggested.txt"
-#+BEGIN_SRC d
-/+ obt - org-mode generated file +/
-struct Cfg {
- string www_http = "http";
- string www_doc_root = "/srv/www/spine/static"; // "/var/www/html"
- string www_domain = "localhost";
- string www_domain_doc_root = "localhost";
- string www_url_doc_root = "http://localhost";
- string cgi_bin_root = "/var/www/cgi/cgi-bin/"; // "/usr/lib/cgi-bin"
- string cgi_bin_part = "cgi-bin";
- string cgi_filename = "spine_search"; // "spine-search"
- string cgi_url_root = "http://localhost/cgi-bin";
- string cgi_port = "";
- string cgi_user = "";
- string cgi_url_action = "http://localhost/cgi-bin/spine_search";
- string cgi_title = "≅ SiSU Spine search";
- string db_sqlite_doc_root = "/srv/www/spine/static/sqlite/";
- string db_sqlite_filename = "spine.search.db";
- string default_language = "en";
- string default_papersize = "a4";
- string default_text_wrap = "80";
- string default_hash_digest = "sha256";
-}
-enum _cfg = Cfg();
-#+END_SRC
** program version struct
@@ -108,7 +80,7 @@ void cgi_function_intro(Cgi cgi) {
<<spine_search_init_1>>
<<spine_search_config>>
<<spine_search_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) {
@@ -140,9 +112,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;
}
@@ -204,7 +176,7 @@ void cgi_function_intro(Cgi cgi) {
// <<spine_search_debug_info>>
}
}
- 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;
@@ -270,21 +242,24 @@ uint sql_match_offset_count = 0;
**** config
+see: cfte_configuation.org
+
#+NAME: spine_search_config
#+BEGIN_SRC d
<<spine_search_config_struct>>
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 = "<<doc_subroot_path>>"; // (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;
#+END_SRC
#+NAME: spine_search_config_struct
@@ -296,13 +271,13 @@ struct Config {
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;
}
#+END_SRC
@@ -654,7 +629,6 @@ if (environment.get("REQUEST_METHOD", "POST") == "POST") {
}
#+END_SRC
-
**** show_matched_objects (string fn) {}
#+NAME: spine_search_show_matched_objects
@@ -832,9 +806,9 @@ string show_the_can = post_value("url");
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\">"
@@ -855,7 +829,7 @@ if (show_the_can == "checked") {
~ 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;
#+END_SRC
@@ -901,7 +875,7 @@ return tip;
form = format(q"┃
<<spine_search_form_html>>
┃",
- _cfg.filename_cgi,
+ _cfg.cgi_filename,
(post_value("ec") == "checked") ? post_value("sf", "field") : "",
provide_tip,
search_note,
@@ -984,7 +958,7 @@ return val;
#+NAME: spine_search_set_selections
#+BEGIN_SRC d
-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", "");
@@ -1268,6 +1242,9 @@ if (!select_query_results.empty) {
#+NAME: spine_search_debug_info
#+BEGIN_SRC d
+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");
@@ -2114,28 +2091,12 @@ _cfg.doc_root_cgi
_cfg.doc_root_db
#+END_SRC
#+BEGIN_SRC text
-<<url_doc_root>>/spine/static/sqlite/
+/var/www/sqlite/
#+END_SRC
*** spine_search configuration.txt
-#+HEADER: :tangle "../sundry/spine_search_cgi/views/configuration_suggested.txt"
-#+BEGIN_SRC d
-/+ 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";
-}
-enum _cfg = Cfg();
-#+END_SRC
+see configuration_cfte.org
*** document header including copyright & license