diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2020-04-19 11:00:01 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2020-05-20 11:27:26 -0400 |
commit | 6ebf986a81ea36bd3e79fb13f1e9f1ff940d5a45 (patch) | |
tree | da2d17855a0a69c269dc6b2d3fb17646ac6629f9 /org | |
parent | cli precedence over config file settings (diff) |
cgi search form, document sub-root path
- (doc_output_root_path - web_doc_root_path) which added to url host provides
document path
Diffstat (limited to 'org')
-rw-r--r-- | org/out_cgi_search_sqlite.org | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/org/out_cgi_search_sqlite.org b/org/out_cgi_search_sqlite.org index 852b93f..4f3ccad 100644 --- a/org/out_cgi_search_sqlite.org +++ b/org/out_cgi_search_sqlite.org @@ -83,6 +83,11 @@ template CGIsearchSQLite() { string _cgi_search_script_raw_fn_d = (opt_action.cgi_sqlite_search_filename_d.empty) ? make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d : opt_action.cgi_sqlite_search_filename_d; + string get_doc_collection_sub_root(string output_path) { + string web_doc_root_path = environment.get("DOCUMENT_ROOT", "/var/www/html"); + auto m = output_path.matchFirst(regex("^(" ~ web_doc_root_path ~ ")")); + return m.post; + } string the_cgi_search_form = format(q"≓ <<cgi_sqlite_head>> <<cgi_sqlite_imports>> @@ -114,6 +119,8 @@ void cgi_function_intro(Cgi cgi) { } mixin GenericMain!cgi_function_intro; ≓", + get_doc_collection_sub_root(make_and_meta_struct.conf.output_path), + make_and_meta_struct.conf.output_path ~ "/sqlite/", _sqlite_db_fn, (opt_action.css_theme_default) ? "FFFFFF" : "000000", (opt_action.css_theme_default) ? "000000" : "CCCCCC", @@ -134,6 +141,7 @@ mixin GenericMain!cgi_function_intro; (opt_action.css_theme_default) ? "FFFF48" : "777748", (opt_action.css_theme_default) ? "222222" : "AAAAAA", _cgi_search_script, + _sqlite_db_fn, ).strip; string _cgi_path = (opt_action.output_dir_set.length > 0) ? opt_action.output_dir_set @@ -245,7 +253,8 @@ struct Config { string http_request_type; string http_host; // string server_name; - string doc_root; + string web_doc_root_path; + string doc_collection_sub_root; string cgi_root; string cgi_script; string data_path_html; @@ -255,16 +264,17 @@ struct Config { string request_method; } auto conf = Config(); -conf.http_request_type = environment.get("REQUEST_SCHEME", "http"); -conf.http_host = environment.get("HTTP_HOST", "localhost"); -// conf.server_name = environment.get("SERVER_NAME", "localhost"); -conf.doc_root = environment.get("DOCUMENT_ROOT", "/var/www/html"); -conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", "/usr/lib/cgi-bin/"); -// conf.cgi_script = environment.get("SCRIPT_NAME", "/cgi-bin/spine-search"); -conf.query_string = environment.get("QUERY_STRING", ""); -conf.http_url = environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string); -conf.db_path = "/var/www/html/sqlite/"; // conf.http_host ~ "/sqlite/"; -conf.request_method = environment.get("REQUEST_METHOD", "POST"); +conf.http_request_type = environment.get("REQUEST_SCHEME", "http"); +conf.http_host = environment.get("HTTP_HOST", "localhost"); +// conf.server_name = environment.get("SERVER_NAME", "localhost"); +conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", "/var/www/html"); +conf.doc_collection_sub_root = "%s"; // (output_path - web_doc_root_path) +conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", "/usr/lib/cgi-bin/"); +// conf.cgi_script = environment.get("SCRIPT_NAME", "/cgi-bin/spine-search"); +conf.query_string = environment.get("QUERY_STRING", ""); +conf.http_url = environment.get("HTTP_REFERER", conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?" ~ conf.query_string); +conf.db_path = "%s"; // (output_path + /sqlite) +conf.request_method = environment.get("REQUEST_METHOD", "POST"); #+END_SRC # REQUEST_URI QUERY_STRING @@ -1518,11 +1528,11 @@ string show_matched_objects (string fn) { } else { val = false; } return val; } - cv.db_selected = set_value("selected_db", "spine.search.db"); // selected_db == db - cv.sql_match_limit = set_value("sml", "1000"); - cv.sql_match_offset = set_value("smo", "0"); - cv.search_text = set_value("sf", ""); - cv.results_type = set_value("rt", "idx"); + cv.db_selected = set_value("selected_db", "%s"); // 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", ""); + cv.results_type = set_value("rt", "idx"); cv.checked_echo = set_bool("ec"); cv.checked_stats = set_bool("sts"); cv.checked_url = set_bool("url"); @@ -1719,7 +1729,7 @@ LIMIT %%s OFFSET %%s auto m = (row["date_published"].as!string).match(regex(r"^([0-9]{4})")); // breaks if row missing or no match? cgi.write( "<hr><a href=\"" - ~ "http://" ~ conf.http_host ~ "/" + ~ "http://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/" ~ row["language_document_char"].as!string ~ "/html/" ~ row["src_filename_base"].as!string ~ "/" ~ "toc.html" @@ -1747,7 +1757,7 @@ LIMIT %%s OFFSET %%s if (row["ocn"].as!string != "0") { cgi.write( "<hr><a href=\"" - ~ "http://" ~ conf.http_host ~ "/" + ~ "http://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/" ~ row["language_document_char"].as!string ~ "/html/" ~ row["src_filename_base"].as!string ~ "/" ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string @@ -1760,7 +1770,7 @@ LIMIT %%s OFFSET %%s } else { cgi.write( "<hr><a href=\"" - ~ "http://" ~ conf.http_host ~ "/" + ~ "http://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/" ~ row["language_document_char"].as!string ~ "/html/" ~ row["src_filename_base"].as!string ~ "/toc.html" ~ "\">" @@ -1780,7 +1790,7 @@ LIMIT %%s OFFSET %%s if (row["ocn"].as!string != "0") { cgi.write( "<a href=\"" - ~ "http://" ~ conf.http_host ~ "/" + ~ "http://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/" ~ row["language_document_char"].as!string ~ "/html/" ~ row["src_filename_base"].as!string ~ "/" ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string @@ -1791,7 +1801,7 @@ LIMIT %%s OFFSET %%s } else { cgi.write( "<a href=\"" - ~ "http://" ~ conf.http_host ~ "/" + ~ "http://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/" ~ row["language_document_char"].as!string ~ "/html/" ~ row["src_filename_base"].as!string ~ "/toc.html" ~ "\">" |