From eed0938b23d13ec4f2ef4588ccdb2e7abc0c1552 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 29 Mar 2020 18:29:44 -0400 Subject: 0.10.0 search sqlite & cgi --- src/doc_reform/meta/conf_make_meta_json.d | 26 ++--- src/doc_reform/meta/conf_make_meta_structs.d | 35 ++++-- src/doc_reform/meta/conf_make_meta_yaml.d | 166 ++++++++++++++++++++++----- src/doc_reform/meta/defaults.d | 2 +- src/doc_reform/meta/metadoc.d | 6 + src/doc_reform/meta/metadoc_show_config.d | 44 ++++--- 6 files changed, 208 insertions(+), 71 deletions(-) (limited to 'src/doc_reform/meta') diff --git a/src/doc_reform/meta/conf_make_meta_json.d b/src/doc_reform/meta/conf_make_meta_json.d index a6214ce..23b9631 100644 --- a/src/doc_reform/meta/conf_make_meta_json.d +++ b/src/doc_reform/meta/conf_make_meta_json.d @@ -199,49 +199,49 @@ static template contentJSONtoSpineStruct() { } /+ conf ------------------------------------------------------------------- +/ if ("webserv" in _json.object) { - if ("url_root" in _json.object["webserv"] - && (_json.object["webserv"]["url_root"].type().to!string == "string") + if ("data_root_url" in _json.object["webserv"] + && (_json.object["webserv"]["data_root_url"].type().to!string == "string") ) { - _struct_composite.conf.webserv_url_doc_root = _json.object["webserv"]["url_root"].str; - if (auto m = _struct_composite.conf.webserv_url_doc_root.match(rgx.webserv_url_doc_root)) { - _struct_composite.conf.webserv_url_domain = m.captures[2].to!string; - _struct_composite.conf.webserv_url_doc_path = m.captures[3].to!string; + _struct_composite.conf.w_srv_data_root_url = _json.object["webserv"]["data_root_url"].str; + if (auto m = _struct_composite.conf.w_srv_data_root_url.match(rgx.webserv_data_root_url)) { + _struct_composite.conf.w_srv_url_domain = m.captures[2].to!string; + _struct_composite.conf.w_srv_url_doc_path = m.captures[3].to!string; } } if ("images" in _json.object["webserv"] && (_json.object["webserv"]["images"].type().to!string == "string") ) { - _struct_composite.conf.webserv_images = _json.object["webserv"]["images"].str; + _struct_composite.conf.w_srv_images = _json.object["webserv"]["images"].str; } if ("cgi" in _json.object["webserv"] && (_json.object["webserv"]["cgi"].type().to!string == "string") ) { - _struct_composite.conf.webserv_cgi = _json.object["webserv"]["cgi"].str; + _struct_composite.conf.w_srv_cgi = _json.object["webserv"]["cgi"].str; } if ("cgi_host" in _json.object["webserv"] && (_json.object["webserv"]["cgi_host"].type().to!string == "string") ) { - _struct_composite.conf.webserv_cgi_host = _json.object["webserv"]["cgi_host"].str; + _struct_composite.conf.w_srv_cgi_host = _json.object["webserv"]["cgi_host"].str; } if ("cgi_host_path" in _json.object["webserv"] && (_json.object["webserv"]["cgi_host_path"].type().to!string == "string") ) { - _struct_composite.conf.webserv_cgi_host_path = _json.object["webserv"]["cgi_host_path"].str; + _struct_composite.conf.w_srv_cgi_host_path = _json.object["webserv"]["cgi_host_path"].str; } if ("cgi_port" in _json.object["webserv"] && (_json.object["webserv"]["cgi_port"].type().to!string == "string") ) { - _struct_composite.conf.webserv_cgi_port = _json.object["webserv"]["cgi_port"].str; + _struct_composite.conf.w_srv_cgi_port = _json.object["webserv"]["cgi_port"].str; } if ("cgi_user" in _json.object["webserv"] && (_json.object["webserv"]["cgi_user"].type().to!string == "string") ) { - _struct_composite.conf.webserv_cgi_user = _json.object["webserv"]["cgi_user"].str; + _struct_composite.conf.w_srv_cgi_user = _json.object["webserv"]["cgi_user"].str; } if ("cgi_file_links" in _json.object["webserv"] && (_json.object["webserv"]["cgi_file_links"].type().to!string == "string") ) { - _struct_composite.conf.webserv_cgi_file_links = _json.object["webserv"]["cgi_file_links"].str; + _struct_composite.conf.w_srv_cgi_file_links = _json.object["webserv"]["cgi_file_links"].str; } } if ("processing" in _json.object) { diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d index 7698388..9707dab 100644 --- a/src/doc_reform/meta/conf_make_meta_structs.d +++ b/src/doc_reform/meta/conf_make_meta_structs.d @@ -141,16 +141,31 @@ struct ConfCompositeMakeInit { string texpdf_font; } struct ConfCompositeSiteLocal { - string webserv_url_doc_root; - string webserv_url_domain; - string webserv_url_doc_path; - string webserv_images; - string webserv_cgi; - string webserv_cgi_host; - string webserv_cgi_host_path; - string webserv_cgi_port; - string webserv_cgi_user; - string webserv_cgi_file_links; + string w_srv_http; + string w_srv_domain; + string w_srv_data_http; // if not set same as webserv_http + string w_srv_data_domain; // if not set same as webserv_domain + string w_srv_data_root_part; + string w_srv_data_root_url; + string w_srv_data_root_path; + string w_srv_images_root_part; + // string w_srv_url_doc_path; + string w_srv_cgi_title; + string w_srv_cgi_http; // if not set same as webserv_http + string w_srv_cgi_domain; // if not set same as webserv_domain + string w_srv_cgi_bin_part; + string w_srv_cgi_bin_path; + string w_srv_cgi_search_script; + string w_srv_cgi_search_script_raw_fn_d; + string w_srv_cgi_port; + string w_srv_cgi_user; + string w_srv_cgi_action; + string w_srv_cgi_bin_url; + string w_srv_db_sqlite; + // string w_srv_db_pg; + string w_srv_db_pg_table; + string w_srv_db_pg_user; + // string webserv_cgi_file_links; string output_path; string processing_path; string processing_dir; diff --git a/src/doc_reform/meta/conf_make_meta_yaml.d b/src/doc_reform/meta/conf_make_meta_yaml.d index 2efd515..1b5ec70 100644 --- a/src/doc_reform/meta/conf_make_meta_yaml.d +++ b/src/doc_reform/meta/conf_make_meta_yaml.d @@ -187,57 +187,161 @@ template contentYAMLtoSpineStruct() { if (_yaml["webserv"].type.mapping && _yaml["webserv"].tag.match(rgx.yaml_tag_is_map) ) { - if ("url_root" in _yaml["webserv"] - && _yaml["webserv"]["url_root"].type.string - && _yaml["webserv"]["url_root"].tag.match(rgx.yaml_tag_is_str) - ) { - _struct_composite.conf.webserv_url_doc_root = _yaml["webserv"]["url_root"].get!string; - if (auto m = _struct_composite.conf.webserv_url_doc_root.match(rgx.webserv_url_doc_root)) { - _struct_composite.conf.webserv_url_domain = m.captures[2].to!string; - _struct_composite.conf.webserv_url_doc_path = m.captures[3].to!string; - } + if ("http" in _yaml["webserv"] + && _yaml["webserv"]["http"].type.string + && _yaml["webserv"]["http"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_http = _yaml["webserv"]["http"].get!string; + } // else { set default? } + if ("data_http" in _yaml["webserv"] + && _yaml["webserv"]["data_http"].type.string + && _yaml["webserv"]["data_http"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_http = _yaml["webserv"]["data_http"].get!string; + } + if ("cgi_http" in _yaml["webserv"] + && _yaml["webserv"]["cgi_http"].type.string + && _yaml["webserv"]["cgi_http"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_http = _yaml["webserv"]["cgi_http"].get!string; + } + if ("domain" in _yaml["webserv"] + && _yaml["webserv"]["domain"].type.string + && _yaml["webserv"]["domain"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_domain = _yaml["webserv"]["domain"].get!string; + } + // if ("data_root_url" in _yaml["webserv"] + // && _yaml["webserv"]["data_root_url"].type.string + // && _yaml["webserv"]["data_root_url"].tag.match(rgx.yaml_tag_is_str) + // ) { + // _struct_composite.conf.w_srv_data_root_url = _yaml["webserv"]["data_root_url"].get!string; + // if (auto m = _struct_composite.conf.w_srv_data_root_url.match(rgx.webserv_url_doc_root)) { + // _struct_composite.conf.w_srv_url_domain = m.captures[2].to!string; + // _struct_composite.conf.w_srv_url_doc_path = m.captures[3].to!string; + // } + // } + if ("data_root_path" in _yaml["webserv"] + && _yaml["webserv"]["data_root_path"].type.string + && _yaml["webserv"]["data_root_path"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_root_path = _yaml["webserv"]["data_root_path"].get!string; + } + if ("data_root_part" in _yaml["webserv"] + && _yaml["webserv"]["data_root_part"].type.string + && _yaml["webserv"]["data_root_part"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_data_root_part = _yaml["webserv"]["data_root_part"].get!string; + } + if ("images_root_part" in _yaml["webserv"] + && _yaml["webserv"]["images_root_part"].type.string + && _yaml["webserv"]["images_root_part"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_images_root_part = _yaml["webserv"]["images_root_part"].get!string; } - if ("images" in _yaml["webserv"] - && _yaml["webserv"]["images"].type.string - && _yaml["webserv"]["images"].tag.match(rgx.yaml_tag_is_str) + if ("data_root_url" in _yaml["webserv"] + && _yaml["webserv"]["data_root_url"].type.string + && _yaml["webserv"]["data_root_url"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_images = _yaml["webserv"]["images"].get!string; + _struct_composite.conf.w_srv_data_root_url = _yaml["webserv"]["data_root_url"].get!string; + } else { + _struct_composite.conf.w_srv_data_root_url = _struct_composite.conf.w_srv_data_root_part; + } + if ("cgi_domain" in _yaml["webserv"] + && _yaml["webserv"]["cgi_domain"].type.string + && _yaml["webserv"]["cgi_domain"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_domain = _yaml["webserv"]["cgi_domain"].get!string; + } else { // composite construct + _struct_composite.conf.w_srv_cgi_domain = _struct_composite.conf.w_srv_domain; } - if ("cgi" in _yaml["webserv"] - && _yaml["webserv"]["cgi"].type.string - && _yaml["webserv"]["cgi"].tag.match(rgx.yaml_tag_is_str) + if ("cgi_title" in _yaml["webserv"] + && _yaml["webserv"]["cgi_title"].type.string + && _yaml["webserv"]["cgi_title"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_cgi = _yaml["webserv"]["cgi"].get!string; + _struct_composite.conf.w_srv_cgi_title = _yaml["webserv"]["cgi_title"].get!string; } - if ("cgi_host" in _yaml["webserv"] - && _yaml["webserv"]["cgi_host"].type.string - && _yaml["webserv"]["cgi_host"].tag.match(rgx.yaml_tag_is_str) + if ("cgi_bin_part" in _yaml["webserv"] + && _yaml["webserv"]["cgi_bin_part"].type.string + && _yaml["webserv"]["cgi_bin_part"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_cgi_host = _yaml["webserv"]["cgi_host"].get!string; + _struct_composite.conf.w_srv_cgi_bin_part = _yaml["webserv"]["cgi_bin_part"].get!string; } - if ("cgi_host_path" in _yaml["webserv"] - && _yaml["webserv"]["cgi_host_path"].type.string - && _yaml["webserv"]["cgi_host_path"].tag.match(rgx.yaml_tag_is_str) + if ("cgi_bin_path" in _yaml["webserv"] + && _yaml["webserv"]["cgi_bin_path"].type.string + && _yaml["webserv"]["cgi_bin_path"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_cgi_host_path = _yaml["webserv"]["cgi_host_path"].get!string; + _struct_composite.conf.w_srv_cgi_bin_path = _yaml["webserv"]["cgi_bin_path"].get!string; + } + if ("cgi_search_script" in _yaml["webserv"] + && _yaml["webserv"]["cgi_search_script"].type.string + && _yaml["webserv"]["cgi_search_script"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_search_script = _yaml["webserv"]["cgi_search_script"].get!string; + } else { + _struct_composite.conf.w_srv_cgi_search_script = "spine-search"; + } + if ("cgi_search_script_raw_fn_d" in _yaml["webserv"] + && _yaml["webserv"]["cgi_search_script_raw_fn_d"].type.string + && _yaml["webserv"]["cgi_search_script_raw_fn_d"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_search_script_raw_fn_d = _yaml["webserv"]["cgi_search_script_raw_fn_d"].get!string; + } else if ("cgi_search_script" in _yaml["webserv"] + && _yaml["webserv"]["cgi_search_script"].type.string + && _yaml["webserv"]["cgi_search_script"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_search_script_raw_fn_d = (_yaml["webserv"]["cgi_search_script"].get!string).translate(['-' : "_"]) ~ ".d"; + } else { + _struct_composite.conf.w_srv_cgi_search_script_raw_fn_d = "spine_search.d"; } if ("cgi_port" in _yaml["webserv"] && _yaml["webserv"]["cgi_port"].type.string && _yaml["webserv"]["cgi_port"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_cgi_port = _yaml["webserv"]["cgi_port"].get!string; + _struct_composite.conf.w_srv_cgi_port = _yaml["webserv"]["cgi_port"].get!string; } if ("cgi_user" in _yaml["webserv"] && _yaml["webserv"]["cgi_user"].type.string && _yaml["webserv"]["cgi_user"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_cgi_user = _yaml["webserv"]["cgi_user"].get!string; + _struct_composite.conf.w_srv_cgi_user = _yaml["webserv"]["cgi_user"].get!string; } - if ("cgi_file_links" in _yaml["webserv"] - && _yaml["webserv"]["cgi_file_links"].type.string - && _yaml["webserv"]["cgi_file_links"].tag.match(rgx.yaml_tag_is_str) + if ("cgi_action" in _yaml["webserv"] + && _yaml["webserv"]["cgi_action"].type.string + && _yaml["webserv"]["cgi_action"].tag.match(rgx.yaml_tag_is_str) ) { - _struct_composite.conf.webserv_cgi_file_links = _yaml["webserv"]["cgi_file_links"].get!string; + _struct_composite.conf.w_srv_cgi_action = _yaml["webserv"]["cgi_action"].get!string; + } else { // action is composite, build + } + if ("cgi_bin_url" in _yaml["webserv"] + && _yaml["webserv"]["cgi_bin_url"].type.string + && _yaml["webserv"]["cgi_bin_url"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_bin_url = _yaml["webserv"]["cgi_bin_url"].get!string; + } else { + _struct_composite.conf.w_srv_cgi_bin_url = + (_struct_composite.conf.w_srv_cgi_http.empty) + ? _struct_composite.conf.w_srv_http + :_struct_composite.conf.w_srv_cgi_http + ~ "://" + ~ (_struct_composite.conf.w_srv_cgi_domain.empty) + ? _struct_composite.conf.w_srv_cgi_domain + : _struct_composite.conf.w_srv_domain + ~ "/" + ~ _struct_composite.conf.w_srv_cgi_bin_part; + } + // if ("cgi_file_links" in _yaml["webserv"] + // && _yaml["webserv"]["cgi_file_links"].type.string + // && _yaml["webserv"]["cgi_file_links"].tag.match(rgx.yaml_tag_is_str) + // ) { + // _struct_composite.conf.w_srv_cgi_file_links = _yaml["webserv"]["cgi_file_links"].get!string; + // } + if ("db_sqlite" in _yaml["webserv"] + && _yaml["webserv"]["db_sqlite"].type.string + && _yaml["webserv"]["db_sqlite"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_db_sqlite = _yaml["webserv"]["db_sqlite"].get!string; + } else { // set default ? } } } diff --git a/src/doc_reform/meta/defaults.d b/src/doc_reform/meta/defaults.d index 63eb5fa..8d34069 100644 --- a/src/doc_reform/meta/defaults.d +++ b/src/doc_reform/meta/defaults.d @@ -187,7 +187,7 @@ template InternalMarkup() { string tc_c = "┚"; string tc_p = "┆"; string img = "☼"; - string sep = "␣"; + string sep = "␣"; // "~"; string on_o = "「"; string on_c = "」"; string mk_bullet = "● "; static string indent_by_spaces_provided(int indent, string _indent_spaces ="░░") { diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index b0b4fdc..cf74e23 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -186,6 +186,12 @@ template spineAbstraction() { @safe string filename() { return _opt_action.sqlite_filename; } + @safe string cgi_filename() { + return _opt_action.cgi_sqlite_search_filename; + } + @safe string cgi_filename_d() { + return _opt_action.cgi_sqlite_search_filename_d; + } } return SQLite_(); } diff --git a/src/doc_reform/meta/metadoc_show_config.d b/src/doc_reform/meta/metadoc_show_config.d index a432c3b..630fe0c 100644 --- a/src/doc_reform/meta/metadoc_show_config.d +++ b/src/doc_reform/meta/metadoc_show_config.d @@ -31,32 +31,44 @@ template spineShowConfig() { } if (doc_matters.opt.action.show_config) { writefln( - "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n", + "%s\n\"%s\", %s\n%s\n%s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n%30-s%10-s\n", markup.repeat_character_by_number_provided("-", char_repeat_number), doc_matters.conf_make_meta.meta.title_full, doc_matters.conf_make_meta.meta.creator_author, doc_matters.src.filename, markup.repeat_character_by_number_provided("-", char_repeat_number), - "- webserv url domain:", - doc_matters.conf_make_meta.conf.webserv_url_domain, - "- webserv doc root:", - doc_matters.conf_make_meta.conf.webserv_url_doc_root, + "- webserv domain name:", + doc_matters.conf_make_meta.conf.w_srv_domain, + "- webserv doc root (part):", + doc_matters.conf_make_meta.conf.w_srv_data_root_part, "- webserv doc path:", - doc_matters.conf_make_meta.conf.webserv_url_doc_path, + doc_matters.conf_make_meta.conf.w_srv_data_root_path, "- webserv images (location):", - doc_matters.conf_make_meta.conf.webserv_images, - "- webserv cgi:", - doc_matters.conf_make_meta.conf.webserv_cgi, - "- webserv cgi host:", - doc_matters.conf_make_meta.conf.webserv_cgi_host, + doc_matters.conf_make_meta.conf.w_srv_images_root_part, + "- webserv doc root url:", + doc_matters.conf_make_meta.conf.w_srv_data_root_url, + "- webserv cgi domain (host):", + doc_matters.conf_make_meta.conf.w_srv_cgi_domain, "- webserv cgi host path:", - doc_matters.conf_make_meta.conf.webserv_cgi_host_path, + doc_matters.conf_make_meta.conf.w_srv_cgi_bin_path, + "- webserv cgi host (part):", + doc_matters.conf_make_meta.conf.w_srv_cgi_bin_part, + "- webserv cgi search script:", + doc_matters.conf_make_meta.conf.w_srv_cgi_search_script, + "- webserv cgi search script in d:", + doc_matters.conf_make_meta.conf.w_srv_cgi_search_script_raw_fn_d, "- webserv cgi port:", - doc_matters.conf_make_meta.conf.webserv_cgi_port, + doc_matters.conf_make_meta.conf.w_srv_cgi_port, "- webserv cgi user:", - doc_matters.conf_make_meta.conf.webserv_cgi_user, - "- webserv cgi file links:", - doc_matters.conf_make_meta.conf.webserv_cgi_file_links, + doc_matters.conf_make_meta.conf.w_srv_cgi_user, + "- webserv cgi url:", + doc_matters.conf_make_meta.conf.w_srv_cgi_bin_url, + "- webserv cgi action:", + doc_matters.conf_make_meta.conf.w_srv_cgi_action, + // "- webserv cgi file links:", + // doc_matters.conf_make_meta.conf.w_srv_cgi_file_links, + "- webserv sqlite db:", + doc_matters.conf_make_meta.conf.w_srv_db_sqlite, "- output path:", doc_matters.conf_make_meta.conf.output_path, "- processing concordance max:", -- cgit v1.2.3