From d39da3f07036b22892ffb0b05737e8ba7e1ff954 Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph.amissah@gmail.com>
Date: Fri, 28 Jan 2022 10:38:10 -0500
Subject: config & sqlite search output, some changes

---
 src/doc_reform/io_in/read_config_files.d       | 34 +++++++++++++-------------
 src/doc_reform/io_out/cgi_sqlite_search_form.d | 18 +++++++-------
 src/doc_reform/io_out/sqlite.d                 | 11 +++++++++
 src/doc_reform/meta/conf_make_meta_yaml.d      | 15 ++++++------
 4 files changed, 45 insertions(+), 33 deletions(-)

(limited to 'src')

diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d
index 0d50be3..c112d1e 100644
--- a/src/doc_reform/io_in/read_config_files.d
+++ b/src/doc_reform/io_in/read_config_files.d
@@ -102,23 +102,23 @@ webserv:
   db_pg_table:           ""
   db_pg_user:            ""
 ┃",
-  _cfg.www_doc_root,          // doc root
-  _cfg.www_http,              // http
-  _cfg.www_host,              // host / domain
-  _cfg.www_http,              // data "http" or "https"
-  _cfg.www_host,              // data domain "localhost"
-  _cfg.www_url_doc_root,      // data root url "http://locahost" "https://sisudoc.org"
-  _cfg.www_doc_root,          // data root path
-  _cfg.cgi_search_form_title, // cgi title // e.g. "≅ SiSU Spine search"
-  _cfg.www_http,              // cgi http
-  _cfg.www_host,              // cgi host
-  _cfg.cgi_url_root,          // cgi bin url
-  _cfg.cgi_bin_subpath,       // cgi bin path
-  _cfg.cgi_bin_root,          // cgi bin path
-  _cfg.cgi_filename,          // cgi filename
-  _cfg.cgi_url_action,        // cgi action
-  _cfg.db_sqlite_path,        // sqlite db path
-  _cfg.db_sqlite_filename,    // sqlite db filename
+  _cfg.processing_path_doc_root, // doc root
+  _cfg.http_request_type,        // http
+  _cfg.http_host,                // host / domain
+  _cfg.http_request_type,        // data "http" or "https"
+  _cfg.http_host,                // data domain "localhost"
+  _cfg.www_url_doc_root,         // data root url "http://locahost" "https://sisudoc.org"
+  _cfg.processing_path_doc_root, // data root path
+  _cfg.cgi_search_form_title,    // cgi title // e.g. "≅ SiSU Spine search"
+  _cfg.http_request_type,        // cgi http
+  _cfg.http_host,                // cgi host
+  _cfg.cgi_url_root,             // cgi bin url
+  _cfg.cgi_bin_subpath,          // cgi bin path
+  _cfg.cgi_bin_root,             // cgi bin path
+  _cfg.cgi_filename,             // cgi filename
+  _cfg.cgi_url_action,           // cgi action
+  _cfg.db_sqlite_path,           // sqlite db path
+  _cfg.db_sqlite_filename,       // sqlite db filename
 );
     foreach(conf_fn; [_conf_file_details.config_filename_site]) {
       foreach(pth; _conf_file_details.possible_config_path_locations.config_local_site) {
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 091c77f..e835b07 100644
--- a/src/doc_reform/io_out/cgi_sqlite_search_form.d
+++ b/src/doc_reform/io_out/cgi_sqlite_search_form.d
@@ -64,7 +64,7 @@ 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 get_doc_collection_subroot(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;
@@ -89,7 +89,7 @@ void cgi_function_intro(Cgi cgi) {
     string http_host;
     // string server_name;
     string web_doc_root_path;
-    string doc_collection_sub_root;
+    string doc_collection_subroot;
     string cgi_root;
     string cgi_script;
     string data_path_html;
@@ -103,7 +103,7 @@ void cgi_function_intro(Cgi cgi) {
   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.doc_collection_subroot = "%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",          "");
@@ -1736,7 +1736,7 @@ LIMIT %%s OFFSET %%s
               _close_para
               ~ "<hr><div class=\"publication\">"
                 ~ "<p class=\"publication\"><a href=\""
-                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/"
+                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/"
                   ~ row["language_document_char"].as!string ~ "/html/"
                   ~ row["src_filename_base"].as!string ~ "/"
                   ~ "toc.html"
@@ -1758,7 +1758,7 @@ LIMIT %%s OFFSET %%s
                 "<div class=\"flex-container\">"
                 ~ "<div class=\"textview_ocn\" style=\"flex: 0 0 1.2em\">"
                   ~ "<p class=\"ocn_is\"><a href=\""
-                    ~ "https://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/"
+                    ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/"
                     ~ row["language_document_char"].as!string ~ "/html/"
                     ~ row["src_filename_base"].as!string ~ "/"
                     ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string
@@ -1776,7 +1776,7 @@ LIMIT %%s OFFSET %%s
                 "<div class=\"flex-container\">"
                 ~ "<div class=\"textview_ocn\" style=\"flex: 0 0 1.2em\">"
                   ~ "<p class=\"ocn_is\"><a href=\""
-                    ~ "https://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/"
+                    ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/"
                     ~ row["language_document_char"].as!string ~ "/html/"
                     ~ row["src_filename_base"].as!string ~ "/toc.html"
                   ~ "\">"
@@ -1794,7 +1794,7 @@ LIMIT %%s OFFSET %%s
               cgi.write(
                 _matched_ocn_open
                 ~ "<a href=\""
-                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/"
+                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/"
                   ~ row["language_document_char"].as!string ~ "/html/"
                   ~ row["src_filename_base"].as!string ~ "/"
                   ~ row["seg_name"].as!string ~ ".html#" ~ row["ocn"].as!string
@@ -1806,7 +1806,7 @@ LIMIT %%s OFFSET %%s
               cgi.write(
                 _matched_ocn_open
                 ~ "<a href=\""
-                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_sub_root ~ "/"
+                  ~ "https://" ~ conf.http_host ~ conf.doc_collection_subroot ~ "/"
                   ~ row["language_document_char"].as!string ~ "/html/"
                   ~ row["src_filename_base"].as!string ~ "/toc.html"
                 ~ "\">"
@@ -1844,7 +1844,7 @@ LIMIT %%s OFFSET %%s
 }
 mixin GenericMain!cgi_function_intro;
 ≓",
-  get_doc_collection_sub_root(make_and_meta_struct.conf.output_path),
+  get_doc_collection_subroot(make_and_meta_struct.conf.output_path),
   make_and_meta_struct.conf.output_path ~ "/sqlite/",
   _sqlite_db_fn,
   (opt_action.cgi_search_title.empty)
diff --git a/src/doc_reform/io_out/sqlite.d b/src/doc_reform/io_out/sqlite.d
index 60f6569..4281609 100644
--- a/src/doc_reform/io_out/sqlite.d
+++ b/src/doc_reform/io_out/sqlite.d
@@ -468,6 +468,17 @@ template SQLiteFormatAndLoadObject() {
               obj.text
             );
           }
+          // if (obj.metainfo.is_a == "bookindex") { // DEBUG LINE
+          //   if (_txt.match(regex(r"<a href"))) {
+          //     writeln(__LINE__, " ",
+          //       doc_matters.conf_make_meta.conf.w_srv_data_root_url_html,
+          //       "/",
+          //       doc_matters.src.filename_base,
+          //       "\n",
+          //       _txt
+          //     );
+          //   }
+          // }
         }
         debug(markup) {
           if (_txt.match(rgx.inline_link)) {
diff --git a/src/doc_reform/meta/conf_make_meta_yaml.d b/src/doc_reform/meta/conf_make_meta_yaml.d
index e2f4c43..af6096a 100644
--- a/src/doc_reform/meta/conf_make_meta_yaml.d
+++ b/src/doc_reform/meta/conf_make_meta_yaml.d
@@ -94,9 +94,9 @@ template contentYAMLtoSpineStruct() {
             = _opt_action.webserver_http;
         } else {
           _struct_composite.conf.w_srv_http
-            = (_cfg.www_http.empty)
+            = (_cfg.http_request_type.empty)
               ? "http"
-              : _cfg.www_http;
+              : _cfg.http_request_type;
           if (("webserv" in _yaml && _yaml["webserv"].type.sequence)
             && (_yaml["webserv"].type.mapping
               && _yaml["webserv"].tag.match(rgx.yaml_tag_is_map))
@@ -226,9 +226,9 @@ template contentYAMLtoSpineStruct() {
               = (_opt_action.output_dir_set.asNormalizedPath).array;
           } else {
             _struct_composite.conf.output_path
-              = (_cfg.www_doc_root.empty)
+              = (_cfg.processing_path_doc_root.empty)
                 ?  "/srv/www/spine"
-                : _cfg.www_doc_root;
+                : _cfg.processing_path_doc_root;
             if (("webserv" in _yaml && _yaml["webserv"].type.sequence)
               && (_yaml["webserv"].type.mapping
                 && _yaml["webserv"].tag.match(rgx.yaml_tag_is_map))
@@ -254,9 +254,9 @@ template contentYAMLtoSpineStruct() {
               = _opt_action.webserver_host_doc_root;
           } else {
             _struct_composite.conf.w_srv_data_root_path
-              = (_cfg.www_doc_root.empty)
+              = (_cfg.processing_path_doc_root.empty)
                 ? "/var/www/spine"
-                : _cfg.www_doc_root;
+                : _cfg.processing_path_doc_root;
             if (("webserv" in _yaml && _yaml["webserv"].type.sequence)
               && (_yaml["webserv"].type.mapping
                 && _yaml["webserv"].tag.match(rgx.yaml_tag_is_map))
@@ -352,7 +352,8 @@ template contentYAMLtoSpineStruct() {
           ) {
             _struct_composite.conf.w_srv_data_root_url      = _yaml["webserv"]["data_root_url"].get!string;
             _struct_composite.conf.w_srv_data_root_url_html =
-              _yaml["webserv"]["data_root_url"].get!string ~ "/"
+              _yaml["webserv"]["data_root_url"].get!string
+              ~ _struct_composite.conf.w_srv_data_root_part ~ "/"
               ~ _manifested.src.language ~ "/"
               ~ "html";
           } else {
-- 
cgit v1.2.3