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 --- org/meta_conf_make_meta.org | 263 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 210 insertions(+), 53 deletions(-) (limited to 'org/meta_conf_make_meta.org') diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index ce43d84..8777fde 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -16,6 +16,44 @@ [[./spine.org][spine]] [[./][org/]] * 0. generic +** conf yaml ref + +#+BEGIN_SRC yaml +flag: + act0: "--html" + act1: "--html --epub" +output: + path: "/var/www/html" +default: + language: "en" + papersize: "a4" + text_wrap: "80" + digest: "sha256" +webserv: + http: "http" + domain: "localhost" + data_http: "http" + data_domain: "localhost" + data_root_url: "http://localhost" + data_root_path: "/var/www/html" + data_root_part: "" + images_root_part: "image" + cgi_title: "≅ SiSU Spine search" + cgi_http: "http" + cgi_domain: "localhost" + cgi_bin_url: "http://localhost/cgi-bin" + cgi_bin_part: "cgi-bin" + cgi_bin_path: "/usr/lib/cgi-bin" + cgi_search_script: "spine-search" + cgi_search_script_raw_fn_d: "spine_search.d" + cgi_port: "" + cgi_user: "" + cgi_action: "http://localhost/cgi-bin/spine-search" + db_sqlite: "spine.search.db" + db_pg_table: "" + db_pg_user: "" +#+END_SRC + ** imports #+NAME: meta_defaults_imports @@ -213,16 +251,31 @@ struct ConfCompositeMakeInit { #+NAME: meta_defaults_template_structs #+BEGIN_SRC d 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; @@ -541,57 +594,161 @@ if ("webserv" in _yaml 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) + if ("http" in _yaml["webserv"] + && _yaml["webserv"]["http"].type.string + && _yaml["webserv"]["http"].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; - } + _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 ("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; + } 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_title" in _yaml["webserv"] + && _yaml["webserv"]["cgi_title"].type.string + && _yaml["webserv"]["cgi_title"].tag.match(rgx.yaml_tag_is_str) + ) { + _struct_composite.conf.w_srv_cgi_title = _yaml["webserv"]["cgi_title"].get!string; } - if ("images" in _yaml["webserv"] - && _yaml["webserv"]["images"].type.string - && _yaml["webserv"]["images"].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_images = _yaml["webserv"]["images"].get!string; + _struct_composite.conf.w_srv_cgi_bin_part = _yaml["webserv"]["cgi_bin_part"].get!string; } - if ("cgi" in _yaml["webserv"] - && _yaml["webserv"]["cgi"].type.string - && _yaml["webserv"]["cgi"].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 = _yaml["webserv"]["cgi"].get!string; + _struct_composite.conf.w_srv_cgi_bin_path = _yaml["webserv"]["cgi_bin_path"].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_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.webserv_cgi_host = _yaml["webserv"]["cgi_host"].get!string; + _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_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_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.webserv_cgi_host_path = _yaml["webserv"]["cgi_host_path"].get!string; + _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 ? } } } @@ -1368,49 +1525,49 @@ if ("make" in _json.object) { #+BEGIN_SRC d /+ 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) { -- cgit v1.2.3