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 /org/out_sqlite.org | |
parent | sql, sqlite internal site links (diff) |
config, where used without document processing
Diffstat (limited to 'org/out_sqlite.org')
-rw-r--r-- | org/out_sqlite.org | 80 |
1 files changed, 57 insertions, 23 deletions
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); |