diff options
author | Ralph Amissah <ralph.amissah@gmail.com> | 2018-09-28 17:05:34 -0400 |
---|---|---|
committer | Ralph Amissah <ralph.amissah@gmail.com> | 2019-04-10 15:14:15 -0400 |
commit | 08a374929fdfd11b2546636a9151518491457f18 (patch) | |
tree | 31b97119fcd3d3e37a94cee5becdc841745ba693 /org/output_sqlite.org | |
parent | doc_abstraction provide object with segment it occurs in (diff) |
output xmls & sqlite, make doc_matter available
Diffstat (limited to 'org/output_sqlite.org')
-rw-r--r-- | org/output_sqlite.org | 157 |
1 files changed, 87 insertions, 70 deletions
diff --git a/org/output_sqlite.org b/org/output_sqlite.org index 8d792c6..566b960 100644 --- a/org/output_sqlite.org +++ b/org/output_sqlite.org @@ -31,18 +31,18 @@ mixin DocReformOutputRgxInit; static auto rgx = Rgx(); long _metadata_tid_lastrowid; template SQLiteHubBuildTablesAndPopulate() { - void SQLiteHubBuildTablesAndPopulate(D,I)( + void SQLiteHubBuildTablesAndPopulate(M,D)( + M doc_matters, D doc_abstraction, - I doc_matters, ) { auto pth_sqlite = DocReformPathsSQLite!()(doc_matters.sqlite.filename, doc_matters.output_path); pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file); template SQLiteDbStatementComposite() { - void SQLiteDbStatementComposite(Db,D,I)( + void SQLiteDbStatementComposite(Db,M,D)( Db db, + M doc_matters, D doc_abstraction, - I doc_matters, ) { <<sqlite_db_statement_composite_collection>> if (!(doc_matters.opt.action.quiet)) { @@ -50,7 +50,7 @@ template SQLiteHubBuildTablesAndPopulate() { } } } - SQLiteDbStatementComposite!()(db, doc_abstraction, doc_matters); + SQLiteDbStatementComposite!()(db, doc_matters, doc_abstraction); } } #+END_SRC @@ -59,18 +59,18 @@ template SQLiteHubBuildTablesAndPopulate() { #+BEGIN_SRC d :tangle ../src/doc_reform/output/sqlite.d template SQLiteHubDiscreteBuildTablesAndPopulate() { - void SQLiteHubDiscreteBuildTablesAndPopulate(D,I)( + void SQLiteHubDiscreteBuildTablesAndPopulate(M,D)( + M doc_matters, D doc_abstraction, - I doc_matters, ) { auto pth_sqlite = DocReformPathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename)); template SQLiteDiscreteDbStatementComposite() { - void SQLiteDiscreteDbStatementComposite(Db,D,I)( + void SQLiteDiscreteDbStatementComposite(Db,M,D)( Db db, + M doc_matters, D doc_abstraction, - I doc_matters, ) { <<sqlite_db_statement_composite_discrete>> if (!(doc_matters.opt.action.quiet)) { @@ -78,7 +78,7 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() { } } } - SQLiteDiscreteDbStatementComposite!()(db, doc_abstraction, doc_matters); + SQLiteDiscreteDbStatementComposite!()(db, doc_matters, doc_abstraction); } } #+END_SRC @@ -132,8 +132,8 @@ template SQLinsertDelimiter() { } } template SQLiteFormatAndLoadObject() { - auto SQLiteFormatAndLoadObject(I)( - I doc_matters, + auto SQLiteFormatAndLoadObject(M)( + M doc_matters, ) { mixin DocReformOutputRgxInit; struct sqlite_format_and_load_objects { @@ -171,8 +171,8 @@ template SQLiteTablesReCreate() { #+BEGIN_SRC d :tangle ../src/doc_reform/output/sqlite.d template SQLiteDeleteDocument() { - string SQLiteDeleteDocument(I)( - I doc_matters, + string SQLiteDeleteDocument(M)( + M doc_matters, ) { <<sqlite_formatted_delete>> return _delete_uid; @@ -184,8 +184,8 @@ template SQLiteDeleteDocument() { #+BEGIN_SRC d :tangle ../src/doc_reform/output/sqlite.d template SQLiteInsertMetadata() { - string SQLiteInsertMetadata(I)( - I doc_matters, + string SQLiteInsertMetadata(M)( + M doc_matters, ) { <<sqlite_formatted_insertions_doc_matters_metadata>> return _insert_metadata; @@ -197,9 +197,9 @@ template SQLiteInsertMetadata() { #+BEGIN_SRC d :tangle ../src/doc_reform/output/sqlite.d template SQLiteInsertDocObjectsLoop() { - string SQLiteInsertDocObjectsLoop(D,I)( + string SQLiteInsertDocObjectsLoop(M,D)( + M doc_matters, D doc_abstraction, - I doc_matters, ) { string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); string insertDocObjectsRow(O)(O obj) { @@ -287,7 +287,7 @@ template SQLiteDbDrop() { _db_statement ~= SQLiteInsertMetadata!()(doc_matters); SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT MetaData"); /+ get tid (lastrowid or max) for use in doc_objects table +/ - _db_statement ~= SQLiteInsertDocObjectsLoop!()(doc_abstraction, doc_matters); + _db_statement ~= SQLiteInsertDocObjectsLoop!()(doc_matters, doc_abstraction); SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "INSERT DocObjects"); } } @@ -304,7 +304,7 @@ template SQLiteDbDrop() { { _db_statement ~= SQLiteTablesReCreate!()(); _db_statement ~= SQLiteInsertMetadata!()(doc_matters); - _db_statement ~= SQLiteInsertDocObjectsLoop!()(doc_abstraction, doc_matters); + _db_statement ~= SQLiteInsertDocObjectsLoop!()(doc_matters, doc_abstraction); SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "table CREATE Tables, INSERT DocObjects"); } db.close; @@ -383,7 +383,8 @@ light html objects #+name: sanitize_and_munge_inline_html #+BEGIN_SRC d -auto munge_html(O)( +auto munge_html(M,O)( + M doc_matters, auto ref const O obj, ) { string _html_special_characters(string _txt){ @@ -490,10 +491,11 @@ string html_font_face(string _txt){ #+name: html_objects #+BEGIN_SRC d -auto html_heading(O)( +auto html_heading(M,O)( + M doc_matters, auto ref const O obj, ) { - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); string o = format(q"¶<p class="%s"><b> %s </b></p>¶", @@ -508,11 +510,12 @@ auto html_heading(O)( ##+name: prepare_objects_html #+BEGIN_SRC d -auto html_heading(O)( +auto html_heading(M,O)( + M doc_matters, auto ref const O obj, ) { string o; - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); o = format(q"¶<h%s class="%s"> %s </h%s>¶", @@ -529,10 +532,11 @@ auto html_heading(O)( #+name: html_objects #+BEGIN_SRC d -auto html_para(O)( +auto html_para(M,O)( + M doc_matters, auto ref const O obj, ) { - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); _txt = (obj.attrib.bullet) ? ("●  " ~ _txt) : _txt; string o = format(q"¶<p class="%s" indent="h%si%s"> %s @@ -550,10 +554,11 @@ auto html_para(O)( #+name: html_objects #+BEGIN_SRC d -auto html_quote(O)( +auto html_quote(M,O)( + M doc_matters, auto ref const O obj, ) { - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); string o = format(q"¶<p class="%s"> %s </p>¶", @@ -568,10 +573,11 @@ auto html_quote(O)( #+name: html_objects #+BEGIN_SRC d -auto html_group(O)( +auto html_group(M,O)( + M doc_matters, auto ref const O obj, ) { - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); string o = format(q"¶<p class="%s"> %s </p>¶", @@ -586,10 +592,11 @@ auto html_group(O)( #+name: html_objects #+BEGIN_SRC d -auto html_block(O)( +auto html_block(M,O)( + M doc_matters, auto ref const O obj, ) { - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); string o = format(q"¶ <p class="%s">%s</p>¶", obj.metainfo.is_a, @@ -603,10 +610,11 @@ auto html_block(O)( #+name: html_objects #+BEGIN_SRC d -auto html_verse(O)( +auto html_verse(M,O)( + M doc_matters, auto ref const O obj, ) { - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); string o = format(q"¶<p class="%s">%s</p>¶", obj.metainfo.is_a, _txt @@ -635,7 +643,8 @@ auto html_code(O)( #+name: html_objects #+BEGIN_SRC d -auto html_table(O)( +auto html_table(M,O)( + M doc_matters, auto ref const O obj, ) { auto _tablarize(O)( @@ -679,7 +688,7 @@ auto html_table(O)( ); return t; } - string _txt = munge_html(obj); + string _txt = munge_html(doc_matters, obj); auto t = _tablarize(obj, _txt); _txt = t[0]; string _note = t[1]; @@ -702,9 +711,9 @@ auto html_table(O)( #+name: sqlite_load_object #+BEGIN_SRC d -auto sqlite_load_string(O,Dm)( +auto sqlite_load_string(M,O)( + auto ref M doc_matters, auto ref const O obj, - auto ref Dm doc_matters, ) { string o; return o; @@ -713,9 +722,9 @@ auto sqlite_load_string(O,Dm)( #+name: sqlite_load_object #+BEGIN_SRC d -auto postgresql_load_string(O,Dm)( +auto postgresql_load_string(M,O)( + auto ref M doc_matters, auto ref const O obj, - auto ref Dm doc_matters, ) { string o; return o; @@ -744,12 +753,13 @@ string sqlite_statement(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto heading(O)( +auto heading(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_heading(obj) + "html": html_heading(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -769,12 +779,13 @@ auto heading(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto para(O)( +auto para(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_para(obj) + "html": html_para(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -794,12 +805,13 @@ auto para(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto quote(O)( +auto quote(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_quote(obj) + "html": html_quote(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -818,12 +830,13 @@ auto quote(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto group(O)( +auto group(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_group(obj) + "html": html_group(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -843,12 +856,13 @@ auto group(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto block(O)( +auto block(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_block(obj) + "html": html_block(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -868,12 +882,13 @@ auto block(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto verse(O)( +auto verse(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_verse(obj) + "html": html_verse(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -893,7 +908,8 @@ auto verse(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto code(O)( +auto code(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ @@ -918,12 +934,13 @@ auto code(O)( #+name: hub_format_and_sqlite_load_objects #+BEGIN_SRC d -auto table(O)( +auto table(M,O)( + M doc_matters, auto ref const O obj, ) { string[string] obj_txt = [ "text": generic_munge_sanitize_text_for_search(obj.text), - "html": html_table(obj) + "html": html_table(doc_matters, obj) ]; if (doc_matters.opt.action.debug_do) { debug(sql_txt) { @@ -955,7 +972,7 @@ foreach (part; doc_matters.xml.keys_seq.sql) { case "para": switch (obj.metainfo.is_a) { case "heading": - obj_txt = format_and_sqlite_load.heading(obj); + obj_txt = format_and_sqlite_load.heading(doc_matters, obj); break; default: if ((doc_matters.opt.action.debug_do)) { @@ -981,10 +998,10 @@ foreach (part; doc_matters.xml.keys_seq.sql) { writeln(__LINE__, ": ", obj.text); } } - obj_txt = format_and_sqlite_load.heading(obj); + obj_txt = format_and_sqlite_load.heading(doc_matters, obj); break; case "para": - obj_txt = format_and_sqlite_load.para(obj); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; default: if ((doc_matters.opt.action.debug_do)) { @@ -996,24 +1013,24 @@ foreach (part; doc_matters.xml.keys_seq.sql) { case "block": switch (obj.metainfo.is_a) { case "quote": - obj_txt = format_and_sqlite_load.quote(obj); + obj_txt = format_and_sqlite_load.quote(doc_matters, obj); break; case "group": - obj_txt = format_and_sqlite_load.group(obj); + obj_txt = format_and_sqlite_load.group(doc_matters, obj); break; case "block": - obj_txt = format_and_sqlite_load.block(obj); + obj_txt = format_and_sqlite_load.block(doc_matters, obj); break; case "poem": // double check on keeping both poem & verse break; case "verse": - obj_txt = format_and_sqlite_load.verse(obj); + obj_txt = format_and_sqlite_load.verse(doc_matters, obj); break; case "code": - obj_txt = format_and_sqlite_load.code(obj); + obj_txt = format_and_sqlite_load.code(doc_matters, obj); break; case "table": - obj_txt = format_and_sqlite_load.table(obj); + obj_txt = format_and_sqlite_load.table(doc_matters, obj); break; default: if ((doc_matters.opt.action.debug_do)) { @@ -1035,19 +1052,19 @@ foreach (part; doc_matters.xml.keys_seq.sql) { case "para": switch (obj.metainfo.is_a) { case "heading": - obj_txt = format_and_sqlite_load.heading(obj); + obj_txt = format_and_sqlite_load.heading(doc_matters, obj); break; case "glossary": assert(part == "glossary", part); - obj_txt = format_and_sqlite_load.para(obj); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; case "bibliography": assert(part == "bibliography", part); - obj_txt = format_and_sqlite_load.para(obj); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; case "bookindex": assert(part == "bookindex_seg", part); - obj_txt = format_and_sqlite_load.para(obj); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; case "blurb": assert(part == "blurb", part); - obj_txt = format_and_sqlite_load.para(obj); + obj_txt = format_and_sqlite_load.para(doc_matters, obj); break; default: if ((doc_matters.opt.action.debug_do)) { |