diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2020-04-04 17:25:56 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2020-05-20 11:27:25 -0400 |
commit | db96528baa55151826442f61ddfea2cd006ef68d (patch) | |
tree | 1325fd983b466d8157248648b6ef8a33beee5a93 /src | |
parent | sql, sqlite internal site links (diff) |
config, where used without document processing
Diffstat (limited to 'src')
-rw-r--r-- | src/doc_reform/io_in/paths_source.d | 41 | ||||
-rw-r--r-- | src/doc_reform/io_in/read_config_files.d | 13 | ||||
-rw-r--r-- | src/doc_reform/io_out/hub.d | 14 | ||||
-rw-r--r-- | src/doc_reform/io_out/rgx.d | 4 | ||||
-rw-r--r-- | src/doc_reform/io_out/sqlite.d | 80 | ||||
-rw-r--r-- | src/doc_reform/io_out/xmls.d | 12 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc.d | 24 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_show_config.d | 109 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_show_make.d | 2 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_show_metadata.d | 2 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_show_summary.d | 2 | ||||
-rw-r--r-- | src/doc_reform/meta/rgx.d | 4 | ||||
-rwxr-xr-x | src/doc_reform/spine.d | 113 |
13 files changed, 282 insertions, 138 deletions
diff --git a/src/doc_reform/io_in/paths_source.d b/src/doc_reform/io_in/paths_source.d index 0cf0478..432b484 100644 --- a/src/doc_reform/io_in/paths_source.d +++ b/src/doc_reform/io_in/paths_source.d @@ -18,7 +18,7 @@ template PodManifest() { mixin spineRgxIn; static auto rgx = RgxI(); @safe auto PodManifest(O)( - O _opt_actions, + O _opt_action, string _pth="" ) { struct ManifestFile_ { @@ -40,10 +40,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; } @@ -73,13 +73,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; @@ -96,7 +96,7 @@ template PathMatters() { @safe auto opt() { struct Opt_ { auto action() { - return _opt_actions; + return _opt_action; } } return Opt_(); @@ -155,7 +155,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() { @@ -270,7 +270,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; @@ -302,7 +302,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; @@ -348,7 +348,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; @@ -384,10 +384,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; @@ -409,10 +409,10 @@ template PathMatters() { return ManifestMatters_(); } } -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 = "" @@ -465,10 +465,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) @@ -490,10 +489,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/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d index 69c2f55..9180c20 100644 --- a/src/doc_reform/io_in/read_config_files.d +++ b/src/doc_reform/io_in/read_config_files.d @@ -12,7 +12,7 @@ import doc_reform.meta.rgx; 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"; @@ -70,6 +70,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; } @@ -93,7 +96,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; @@ -128,7 +131,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) { @@ -176,7 +179,7 @@ static template configReadSiteYAML() { doc_reform.io_in.paths_source; @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; @@ -190,7 +193,7 @@ static template configReadDocYAML() { doc_reform.io_in.paths_source; @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/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d index 50ee897..2220d33 100644 --- a/src/doc_reform/io_out/hub.d +++ b/src/doc_reform/io_out/hub.d @@ -115,7 +115,7 @@ template outputHubOp() { doc_reform.io_out.xmls, doc_reform.io_out.create_zip_file, doc_reform.io_out.paths_output; - @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(); if ((opt_action.sqlite_db_drop)) { @@ -123,7 +123,7 @@ template outputHubOp() { 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"); } @@ -134,7 +134,7 @@ template outputHubOp() { 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"); } @@ -142,20 +142,20 @@ template outputHubOp() { 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/src/doc_reform/io_out/rgx.d b/src/doc_reform/io_out/rgx.d index 5024319..e98f118 100644 --- a/src/doc_reform/io_out/rgx.d +++ b/src/doc_reform/io_out/rgx.d @@ -51,8 +51,8 @@ static template spineRgxOut() { static inline_link_number = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used static inline_link_number_only = ctRegex!(`(?P<linked_text>┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links - static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg"); - static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^/]+?#(?P<segname>.+?))├`, "mg"); + static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<hash>\S+?))├`, "mg"); + static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); static url = ctRegex!(`https?://`, "mg"); diff --git a/src/doc_reform/io_out/sqlite.d b/src/doc_reform/io_out/sqlite.d index 392d8b0..99a6b5d 100644 --- a/src/doc_reform/io_out/sqlite.d +++ b/src/doc_reform/io_out/sqlite.d @@ -301,9 +301,9 @@ template SQLiteFormatAndLoadObject() { } 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┝┤" @@ -320,9 +320,9 @@ template SQLiteFormatAndLoadObject() { ~ "/" ~ 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"] ~ "├" ); } @@ -330,9 +330,9 @@ template SQLiteFormatAndLoadObject() { 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 ); } @@ -346,7 +346,7 @@ template SQLiteFormatAndLoadObject() { ~ 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"] ~ "├" ); } @@ -1143,7 +1143,6 @@ template SQLiteInsertMetadata() { SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html) ); 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); @@ -1386,7 +1385,7 @@ template SQLiteInsertDocObjectsLoop() { } } 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()() { @@ -1545,26 +1544,61 @@ 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"); } } } 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); } } } diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 7649d40..c13d31f 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -364,10 +364,10 @@ template outputXHTMLs() { 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, @@ -377,7 +377,7 @@ template outputXHTMLs() { _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" ~ "├" ); @@ -386,9 +386,9 @@ template outputXHTMLs() { 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/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index cf74e23..5c45c96 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -184,13 +184,31 @@ template spineAbstraction() { @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_(); diff --git a/src/doc_reform/meta/metadoc_show_config.d b/src/doc_reform/meta/metadoc_show_config.d index 630fe0c..c642cb9 100644 --- a/src/doc_reform/meta/metadoc_show_config.d +++ b/src/doc_reform/meta/metadoc_show_config.d @@ -1,4 +1,89 @@ module doc_reform.meta.metadoc_show_config; +template spineShowSiteConfig() { + @safe void spineShowSiteConfig(O,T)( + O opt_action, + T config, + ) { + import + doc_reform.meta.defaults, + doc_reform.meta.rgx; + import + std.array, + std.exception, + std.regex, + std.stdio, + std.string, + std.typecons, + std.uni, + std.utf, + std.conv : to; + mixin InternalMarkup; + auto markup = InlineMarkup(); + auto char_repeat_number = 66; + if (opt_action.show_config) { + 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, + ); + } + } +} template spineShowConfig() { @safe void spineShowConfig(T)( T doc_matters, @@ -31,7 +116,7 @@ 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", + "%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, @@ -73,26 +158,8 @@ template spineShowConfig() { 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:", diff --git a/src/doc_reform/meta/metadoc_show_make.d b/src/doc_reform/meta/metadoc_show_make.d index 854552a..ea533d0 100644 --- a/src/doc_reform/meta/metadoc_show_make.d +++ b/src/doc_reform/meta/metadoc_show_make.d @@ -31,7 +31,7 @@ template spineShowMake() { } if (doc_matters.opt.action.show_make) { 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, diff --git a/src/doc_reform/meta/metadoc_show_metadata.d b/src/doc_reform/meta/metadoc_show_metadata.d index 05758b6..f7068c3 100644 --- a/src/doc_reform/meta/metadoc_show_metadata.d +++ b/src/doc_reform/meta/metadoc_show_metadata.d @@ -31,7 +31,7 @@ template spineShowMetaData() { } if (doc_matters.opt.action.show_metadata) { 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/src/doc_reform/meta/metadoc_show_summary.d b/src/doc_reform/meta/metadoc_show_summary.d index f774a6d..2c2202c 100644 --- a/src/doc_reform/meta/metadoc_show_summary.d +++ b/src/doc_reform/meta/metadoc_show_summary.d @@ -52,7 +52,7 @@ template spineMetaDocSummary() { } } 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, diff --git a/src/doc_reform/meta/rgx.d b/src/doc_reform/meta/rgx.d index d4dd201..a5a153e 100644 --- a/src/doc_reform/meta/rgx.d +++ b/src/doc_reform/meta/rgx.d @@ -217,8 +217,8 @@ static template spineRgxIn() { static inline_link_number = ctRegex!(`┥(?P<text>.+?)┝┤(?P<num>[0-9]+)├`, "mg"); // not used static inline_link_number_only = ctRegex!(`(?P<linked_text>┥.+?┝)┤(?P<num>[0-9]+)├`, "mg"); static inline_link_stow_uri = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^ 0-9#┥┝┤├][^ 0-9┥┝┤├]+)├`, "mg"); // will not stow (stowed links) or object number internal links - static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<segname>\S+?))├`, "mg"); - static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>[^/]+?#(?P<segname>.+?))├`, "mg"); + static inline_link_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>#(?P<hash>\S+?))├`, "mg"); + static inline_link_seg_and_hash = ctRegex!(`┥(?P<text>.+?)┝┤(?P<link>(?P<seg>[^/#├]*)#(?P<hash>.+?))├`, "mg"); static inline_link_clean = ctRegex!(`┤(?:.+?)├|[┥┝]`, "mg"); static inline_link_toc_to_backmatter = ctRegex!(`┤#(?P<link>endnotes|bibliography|bookindex|glossary|blurb)├`, "mg"); static url = ctRegex!(`https?://`, "mg"); diff --git a/src/doc_reform/spine.d b/src/doc_reform/spine.d index 3a64726..7539149 100755 --- a/src/doc_reform/spine.d +++ b/src/doc_reform/spine.d @@ -184,7 +184,9 @@ string program_name = "spine"; "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"], @@ -197,6 +199,7 @@ string program_name = "spine"; "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"], @@ -205,8 +208,9 @@ string program_name = "spine"; "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"], @@ -236,16 +240,12 @@ string program_name = "spine"; "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); @@ -505,6 +505,28 @@ string program_name = "spine"; || 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"] @@ -556,33 +578,53 @@ string program_name = "spine"; ]; 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); + } + 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); + 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 @@ -731,19 +773,6 @@ string program_name = "spine"; } } } - 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"); - } - } if (_manifests.length > 1 // _manifests[0] initialized dummy element && _opt_action.abstraction) { if (_opt_action.parallelise) { // see else @@ -795,20 +824,17 @@ string program_name = "spine"; spineMetaDocSummary!()(doc_abstraction, doc_matters); } /+ ↓ 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); } /+ ↓ 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); } /+ ↓ 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); } @@ -910,20 +936,17 @@ string program_name = "spine"; spineMetaDocSummary!()(doc_abstraction, doc_matters); } /+ ↓ 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); } /+ ↓ 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); } /+ ↓ 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); } |