From db96528baa55151826442f61ddfea2cd006ef68d Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 4 Apr 2020 17:25:56 -0400 Subject: config, where used without document processing --- org/default_paths.org | 41 +++++++------ org/default_regex.org | 4 +- org/in_source_files.org | 13 +++-- org/out_sqlite.org | 80 ++++++++++++++++++-------- org/out_xmls.org | 12 ++-- org/output_hub.org | 14 ++--- org/output_show.org | 118 ++++++++++++++++++++++++++++++-------- org/spine.org | 149 ++++++++++++++++++++++++++++++++---------------- 8 files changed, 292 insertions(+), 139 deletions(-) (limited to 'org') diff --git a/org/default_paths.org b/org/default_paths.org index 20dae9e..3af1019 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -49,7 +49,7 @@ template PodManifest() { mixin spineRgxIn; static auto rgx = RgxI(); @safe auto PodManifest(O)( - O _opt_actions, + O _opt_action, string _pth="" ) { struct ManifestFile_ { @@ -71,10 +71,10 @@ template PodManifest() { _manifest_path = m.captures["podpath"]; } } else { - if (_opt_actions.verbose || _opt_actions.very_verbose || _opt_actions.debug_do) { + if (_opt_action.verbose || _opt_action.very_verbose || _opt_action.debug_do) { writeln("WARNING, src is not a pod, issue with manifest_path: ", _pth); // remove? unless can distinguish pod } - _manifest_path = null; // _manifest_path = ""; + _manifest_path = ""; } return _manifest_path; } @@ -126,13 +126,13 @@ template PathMatters() { static auto rgx = RgxI(); static auto mkup = InlineMarkup(); @safe auto PathMatters(O,E)( - O _opt_actions, + O _opt_action, E _env, string _pth, string _fns = "", char[][] _manifest_fn_list = [[]], ) { - @safe auto _manifested = PodManifest!()(_opt_actions, _pth); + @safe auto _manifested = PodManifest!()(_opt_action, _pth); struct ManifestMatters_ { auto env() { auto _env = _env; @@ -149,7 +149,7 @@ template PathMatters() { @safe auto opt() { struct Opt_ { auto action() { - return _opt_actions; + return _opt_action; } } return Opt_(); @@ -208,7 +208,7 @@ template PathMatters() { } @safe auto src() { string _fns = _fns; // required here by dmd & not by ldc (for D:2078) - auto _opt_actions = _opt_actions; + auto _opt_action = _opt_action; auto _env = _env; struct SRC_ { @safe bool is_pod() { @@ -323,7 +323,7 @@ template PathMatters() { assert(_dir == absolute_path_to_src .match(rgx.src_base_parent_dir_name).captures["dir"]); } - if (_opt_actions.debug_do) { + if (_opt_action.debug_do) { writeln("--> (base_dir) ", _dir); } return _dir; @@ -355,7 +355,7 @@ template PathMatters() { } else { _dir = ((path_and_fn.chainPath("../../")).asNormalizedPath).array; } - if (_opt_actions.debug_do) { + if (_opt_action.debug_do) { writeln("--> (base_dir_path) ", _dir); } return _dir; @@ -401,7 +401,7 @@ template PathMatters() { } else { _dir = (absolute_path_to_src).match(rgx.src_base_parent_dir_name).captures["dir"]; } - if (_opt_actions.debug_do) { + if (_opt_action.debug_do) { writeln("--> (base_parent_dir) ", _dir); } return _dir; @@ -437,10 +437,10 @@ template PathMatters() { struct Out_ { @safe auto path() { auto _output_path = _env["pwd"]; - if ((_opt_actions.output_dir_set.length > 0) - && isValidPath(_opt_actions.output_dir_set) + if ((_opt_action.output_dir_set.length > 0) + && isValidPath(_opt_action.output_dir_set) ) { - _output_path = ((_opt_actions.output_dir_set).asNormalizedPath).array; + _output_path = ((_opt_action.output_dir_set).asNormalizedPath).array; if (!exists(_output_path)) { try { _output_path.mkdirRecurse; @@ -468,10 +468,10 @@ template PathMatters() { #+NAME: template_paths_src #+BEGIN_SRC d -template ConfigFilePaths() { +template configFilePaths() { mixin spineRgxIn; static auto rgx = RgxI(); - @safe auto ConfigFilePaths(M,E)( + @safe auto configFilePaths(M,E)( M _manifested, E _env, string _cli_config_path_set = "" @@ -524,10 +524,9 @@ template ConfigFilePaths() { _dr_doc_conf_pwd_d, ]; } - } else { - _possible_config_path_locations = [ - _cli_config_path_set - ]; + } else if (_cli_config_path_set.isDir) { + _possible_config_path_locations = [_cli_config_path_set ]; + // } else if (_cli_config_path_set.isFile) { // use file, taken care of elsewhere } /+ FIX clean up conf paths ↑ (compare pwd to doc path location, and build config path) @@ -549,10 +548,10 @@ template ConfigFilePaths() { _possible_config_path_locations = [ _dot_pwd, _underscore_pwd, + _collection_root_a, + _collection_root_b, _dot_home, "/etc/dr", - _collection_root_a, // set priority higher? - _collection_root_b // set priority higher? ]; } else { /+ config document (& or local site) on filesystem +/ diff --git a/org/default_regex.org b/org/default_regex.org index 67d259a..a768a65 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -480,8 +480,8 @@ static inline_link_empty = ctRegex!(`┥(?P.+ static inline_link_number = ctRegex!(`┥(?P.+?)┝┤(?P[0-9]+)├`, "mg"); // not used static inline_link_number_only = ctRegex!(`(?P┥.+?┝)┤(?P[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P.+?)┝┤(?P[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links -static inline_link_hash = ctRegex!(`┥(?P.+?)┝┤(?P#(?P\S+?))├`, "mg"); -static inline_link_seg_and_hash = ctRegex!(`┥(?P.+?)┝┤(?P[^/]+?#(?P.+?))├`, "mg"); +static inline_link_hash = ctRegex!(`┥(?P.+?)┝┤(?P#(?P\S+?))├`, "mg"); +static inline_link_seg_and_hash = ctRegex!(`┥(?P.+?)┝┤(?P(?P[^/#├]*)#(?P.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?Pendnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); static url = ctRegex!(`https?://`, "mg"); diff --git a/org/in_source_files.org b/org/in_source_files.org index eb813db..05e9889 100644 --- a/org/in_source_files.org +++ b/org/in_source_files.org @@ -56,7 +56,7 @@ import #+NAME: meta_config_file_hub #+BEGIN_SRC d template readConfigSite() { - @system final auto readConfigSite(C)(C _conf_file_details) { + @system final auto readConfigSite(C,O)(C _conf_file_details, O _opt_action) { mixin spineRgxIn; static auto rgx = RgxI(); string conf_filename = "NONE"; @@ -114,6 +114,9 @@ webserv: try { if (exists(conf_file)) { if (conf_file.getLinkAttributes.attrIsFile) { + if (_opt_action.verbose || _opt_action.very_verbose || _opt_action.debug_do) { + writeln("config file used: \"", conf_file, "\" (cli flag settings override config file's individual settings)"); + } config_file_str = conf_file.readText; break; } @@ -137,7 +140,7 @@ webserv: config_file_str = default_config_file_str; } } - if (config_file_str.length == 0) { /+ create dummy default config file +/ + if (config_file_str.length == 0) { /+ use dummy default config file +/ writeln("WARNING config file NOT found, default provided"); conf_filename = "VIRTUAL"; config_file_str = default_config_file_str; @@ -176,7 +179,7 @@ static template readConfigDoc() { static auto rgx = RgxI(); string config_file_str; string conf_filename = "NONE"; - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); + auto _conf_file_details = configFilePaths!()(_manifested, _env); string[] possible_config_path_locations = _conf_file_details.possible_config_path_locations.dr_document_make; foreach(conf_fn; [_conf_file_details.config_filename_document]) { foreach(pth; possible_config_path_locations) { @@ -228,7 +231,7 @@ static template configReadSiteYAML() { <>; @safe final YAMLDocument configReadSiteYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInSiteYAML!()(_manifested, _env); - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); + auto _conf_file_details = configFilePaths!()(_manifested, _env); string _conf_yaml_fn = _conf_file_details.config_filename_site; YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn); return _yaml_conf; @@ -240,7 +243,7 @@ static template configReadDocYAML() { <>; @safe final YAMLDocument configReadDocYAML(M,E)(M _manifested, E _env) { string _configuration = configReadInDocYAML!()(_manifested, _env); - auto _conf_file_details = ConfigFilePaths!()(_manifested, _env); + auto _conf_file_details = configFilePaths!()(_manifested, _env); string _conf_yaml_fn = _conf_file_details.config_filename_document; YAMLDocument _yaml_conf = configYAML!()(_configuration, _conf_yaml_fn); return _yaml_conf; diff --git a/org/out_sqlite.org b/org/out_sqlite.org index e886fbd..b5c2532 100644 --- a/org/out_sqlite.org +++ b/org/out_sqlite.org @@ -272,7 +272,7 @@ template SQLiteInsertDocObjectsLoop() { #+NAME: sqlite_tables_create #+BEGIN_SRC d template SQLiteTablesCreate() { - void SQLiteTablesCreate(E,O)(E env, O opt_action) { + void SQLiteTablesCreate(E,O,C)(E env, O opt_action, C config) { import d2sqlite3; template SQLiteTablesReCreate() { string SQLiteTablesReCreate()() { @@ -290,13 +290,32 @@ template SQLiteTablesCreate() { } if (opt_action.sqlite_db_create) { string _db_statement; - auto pth_sqlite = spinePathsSQLite!()(opt_action.sqlite_filename, opt_action.output_dir_set); - pth_sqlite.base.mkdirRecurse; - auto db = Database(pth_sqlite.sqlite_file); - { - _db_statement ~= SQLiteTablesReCreate!()(); + string db_filename = (opt_action.sqlite_filename.length > 0) + ? opt_action.sqlite_filename + : (config.conf.w_srv_db_sqlite.length > 0) + ? config.conf.w_srv_db_sqlite + : ""; + string output_path = (opt_action.output_dir_set.length > 0) + ? opt_action.output_dir_set + : (config.conf.output_path.length > 0) + ? config.conf.output_path + : ""; + if (db_filename.length > 0 && output_path.length > 0) { + if ((opt_action.verbose)) { + writeln("db name & path: ", config.conf.output_path, "/sqlite/", db_filename); + } + auto pth_sqlite = spinePathsSQLite!()(db_filename, output_path); + pth_sqlite.base.mkdirRecurse; + auto db = Database(pth_sqlite.sqlite_file); + { + _db_statement ~= SQLiteTablesReCreate!()(); + } + SQLiteDbRun!()(db, _db_statement, opt_action, "TABLE RE-CREATE"); + } else { + writeln("must provide db name & output root path either on the command line or in configuration file"); + writeln("db name: ", db_filename); + writeln("output root path (path less /sqlite which is added: ", config.conf.output_path); } - SQLiteDbRun!()(db, _db_statement, opt_action, "TABLE RE-CREATE"); } } } @@ -307,15 +326,31 @@ template SQLiteTablesCreate() { #+NAME: sqlite_tables_drop #+BEGIN_SRC d template SQLiteDbDrop() { - void SQLiteDbDrop(O)(O opt_action) { + void SQLiteDbDrop(O,C)(O opt_action, C config) { writeln("db drop"); if ((opt_action.sqlite_db_drop)) { - auto pth_sqlite = spinePathsSQLite!()(opt_action.sqlite_filename, opt_action.output_dir_set); - writeln("remove(", pth_sqlite.sqlite_file, ")"); - try { - remove(pth_sqlite.sqlite_file); - } catch (FileException ex) { - // handle error + string db_filename = (opt_action.sqlite_filename.length > 0) + ? opt_action.sqlite_filename + : (config.conf.w_srv_db_sqlite.length > 0) + ? config.conf.w_srv_db_sqlite + : ""; + string output_path = (opt_action.output_dir_set.length > 0) + ? opt_action.output_dir_set + : (config.conf.output_path.length > 0) + ? config.conf.output_path + : ""; + if (db_filename.length > 0 && output_path.length > 0) { + auto pth_sqlite = spinePathsSQLite!()(db_filename, output_path); + writeln("remove(", pth_sqlite.sqlite_file, ")"); + try { + remove(pth_sqlite.sqlite_file); + } catch (FileException ex) { + // handle error + } + } else { + writeln("must provide db name & output root path either on the command line or in configuration file"); + writeln("db name: ", db_filename); + writeln("output root path (path less /sqlite which is added: ", config.conf.output_path); } } } @@ -605,9 +640,9 @@ string inline_links(M,O)( } auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); if (_xml_type == "seg") { - foreach (m; _txt.match(rgx.inline_link_seg_and_hash)) { - if (m.captures["segname"] in doc_matters.has.tag_associations) { - if (m.captures["segname"] == doc_matters.has.tag_associations[(m.captures["segname"])]["seg_lv4"]) { + foreach (m; _txt.matchAll(rgx.inline_link_seg_and_hash)) { + if (m.captures["hash"] in doc_matters.has.tag_associations) { + if (m.captures["hash"] == doc_matters.has.tag_associations[(m.captures["hash"])]["seg_lv4"]) { _txt = _txt.replaceFirst( rgx.inline_link_seg_and_hash, "┥$1┝┤" @@ -624,9 +659,9 @@ string inline_links(M,O)( ~ "/" ~ doc_matters.src.filename_base ~ "/" - ~ doc_matters.has.tag_associations[(m.captures["segname"])]["seg_lv4"] + ~ doc_matters.has.tag_associations[(m.captures["hash"])]["seg_lv4"] ~ ".html" - ~ "#" ~ "$3" + ~ "#" ~ m.captures["hash"] ~ "├" ); } @@ -634,9 +669,9 @@ string inline_links(M,O)( if (!(doc_matters.opt.action.quiet)) { writeln( "WARNING on internal document links, anchor to link <<" - ~ m.captures["segname"] + ~ m.captures["hash"] ~ ">> not found in document, " - ~ "anchor: " ~ m.captures["segname"] + ~ "anchor: " ~ m.captures["hash"] ~ " document: " ~ doc_matters.src.filename ); } @@ -650,7 +685,7 @@ string inline_links(M,O)( ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url_html ~ "/" ~ pth_html.tail_fn_scroll(doc_matters.src.filename) - ~ "#" ~ "$3" + ~ "#" ~ m.captures["hash"] ~ "├" ); } @@ -1869,7 +1904,6 @@ writeln(doc_matters.conf_make_meta.meta.classify_topic_register_arr); #+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC d if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { - string _insert_topics; foreach (topic; doc_matters.conf_make_meta.meta.classify_topic_register_arr) { string[] subject_tree = topic.split(mkup.sep); diff --git a/org/out_xmls.org b/org/out_xmls.org index da5b640..acd2b79 100644 --- a/org/out_xmls.org +++ b/org/out_xmls.org @@ -499,10 +499,10 @@ import if (_xml_type == "seg" || _xml_type == "epub") { seg_lvs = (_xml_type == "epub") ? "seg_lv1_to_4" : "seg_lv4"; foreach (m; _txt.match(rgx.inline_link_hash)) { - if (m.captures[3] in doc_matters.has.tag_associations) { + if (m.captures["hash"] in doc_matters.has.tag_associations) { if ( - m.captures[3] - == doc_matters.has.tag_associations[(m.captures[3])][seg_lvs] + m.captures["hash"] + == doc_matters.has.tag_associations[(m.captures["hash"])][seg_lvs] ) { _txt = _txt.replaceFirst( rgx.inline_link_hash, @@ -512,7 +512,7 @@ import _txt = _txt.replaceFirst( rgx.inline_link_hash, "┥$1┝┤" - ~ doc_matters.has.tag_associations[(m.captures[3])][seg_lvs] + ~ doc_matters.has.tag_associations[(m.captures["hash"])][seg_lvs] ~ _suffix ~ "#" ~ "$3" ~ "├" ); @@ -521,9 +521,9 @@ import if (!(doc_matters.opt.action.quiet)) { writeln( "WARNING on internal document links, anchor to link <<" - ~ m.captures[3] + ~ m.captures["hash"] ~ ">> not found in document, " - ~ "anchor: " ~ m.captures[3] + ~ "anchor: " ~ m.captures["hash"] ~ " document: " ~ doc_matters.src.filename ); } diff --git a/org/output_hub.org b/org/output_hub.org index 560cc2e..ba39e2e 100644 --- a/org/output_hub.org +++ b/org/output_hub.org @@ -58,7 +58,7 @@ template outputHub() { } template outputHubOp() { <> - @system void outputHubOp(E,O,M)(E env, O opt_action, M make_and_meta_struct) { + @system void outputHubOp(E,O,C)(E env, O opt_action, C config) { mixin spineRgxOut; static auto rgx = RgxO(); <> @@ -226,7 +226,7 @@ if ((opt_action.sqlite_db_drop)) { writeln("sqlite drop db..."); } import doc_reform.io_out.sqlite; - SQLiteDbDrop!()(opt_action); + SQLiteDbDrop!()(opt_action, config); if ((opt_action.very_verbose)) { writeln("sqlite drop db done"); } @@ -243,7 +243,7 @@ if ((opt_action.sqlite_db_create)) { writeln("sqlite create table..."); } import doc_reform.io_out.sqlite; - SQLiteTablesCreate!()(env, opt_action); + SQLiteTablesCreate!()(env, opt_action, config); if ((opt_action.very_verbose)) { writeln("sqlite create table done"); } @@ -257,20 +257,20 @@ if ((opt_action.sqlite_db_create)) { if ((opt_action.cgi_search_form_codegen)) { if ((opt_action.verbose)) { string _sqlite_db_fn = (opt_action.sqlite_filename.empty) - ? make_and_meta_struct.conf.w_srv_db_sqlite + ? config.conf.w_srv_db_sqlite : opt_action.sqlite_filename; string _cgi_search_script = (opt_action.cgi_sqlite_search_filename.empty) - ? make_and_meta_struct.conf.w_srv_cgi_search_script + ? config.conf.w_srv_cgi_search_script : opt_action.cgi_sqlite_search_filename; 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 + ? config.conf.w_srv_cgi_search_script_raw_fn_d : opt_action.cgi_sqlite_search_filename_d; auto pth_sqlite_cgi = spinePathsSQLiteCGI!()(_cgi_search_script_raw_fn_d, _cgi_search_script, opt_action.output_dir_set); writeln("sqlite cgi search form..."); writeln(" ", pth_sqlite_cgi.search_form_path_out); } import doc_reform.io_out.cgi_sqlite_search_form; - CGIsearchSQLite!()(env, opt_action, make_and_meta_struct); + CGIsearchSQLite!()(env, opt_action, config); if ((opt_action.very_verbose)) { writeln("sqlite cgi search form done"); } diff --git a/org/output_show.org b/org/output_show.org index 3a1832b..0030b63 100644 --- a/org/output_show.org +++ b/org/output_show.org @@ -72,7 +72,7 @@ foreach (k; doc_matters.has.keys_seq.seg) { #+NAME: meta_metadoc_show_summary_document #+BEGIN_SRC d writefln( - "%s\n\"%s\", %s\n%s [%s]\n%s\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%30-s%10-d\n%s", + "%s\n\"%s\", %s\n%s [%s]\n%s\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%s", 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, @@ -131,10 +131,97 @@ writefln( * show config ** _module template_ show config +*** _show site config --show-config (show config) #+BEGIN_SRC d :tangle "../src/doc_reform/meta/metadoc_show_config.d" module doc_reform.meta.metadoc_show_config; +template spineShowSiteConfig() { + @safe void spineShowSiteConfig(O,T)( + O opt_action, + T config, + ) { + <> + <> + mixin InternalMarkup; + auto markup = InlineMarkup(); + auto char_repeat_number = 66; + if (opt_action.show_config) { + <> + } + } +} +#+END_SRC + +*** show site config + +#+NAME: meta_metadoc_show_site_config +#+BEGIN_SRC d +writefln( + "\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n", + markup.repeat_character_by_number_provided("-", char_repeat_number), + "- webserv domain name:", + config.conf.w_srv_domain, + "- webserv doc root (part):", + config.conf.w_srv_data_root_part, + "- webserv doc path:", + config.conf.w_srv_data_root_path, + "- webserv images (location):", + config.conf.w_srv_images_root_part, + "- webserv doc root url:", + config.conf.w_srv_data_root_url, + "- webserv cgi domain (host):", + config.conf.w_srv_cgi_domain, + "- webserv cgi host path:", + config.conf.w_srv_cgi_bin_path, + "- webserv cgi host (part):", + config.conf.w_srv_cgi_bin_part, + "- webserv cgi search script:", + config.conf.w_srv_cgi_search_script, + "- webserv cgi search script in d:", + config.conf.w_srv_cgi_search_script_raw_fn_d, + "- webserv cgi port:", + config.conf.w_srv_cgi_port, + "- webserv cgi user:", + config.conf.w_srv_cgi_user, + "- webserv cgi url:", + config.conf.w_srv_cgi_bin_url, + "- webserv cgi action:", + config.conf.w_srv_cgi_action, + // "- webserv cgi file links:", + // config.conf.w_srv_cgi_file_links, + "- webserv sqlite db:", + config.conf.w_srv_db_sqlite, + "- output path:", + config.conf.output_path, + "- processing concordance max:", + config.conf.processing_concord_max, + // "- flag act0:", + // config.conf.flag_act0, + "- default papersize:", + config.conf.default_papersize, + "- default text wrap:", + config.conf.default_text_wrap, + "- default emphasis markup symbol:", + config.conf.default_emphasis, + "- default language:", + config.conf.default_language, + "- default hash digest:", + config.conf.default_digest, + "- search flag:", + config.conf.search_flag, + "- search action:", + config.conf.search_action, + "- search db:", + config.conf.search_db, + "- search title:", + config.conf.search_title, +); +#+END_SRC + +*** show (per document) config + +#+BEGIN_SRC d :tangle "../src/doc_reform/meta/metadoc_show_config.d" template spineShowConfig() { @safe void spineShowConfig(T)( T doc_matters, @@ -160,7 +247,7 @@ template spineShowConfig() { #+NAME: meta_metadoc_show_config #+BEGIN_SRC d 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", + "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-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, @@ -202,26 +289,8 @@ writefln( doc_matters.conf_make_meta.conf.output_path, "- processing concordance max:", doc_matters.conf_make_meta.conf.processing_concord_max, - "- flag act0:", - doc_matters.conf_make_meta.conf.flag_act0, - "- flag act1:", - doc_matters.conf_make_meta.conf.flag_act1, - "- flag act2:", - doc_matters.conf_make_meta.conf.flag_act2, - "- flag act3:", - doc_matters.conf_make_meta.conf.flag_act3, - "- flag act4:", - doc_matters.conf_make_meta.conf.flag_act4, - "- flag act5:", - doc_matters.conf_make_meta.conf.flag_act5, - "- flag act6:", - doc_matters.conf_make_meta.conf.flag_act6, - "- flag act7:", - doc_matters.conf_make_meta.conf.flag_act7, - "- flag act8:", - doc_matters.conf_make_meta.conf.flag_act8, - "- flag act9:", - doc_matters.conf_make_meta.conf.flag_act9, + // "- flag act0:", + // doc_matters.conf_make_meta.conf.flag_act0, "- default papersize:", doc_matters.conf_make_meta.conf.default_papersize, "- default text wrap:", @@ -274,7 +343,7 @@ template spineShowMake() { #+NAME: meta_metadoc_show_make #+BEGIN_SRC d 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", + "%s\n\"%s\", %s\n%s\n%s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-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, @@ -313,7 +382,6 @@ writefln( ); #+END_SRC - * show metadata ** _module template_ show metadata --show-metadata (show document metadata) @@ -345,7 +413,7 @@ template spineShowMetaData() { #+NAME: meta_metadoc_show_metadata #+BEGIN_SRC d 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%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%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-s%10-s\n%40-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, diff --git a/org/spine.org b/org/spine.org index 253720f..f530703 100644 --- a/org/spine.org +++ b/org/spine.org @@ -98,7 +98,6 @@ string program_name = "spine"; <> <> <> - <> if (_manifests.length > 1 // _manifests[0] initialized dummy element && _opt_action.abstraction) { if (_opt_action.parallelise) { // see else @@ -425,7 +424,9 @@ auto helpInfo = getopt(args, "abstraction", "--abstraction document abstraction ", &opts["abstraction"], "assert", "--assert set optional assertions on", &opts["assertions"], "cgi-search-form-codegen", "--cgi-search-form-codegen pre-compiled d code search of specified db", &opts["cgi-search-form-codegen"], + "cgi-sqlite-search-filename", "--cgi-sqlite-search-filename=[filename]", &settings["cgi-sqlite-search-filename"], "concordance", "--concordance file for document", &opts["concordance"], + "config", "--config=/path/to/config/file/including/filename", &settings["config"], "dark", "--dark alternative dark theme", &opts["dark"], "debug", "--debug", &opts["debug"], "digest", "--digest hash digest for each object", &opts["digest"], @@ -438,6 +439,7 @@ auto helpInfo = getopt(args, "html-link-search", "--html-link-search html embedded search submission", &opts["html-link-search"], "html-seg", "--html-seg process html output", &opts["html-seg"], "html-scroll", "--html-seg process html output", &opts["html-scroll"], + "lang", "--lang=[lang code e.g. =en or =en,es]", &settings["lang"], "latex", "--latex output for pdfs", &opts["latex"], "latex-color-links", "--latex-color-links mono or color links for pdfs", &opts["latex-color-links"], "light", "--light default light theme", &opts["light"], @@ -446,8 +448,9 @@ auto helpInfo = getopt(args, "ocn-off", "--ocn-off object cite numbers", &opts["ocn-off"], "odf", "--odf open document format text (--odt)", &opts["odf"], "odt", "--odt open document format text", &opts["odt"], + "output", "--output=/path/to/output/dir specify where to place output", &settings["output"], "parallel", "--parallel parallelisation", &opts["parallel"], - "parallel-subprocesses", "--parallel-subprocesses nested parallelisation", &opts["parallel-subprocesses"], + "parallel-subprocesses", "--parallel-subprocesses nested parallelisation", &opts["parallel-subprocesses"], "quiet|q", "--quiet output to terminal", &opts["quiet"], "pdf", "--pdf latex output for pdfs", &opts["pdf"], "pdf-color-links", "--pdf-color-links mono or color links for pdfs", &opts["pdf-color-links"], @@ -477,16 +480,12 @@ auto helpInfo = getopt(args, "section-biblio", "--section-biblio process document biblio (default)", &opts["section_biblio"], "section-bookindex", "--section-bookindex process document bookindex (default)", &opts["section_bookindex"], "section-blurb", "--section-blurb process document blurb (default)", &opts["section_blurb"], + "sqlite-db-filename", "--sqlite-db-filename=[filename].sql.db", &settings["sqlite-filename"], "backmatter", "--section-backmatter process document backmatter (default)", &opts["backmatter"], "skip-output", "--skip-output", &opts["skip-output"], "theme-dark", "--theme-dark alternative dark theme", &opts["theme-dark"], "theme-light", "--theme-light default light theme", &opts["theme-light"], "workon", "--workon (reserved for some matters under development & testing)", &opts["workon"], - "cgi-sqlite-search-filename", "--cgi-sqlite-search-filename=[filename]", &settings["cgi-sqlite-search-filename"], - "config", "--config=/path/to/config/file/including/filename", &settings["config"], - "output", "--output=/path/to/output/dir specify where to place output", &settings["output"], - "sqlite-db-filename", "--sqlite-db-filename=[filename].sql.db", &settings["sqlite-db-filename"], - "lang", "--lang=[lang code e.g. =en or =en,es]", &settings["lang"], ); if (helpInfo.helpWanted) { defaultGetoptPrinter("Some information about the program.", helpInfo.options); @@ -753,6 +752,28 @@ struct OptActions { || sqlite_update ) ? true : false; } + @trusted bool require_processing_files() { + return ( + opts["abstraction"] + || epub + || html + || html_seg + || html_scroll + || latex + || odt + || manifest + || pod + || show_make + || show_metadata + || show_summary + || source + || source_or_pod + || sqlite_discrete + || sqlite_update + || text + || xhtml + ) ? true : false; + } @trusted bool meta_processing_general() { return ( opts["abstraction"] @@ -811,39 +832,71 @@ auto _env = [ ]; #+END_SRC -*** opt actions on processing files & file paths (pods, src etc.) +*** get/read site config #+NAME: spine_args #+BEGIN_SRC d auto _manifested = PathMatters!()(_opt_action, _env, ""); auto _manifests = [ _manifested ]; -auto _conf_file_details = ConfigFilePaths!()(_manifested, _env, _opt_action.config_path_set); -ConfComposite _make_and_meta_struct; -if (_opt_action.config_path_set.empty) { +auto _conf_file_details = configFilePaths!()(_manifested, _env, _opt_action.config_path_set); +ConfComposite _config; +if ( + _opt_action.require_processing_files + && _opt_action.config_path_set.empty +) { foreach(arg; args[1..$]) { if (!(arg.match(rgx.flag_action))) { /+ cli markup source path +/ // get first input markup source file names for processing _manifested = PathMatters!()(_opt_action, _env, arg); { /+ local site config +/ - _conf_file_details = ConfigFilePaths!()(_manifested, _env, _opt_action.config_path_set); - auto _config_local_site_struct = readConfigSite!()(_conf_file_details); + _conf_file_details = configFilePaths!()(_manifested, _env, _opt_action.config_path_set); + auto _config_local_site_struct = readConfigSite!()(_conf_file_details, _opt_action); import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifested); // - get local site config + _config = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_config, _manifested); // - get local site config break; } } } -} else { - { /+ local site config +/ - auto _config_local_site_struct = readConfigSite!()(_conf_file_details); - import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifested); // - get local site config +} else { /+ local site config +/ + auto _config_local_site_struct = readConfigSite!()(_conf_file_details, _opt_action); + import doc_reform.meta.conf_make_meta_yaml; + _config = _config_local_site_struct.configParseYAMLreturnSpineStruct!()(_config, _manifested); // - get local site config +} +if (_opt_action.show_config) { + import doc_reform.meta.metadoc_show_config; + spineShowSiteConfig!()(_opt_action, _config); +} +#+END_SRC + +*** use config for operations that do not require file processing + +#+NAME: spine_args +#+BEGIN_SRC d +if (!(_opt_action.skip_output)) { + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { + writeln("step0 commence → (without processing files)"); + } + outputHubOp!()(_env, _opt_action, _config); + if ((_opt_action.debug_do) + || (_opt_action.very_verbose) + ) { + writeln("- step0 complete"); } } -foreach(arg; args[1..$]) { // refigure how args relate to _opt_action, need path from _opt_action or args early _manifested too late, work on (search for PathMatters and .harvest, - auto _manifest_start = PodManifest!()(_opt_action, arg); +#+END_SRC + +*** opt action on processing files (loop args) + +#+NAME: spine_args +#+BEGIN_SRC d +ConfComposite _make_and_meta_struct = _config; +destroy(_config); +foreach(arg; args[1..$]) { if (arg.match(rgx.flag_action)) { /+ cli instruction, flag do +/ flag_action ~= " " ~ arg; // flags not taken by getopt - } else { /+ cli, assumed to be path to source files +/ + } else if (_opt_action.require_processing_files) { /+ cli, assumed to be path to source files +/ + auto _manifest_start = PodManifest!()(_opt_action, arg); if ( /+ pod files +/ !(arg.match(rgx.src_pth_sst_or_ssm)) && _manifest_start.pod_manifest_file_with_path @@ -1005,25 +1058,6 @@ foreach(arg; args[1..$]) { // refigure how args relate to _opt_action, need path } #+END_SRC -*** opt actions independent of processing files (no files no processing loop) - -#+NAME: spine_do_selected -#+BEGIN_SRC d -if (!(_opt_action.skip_output)) { - if ((_opt_action.debug_do) - || (_opt_action.very_verbose) - ) { - writeln("step0 commence → (without processing files)"); - } - outputHubOp!()(_env, _opt_action, _make_and_meta_struct); - if ((_opt_action.debug_do) - || (_opt_action.very_verbose) - ) { - writeln("- step0 complete"); - } -} -#+END_SRC - ** _2. processing: (loop each file)_ [+2] :loop:files: *** scope (loop) :scope: @@ -1100,8 +1134,7 @@ if (doc_matters.opt.action.verbose #+NAME: spine_each_file_do_debugs_checkdoc #+BEGIN_SRC d /+ ↓ debugs +/ -if (doc_matters.opt.action.show_metadata -) { +if (doc_matters.opt.action.show_metadata) { import doc_reform.meta.metadoc_show_metadata; spineShowMetaData!()(doc_matters); } @@ -1113,8 +1146,7 @@ if (doc_matters.opt.action.show_metadata #+NAME: spine_each_file_do_debugs_checkdoc #+BEGIN_SRC d /+ ↓ debugs +/ -if (doc_matters.opt.action.show_make -) { +if (doc_matters.opt.action.show_make) { import doc_reform.meta.metadoc_show_make; spineShowMake!()(doc_matters); } @@ -1126,8 +1158,7 @@ if (doc_matters.opt.action.show_make #+NAME: spine_each_file_do_debugs_checkdoc #+BEGIN_SRC d /+ ↓ debugs +/ -if (doc_matters.opt.action.show_config -) { +if (doc_matters.opt.action.show_config) { import doc_reform.meta.metadoc_show_config; spineShowConfig!()(doc_matters); } @@ -1504,13 +1535,31 @@ struct DocumentMatters { @safe auto sqlite() { struct SQLite_ { @safe string filename() { - return _opt_action.sqlite_filename; + string _fn = ""; + if (_opt_action.sqlite_filename.length > 0) { + _fn = _opt_action.sqlite_filename; + } else if (_make_and_meta_struct.conf.w_srv_db_sqlite.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_db_sqlite; + } + return _fn; } @safe string cgi_filename() { - return _opt_action.cgi_sqlite_search_filename; + string _fn = ""; + if (_opt_action.cgi_sqlite_search_filename.length > 0) { + _fn = _opt_action.cgi_sqlite_search_filename; + } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script; + } + return _fn; } @safe string cgi_filename_d() { - return _opt_action.cgi_sqlite_search_filename_d; + string _fn = ""; + if (_opt_action.cgi_sqlite_search_filename_d.length > 0) { + _fn = _opt_action.cgi_sqlite_search_filename_d; + } else if (_make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d.length > 0) { + _fn = _make_and_meta_struct.conf.w_srv_cgi_search_script_raw_fn_d; + } + return _fn; } } return SQLite_(); -- cgit v1.2.3