diff options
Diffstat (limited to 'src/doc_reform/io_out/sqlite.d')
-rw-r--r-- | src/doc_reform/io_out/sqlite.d | 80 |
1 files changed, 57 insertions, 23 deletions
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); } } } |