aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/output/sqlite.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2018-09-28 17:05:34 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-04-10 15:14:15 -0400
commit08a374929fdfd11b2546636a9151518491457f18 (patch)
tree31b97119fcd3d3e37a94cee5becdc841745ba693 /src/doc_reform/output/sqlite.d
parentdoc_abstraction provide object with segment it occurs in (diff)
output xmls & sqlite, make doc_matter available
Diffstat (limited to 'src/doc_reform/output/sqlite.d')
-rw-r--r--src/doc_reform/output/sqlite.d152
1 files changed, 84 insertions, 68 deletions
diff --git a/src/doc_reform/output/sqlite.d b/src/doc_reform/output/sqlite.d
index 6fbb4a7..b317dc0 100644
--- a/src/doc_reform/output/sqlite.d
+++ b/src/doc_reform/output/sqlite.d
@@ -9,18 +9,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,
) {
{
string _db_statement;
@@ -41,7 +41,7 @@ template SQLiteHubBuildTablesAndPopulate() {
_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");
}
}
@@ -52,29 +52,29 @@ template SQLiteHubBuildTablesAndPopulate() {
}
}
}
- SQLiteDbStatementComposite!()(db, doc_abstraction, doc_matters);
+ SQLiteDbStatementComposite!()(db, doc_matters, doc_abstraction);
}
}
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,
) {
{
string _db_statement;
{
_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;
@@ -84,7 +84,7 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() {
}
}
}
- SQLiteDiscreteDbStatementComposite!()(db, doc_abstraction, doc_matters);
+ SQLiteDiscreteDbStatementComposite!()(db, doc_matters, doc_abstraction);
}
}
template SQLiteDbRun() {
@@ -128,8 +128,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 {
@@ -166,7 +166,8 @@ template SQLiteFormatAndLoadObject() {
}
return _txt;
}
- auto munge_html(O)(
+ auto munge_html(M,O)(
+ M doc_matters,
auto ref const O obj,
) {
string _html_special_characters(string _txt){
@@ -248,10 +249,11 @@ template SQLiteFormatAndLoadObject() {
.replaceAll(rgx.inline_cite, "<cite>$1</cite>");
return _txt;
}
- 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>¶",
@@ -260,10 +262,11 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- 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) ? ("●&#160;&#160;" ~ _txt) : _txt;
string o = format(q"¶<p class="%s" indent="h%si%s">
%s
@@ -275,10 +278,11 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- 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>¶",
@@ -287,10 +291,11 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- 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>¶",
@@ -299,10 +304,11 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- 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,
@@ -310,10 +316,11 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- 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
@@ -330,7 +337,8 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- auto html_table(O)(
+ auto html_table(M,O)(
+ M doc_matters,
auto ref const O obj,
) {
auto _tablarize(O)(
@@ -374,7 +382,7 @@ template SQLiteFormatAndLoadObject() {
);
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];
@@ -390,16 +398,16 @@ template SQLiteFormatAndLoadObject() {
);
return o;
}
- 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;
}
- 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;
@@ -418,12 +426,13 @@ template SQLiteFormatAndLoadObject() {
string _sql;
return _sql;
}
- 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) {
@@ -437,12 +446,13 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- 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) {
@@ -456,12 +466,13 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- 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) {
@@ -475,12 +486,13 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- 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) {
@@ -494,12 +506,13 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- 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) {
@@ -513,12 +526,13 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- 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) {
@@ -532,7 +546,8 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- auto code(O)(
+ auto code(M,O)(
+ M doc_matters,
auto ref const O obj,
) {
string[string] obj_txt = [
@@ -551,12 +566,13 @@ template SQLiteFormatAndLoadObject() {
}
return obj_txt;
}
- 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) {
@@ -712,8 +728,8 @@ template SQLiteTablesReCreate() {
}
}
template SQLiteDeleteDocument() {
- string SQLiteDeleteDocument(I)(
- I doc_matters,
+ string SQLiteDeleteDocument(M)(
+ M doc_matters,
) {
string _uid = doc_matters.src.doc_uid;
string _delete_uid = format(q"¶
@@ -729,8 +745,8 @@ template SQLiteDeleteDocument() {
}
}
template SQLiteInsertMetadata() {
- string SQLiteInsertMetadata(I)(
- I doc_matters,
+ string SQLiteInsertMetadata(M)(
+ M doc_matters,
) {
string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid);
string _insert_metadata = format(q"¶
@@ -885,9 +901,9 @@ template SQLiteInsertMetadata() {
}
}
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) {
@@ -933,7 +949,7 @@ template SQLiteInsertDocObjectsLoop() {
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)) {
@@ -959,10 +975,10 @@ template SQLiteInsertDocObjectsLoop() {
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)) {
@@ -974,24 +990,24 @@ template SQLiteInsertDocObjectsLoop() {
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)) {
@@ -1013,19 +1029,19 @@ template SQLiteInsertDocObjectsLoop() {
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)) {