diff options
Diffstat (limited to 'org/out_sqlite.org')
-rw-r--r-- | org/out_sqlite.org | 133 |
1 files changed, 66 insertions, 67 deletions
diff --git a/org/out_sqlite.org b/org/out_sqlite.org index 5e56ad1..14e3ab0 100644 --- a/org/out_sqlite.org +++ b/org/out_sqlite.org @@ -4,16 +4,15 @@ #+FILETAGS: :spine:output:db:sql:sqlite: #+AUTHOR: Ralph Amissah #+EMAIL: [[mailto:ralph.amissah@gmail.com][ralph.amissah@gmail.com]] -#+COPYRIGHT: Copyright (C) 2015 - 2019 Ralph Amissah +#+COPYRIGHT: Copyright (C) 2015 - 2020 Ralph Amissah #+LANGUAGE: en -#+STARTUP: indent content hideblocks hidestars -#+OPTIONS: H:3 num:nil toc:t \n:nil @:t ::t |:t ^:nil _:nil -:t f:t *:t <:t -#+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc -#+OPTIONS: author:nil email:nil creator:nil timestamp:nil -#+PROPERTY: header-args :padline no :exports code :cache no :noweb yes -#+EXPORT_SELECT_TAGS: export -#+EXPORT_EXCLUDE_TAGS: noexport -#+TAGS: assert(a) class(c) debug(d) mixin(m) spine(s) tangle(T) template(t) WEB(W) noexport(n) +#+STARTUP: content hideblocks hidestars noindent entitiespretty +#+PROPERTY: header-args :exports code +#+PROPERTY: header-args+ :noweb yes +#+PROPERTY: header-args+ :eval no +#+PROPERTY: header-args+ :results no +#+PROPERTY: header-args+ :cache no +#+PROPERTY: header-args+ :padline no - [[./spine.org][spine]] [[./][org/]] - [[./output_hub.org][output_hub]] @@ -277,7 +276,7 @@ template SQLiteDbDrop() { ** 1. [#A] sqlite_db_statement :statement: *** collection -#+name: sqlite_db_statement_composite_collection +#+NAME: sqlite_db_statement_composite_collection #+BEGIN_SRC d { string _db_statement; @@ -308,7 +307,7 @@ template SQLiteDbDrop() { *** discrete -#+name: sqlite_db_statement_composite_discrete +#+NAME: sqlite_db_statement_composite_discrete #+BEGIN_SRC d { string _db_statement; @@ -324,7 +323,7 @@ template SQLiteDbDrop() { ** 2. imports -#+name: output_imports +#+NAME: output_imports #+BEGIN_SRC d import doc_reform.io_out; import @@ -347,7 +346,7 @@ import - [X] clean url markers, leave plain link text - [X] place urls after text object and its endnotes -#+name: sanitize_text_for_search +#+NAME: sanitize_text_for_search #+BEGIN_SRC d string generic_munge_sanitize_text_for_search( string _txt, @@ -396,7 +395,7 @@ light html objects ***** munge ****** general munge (special characters, inline markup, move notes) -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string munge_html(M,O)( M doc_matters, @@ -450,7 +449,7 @@ string munge_html(M,O)( ****** special characters -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string html_special_characters(string _txt){ _txt = _txt @@ -466,7 +465,7 @@ string html_special_characters(string _txt){ ****** special characters for code -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string html_special_characters_code(string _txt){ _txt = _txt @@ -481,7 +480,7 @@ string html_special_characters_code(string _txt){ ****** font_face -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string html_font_face(string _txt){ _txt = _txt @@ -502,7 +501,7 @@ string html_font_face(string _txt){ ****** inline markup ******* images -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string inline_images(M,O)( M doc_matters, @@ -533,7 +532,7 @@ string inline_images(M,O)( ******* links ******** scroll, seg, epub -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string inline_links(M,O)( M doc_matters, @@ -641,7 +640,7 @@ string inline_links(M,O)( ******* notes ******** scroll -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string inline_notes_scroll(M,O)( M doc_matters, @@ -671,7 +670,7 @@ string inline_notes_scroll(M,O)( ******** seg -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d Tuple!(string, string[]) inline_notes_seg(M,O)( M doc_matters, @@ -716,7 +715,7 @@ Tuple!(string, string[]) inline_notes_seg(M,O)( ******* inline markup -#+name: sanitize_and_munge_inline_html +#+NAME: sanitize_and_munge_inline_html #+BEGIN_SRC d string xml_type="seg"; /+ set html document type to be linked to here (seg|scroll) +/ string inline_markup(M,O)( @@ -734,7 +733,7 @@ string inline_markup(M,O)( ***** objects ****** heading -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_heading(M,O)( M doc_matters, @@ -758,7 +757,7 @@ string html_heading(M,O)( ******* +fancy+ -##+name: prepare_objects_html +##+NAME: prepare_objects_html #+BEGIN_SRC d string html_heading(M,O)( M doc_matters, @@ -780,7 +779,7 @@ string html_heading(M,O)( ****** para -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_para(M,O)( M doc_matters, @@ -807,7 +806,7 @@ string html_para(M,O)( ****** quote -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_quote(M,O)( M doc_matters, @@ -830,7 +829,7 @@ string html_quote(M,O)( ****** group -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_group(M,O)( M doc_matters, @@ -853,7 +852,7 @@ string html_group(M,O)( ****** block -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_block(M,O)( M doc_matters, @@ -875,7 +874,7 @@ string html_block(M,O)( ****** verse -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_verse(M,O)( M doc_matters, @@ -896,7 +895,7 @@ string html_verse(M,O)( ****** code -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_code(O)( const O obj, @@ -916,7 +915,7 @@ string html_code(O)( ****** table -#+name: html_objects +#+NAME: html_objects #+BEGIN_SRC d string html_table(M,O)( M doc_matters, @@ -988,7 +987,7 @@ string html_table(M,O)( *** 2. hub (sqlite_format_and_load_objects) **** sql related -#+name: sqlite_load_object +#+NAME: sqlite_load_object #+BEGIN_SRC d string sqlite_load_string(M,O)( M doc_matters, @@ -999,7 +998,7 @@ string sqlite_load_string(M,O)( } #+END_SRC -#+name: sqlite_load_object +#+NAME: sqlite_load_object #+BEGIN_SRC d string postgresql_load_string(M,O)( M doc_matters, @@ -1010,7 +1009,7 @@ string postgresql_load_string(M,O)( } #+END_SRC -#+name: sqlite_load_object +#+NAME: sqlite_load_object #+BEGIN_SRC d string sqlite_statement(O)( const O obj, @@ -1030,7 +1029,7 @@ string sqlite_statement(O)( **** heading -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] heading(M,O)( M doc_matters, @@ -1059,7 +1058,7 @@ string[string] heading(M,O)( **** para -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] para(M,O)( M doc_matters, @@ -1088,7 +1087,7 @@ string[string] para(M,O)( **** quote -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] quote(M,O)( M doc_matters, @@ -1116,7 +1115,7 @@ string[string] quote(M,O)( #+END_SRC **** group -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] group(M,O)( M doc_matters, @@ -1145,7 +1144,7 @@ string[string] group(M,O)( **** block -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] block(M,O)( M doc_matters, @@ -1174,7 +1173,7 @@ string[string] block(M,O)( **** verse -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] verse(M,O)( M doc_matters, @@ -1203,7 +1202,7 @@ string[string] verse(M,O)( **** code -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] code(M,O)( M doc_matters, @@ -1232,7 +1231,7 @@ string[string] code(M,O)( **** table -#+name: hub_format_and_sqlite_load_objects +#+NAME: hub_format_and_sqlite_load_objects #+BEGIN_SRC d string[string] table(M,O)( M doc_matters, @@ -1261,7 +1260,7 @@ string[string] table(M,O)( ** 4. ↻ loop, identify, load - loop template -#+name: sqlite_objects_loop +#+NAME: sqlite_objects_loop #+BEGIN_SRC d auto format_and_sqlite_load = SQLiteFormatAndLoadObject!()(doc_matters); string[string] obj_txt; @@ -1444,7 +1443,7 @@ return _insert_doc_objects.join.to!(char[]).toUTF8; *** drop index and tables **** DROP INDEX IF EXISTS -#+name: sqlite_statement_drop_existing_index +#+NAME: sqlite_statement_drop_existing_index #+BEGIN_SRC sql DROP INDEX IF EXISTS idx_ocn; DROP INDEX IF EXISTS idx_uid; @@ -1460,7 +1459,7 @@ DROP INDEX IF EXISTS idx_classify_topic_register; **** DROP TABLE IF EXISTS -#+name: sqlite_statement_drop_existing_tables +#+NAME: sqlite_statement_drop_existing_tables #+BEGIN_SRC sql DROP TABLE IF EXISTS metadata_and_text; DROP TABLE IF EXISTS topic_register; @@ -1471,7 +1470,7 @@ DROP TABLE IF EXISTS urls; *** create tables and index **** CREATE TABLE metadata_and_text -#+name: sqlite_statement_create_table_metadata_and_src_txt +#+NAME: sqlite_statement_create_table_metadata_and_src_txt #+BEGIN_SRC sql CREATE TABLE metadata_and_text ( uid VARCHAR(256) UNIQUE, -- filename, language char, pod/txt (decide on delimiter [,;:/]) @@ -1564,7 +1563,7 @@ CREATE TABLE metadata_and_text ( **** CREATE TABLE topic_register -#+name: sqlite_statement_create_table_topic_register +#+NAME: sqlite_statement_create_table_topic_register #+BEGIN_SRC sql CREATE TABLE topic_register ( -- tid BIGINT PRIMARY KEY, @@ -1584,7 +1583,7 @@ CREATE TABLE topic_register ( **** CREATE TABLE site_urls ? -#+name: sqlite_statement_create_table_site_urls +#+NAME: sqlite_statement_create_table_site_urls #+BEGIN_SRC sql CREATE TABLE site_urls ( -- tid BIGINT PRIMARY KEY, @@ -1599,7 +1598,7 @@ CREATE TABLE site_urls ( **** CREATE TABLE doc_objects -#+name: sqlite_statement_create_table_objects +#+NAME: sqlite_statement_create_table_objects #+BEGIN_SRC sql CREATE TABLE doc_objects ( lid BIGINT PRIMARY KEY, @@ -1625,7 +1624,7 @@ CREATE TABLE doc_objects ( **** CREATE INDEX -#+name: sqlite_statement_create_index +#+NAME: sqlite_statement_create_index #+BEGIN_SRC sql CREATE INDEX idx_ocn ON doc_objects(ocn); CREATE INDEX idx_digest_clean ON doc_objects(digest_clean); @@ -1645,7 +1644,7 @@ CREATE INDEX idx_topics ON metadata_and_text(classify_topic_register); **** DELETE uid rows doc matters & metadata ***** sql statement: dlang format -#+name: sqlite_formatted_delete +#+NAME: sqlite_formatted_delete #+BEGIN_SRC d string _uid = doc_matters.src.doc_uid; string _delete_uid = format(q"┃ @@ -1653,7 +1652,7 @@ string _delete_uid = format(q"┃ ***** DELETE FROM ... WHERE -#+name: sqlite_formatted_delete +#+NAME: sqlite_formatted_delete #+BEGIN_SRC sql DELETE FROM metadata_and_text WHERE uid = '%s'; @@ -1663,7 +1662,7 @@ WHERE uid_metadata_and_text = '%s'; ***** VALUES -#+name: sqlite_formatted_delete +#+NAME: sqlite_formatted_delete #+BEGIN_SRC d ┃", _uid, @@ -1675,7 +1674,7 @@ WHERE uid_metadata_and_text = '%s'; **** INSERT doc matters & metadata ***** sql statement: dlang format -#+name: sqlite_formatted_insertions_doc_matters_metadata +#+NAME: sqlite_formatted_insertions_doc_matters_metadata #+BEGIN_SRC d string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid); string _insert_metadata = format(q"┃ @@ -1683,7 +1682,7 @@ string _insert_metadata = format(q"┃ ***** INSERT INTO -#+name: sqlite_formatted_insertions_doc_matters_metadata +#+NAME: sqlite_formatted_insertions_doc_matters_metadata #+BEGIN_SRC sql INSERT INTO metadata_and_text ( uid, @@ -1739,7 +1738,7 @@ string _insert_metadata = format(q"┃ ***** VALUES -#+name: sqlite_formatted_insertions_doc_matters_metadata +#+NAME: sqlite_formatted_insertions_doc_matters_metadata #+BEGIN_SRC sql VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' @@ -1748,7 +1747,7 @@ string _insert_metadata = format(q"┃ ***** dlang values for formatting -#+name: sqlite_formatted_insertions_doc_matters_metadata +#+NAME: sqlite_formatted_insertions_doc_matters_metadata #+BEGIN_SRC d ┃", _uid, @@ -1808,7 +1807,7 @@ writeln(doc_matters.conf_make_meta.meta.classify_topic_register_arr); ***** { if topic register then loop topic register array -#+name: sqlite_formatted_insertions_topic_register +#+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC d if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { @@ -1819,14 +1818,14 @@ if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { ***** sql statement: dlang format -#+name: sqlite_formatted_insertions_topic_register +#+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC d _insert_topics ~= format(q"┃ #+END_SRC ***** INSERT INTO -#+name: sqlite_formatted_insertions_topic_register +#+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC sql INSERT INTO topic_register ( uid_metadata_and_text, @@ -1840,7 +1839,7 @@ _insert_topics ~= format(q"┃ ***** VALUES -#+name: sqlite_formatted_insertions_topic_register +#+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC sql VALUES ( '%s', '%s', '%s', '%s', '%s', '%s' @@ -1849,7 +1848,7 @@ _insert_topics ~= format(q"┃ ***** dlang values for formatting -#+name: sqlite_formatted_insertions_topic_register +#+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC d ┃", _uid, @@ -1863,7 +1862,7 @@ _insert_topics ~= format(q"┃ ***** } close topic register & loop topic register array -#+name: sqlite_formatted_insertions_topic_register +#+NAME: sqlite_formatted_insertions_topic_register #+BEGIN_SRC d } } @@ -1880,14 +1879,14 @@ either: ***** sql statement: dlang format -#+name: sqlite_formatted_insertions_doc_objects +#+NAME: sqlite_formatted_insertions_doc_objects #+BEGIN_SRC d string _insert_doc_objects_row = format(q"┃ #+END_SRC ***** INSERT INTO -#+name: sqlite_formatted_insertions_doc_objects +#+NAME: sqlite_formatted_insertions_doc_objects #+BEGIN_SRC sql INSERT INTO doc_objects ( uid_metadata_and_text, @@ -1904,7 +1903,7 @@ string _insert_doc_objects_row = format(q"┃ ***** VALUES -#+name: sqlite_formatted_insertions_doc_objects +#+NAME: sqlite_formatted_insertions_doc_objects #+BEGIN_SRC sql VALUES ( '%s', %s, '%s', '%s', '%s', %s, '%s', '%s', '%s' @@ -1913,7 +1912,7 @@ string _insert_doc_objects_row = format(q"┃ ***** dlang values for formatting -#+name: sqlite_formatted_insertions_doc_objects +#+NAME: sqlite_formatted_insertions_doc_objects #+BEGIN_SRC d ┃", _uid, |