aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/io_out
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2020-04-19 11:00:01 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2020-05-20 11:27:26 -0400
commit6ebf986a81ea36bd3e79fb13f1e9f1ff940d5a45 (patch)
treeda2d17855a0a69c269dc6b2d3fb17646ac6629f9 /src/doc_reform/io_out
parentcli 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 'src/doc_reform/io_out')
-rw-r--r--src/doc_reform/io_out/cgi_sqlite_search_form.d52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/doc_reform/io_out/cgi_sqlite_search_form.d b/src/doc_reform/io_out/cgi_sqlite_search_form.d
index 7bfd5ef..145203f 100644
--- a/src/doc_reform/io_out/cgi_sqlite_search_form.d
+++ b/src/doc_reform/io_out/cgi_sqlite_search_form.d
@@ -14,6 +14,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"≓
/+ dub.sdl
name "spine search"
@@ -33,7 +38,8 @@ void cgi_function_intro(Cgi cgi) {
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;
@@ -43,16 +49,17 @@ void cgi_function_intro(Cgi cgi) {
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");
struct CGI_val {
string db_selected = "";
string sql_match_limit = ""; // radio: ( 1000 | 2500 )
@@ -1180,11 +1187,11 @@ void cgi_function_intro(Cgi cgi) {
} 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");
@@ -1347,7 +1354,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"
@@ -1369,7 +1376,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
@@ -1382,7 +1389,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"
~ "\">"
@@ -1396,7 +1403,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
@@ -1407,7 +1414,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"
~ "\">"
@@ -1436,6 +1443,8 @@ LIMIT %%s OFFSET %%s
}
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",
@@ -1456,6 +1465,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