diff options
Diffstat (limited to 'src/doc_reform/io_out')
-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 |
4 files changed, 72 insertions, 38 deletions
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 ); } |