aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/out_sqlite.org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2020-03-29 18:29:44 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2020-05-20 11:27:23 -0400
commiteed0938b23d13ec4f2ef4588ccdb2e7abc0c1552 (patch)
tree4e015ce076795100792412b76156330e80440c37 /org/out_sqlite.org
parentmeson using dub (diff)
0.10.0 search sqlite & cgi
Diffstat (limited to 'org/out_sqlite.org')
-rw-r--r--org/out_sqlite.org119
1 files changed, 88 insertions, 31 deletions
diff --git a/org/out_sqlite.org b/org/out_sqlite.org
index 32daf8e..944ed18 100644
--- a/org/out_sqlite.org
+++ b/org/out_sqlite.org
@@ -17,19 +17,61 @@
- [[./spine.org][spine]] [[./][org/]]
- [[./output_hub.org][output_hub]]
+sudo chown ralph:ralph /var/www
+
+- create db
+ ~dr/bin/spine-ldc -v \
+ --sqlite-db-create --sqlite-db-filename="spine.search.db" \
+ --output=/var/www/html \
+ ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/*
+
+- update db
+ ~dr/bin/spine-ldc -v \
+ --sqlite-update --sqlite-db-filename="spine.search.db" \
+ --output=/var/www/html \
+ ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/*
+
+- produce html (and some other) output files
+ ~dr/bin/spine-ldc -v --html --epub --latex --odt \
+ --output=/var/www \
+ ~grotto/repo/git.repo/code/project-spine/doc-reform-markup/markup_samples/markup/pod/*
+
* sql
** _module, templates_ :module:
-*** hub
-**** collection
+*** template
#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
module doc_reform.io_out.sqlite;
-<<output_imports>>
+<<sqlite_imports>>
+<<sqlite_common>>
+<<sqlite_collection>>
+<<sqlite_discrete>>
+<<sqlite_run>>
+<<sqlite_munge>>
+<<sqlite_create>>
+<<sqlite_delete>>
+<<sqlite_insert>>
+<<sqlite_insert_doc_objects_loop>>
+<<sqlite_tables_create>>
+<<sqlite_tables_drop>>
+#+END_SRC
+
+*** hub
+**** common
+
+#+NAME: sqlite_common
+#+BEGIN_SRC d
mixin spineRgxOut;
mixin InternalMarkup;
static auto rgx = RgxO();
static auto mkup = InlineMarkup();
long _metadata_tid_lastrowid;
+#+END_SRC
+
+**** collection
+
+#+NAME: sqlite_collection
+#+BEGIN_SRC d
template SQLiteHubBuildTablesAndPopulate() {
void SQLiteHubBuildTablesAndPopulate(D,M)(
const D doc_abstraction,
@@ -57,13 +99,14 @@ template SQLiteHubBuildTablesAndPopulate() {
**** discrete
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_discrete
+#+BEGIN_SRC d
template SQLiteHubDiscreteBuildTablesAndPopulate() {
void SQLiteHubDiscreteBuildTablesAndPopulate(D,M)(
const D doc_abstraction,
M doc_matters,
) {
- auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.webserv_url_doc_root, doc_matters.src.language);
+ auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url, doc_matters.src.language);
auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language);
pth_sqlite.base.mkdirRecurse;
auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename));
@@ -86,7 +129,8 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() {
*** db run
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_run
+#+BEGIN_SRC d
template SQLiteDbRun() {
void SQLiteDbRun(Db,St,O)(
Db db,
@@ -127,7 +171,8 @@ template SQLiteDbRun() {
*** munge
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_munge
+#+BEGIN_SRC d
template SQLinsertDelimiter() {
string SQLinsertDelimiter(string _txt) {
_txt = _txt
@@ -155,7 +200,8 @@ template SQLiteFormatAndLoadObject() {
*** sqlite instructions
**** create
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_create
+#+BEGIN_SRC d
template SQLiteTablesReCreate() {
string SQLiteTablesReCreate()() {
string _sql_instruct;
@@ -174,7 +220,8 @@ template SQLiteTablesReCreate() {
**** delete
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_delete
+#+BEGIN_SRC d
template SQLiteDeleteDocument() {
string SQLiteDeleteDocument(M)(
M doc_matters,
@@ -187,7 +234,8 @@ template SQLiteDeleteDocument() {
**** insert
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_insert
+#+BEGIN_SRC d
template SQLiteInsertMetadata() {
string SQLiteInsertMetadata(M)(
M doc_matters,
@@ -201,14 +249,15 @@ template SQLiteInsertMetadata() {
**** insert doc objects loop
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_insert_doc_objects_loop
+#+BEGIN_SRC d
template SQLiteInsertDocObjectsLoop() {
string SQLiteInsertDocObjectsLoop(D,M)(
const D doc_abstraction,
M doc_matters,
) {
string _uid = SQLinsertDelimiter!()(doc_matters.src.doc_uid);
- auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.webserv_url_doc_root, doc_matters.src.language);
+ auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url, doc_matters.src.language);
string insertDocObjectsRow(O)(O obj) {
<<sqlite_formatted_insertions_doc_objects>>
return _insert_doc_objects_row;
@@ -220,7 +269,8 @@ template SQLiteInsertDocObjectsLoop() {
**** tables create
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_tables_create
+#+BEGIN_SRC d
template SQLiteTablesCreate() {
void SQLiteTablesCreate(E,O)(E env, O opt_action) {
import d2sqlite3;
@@ -254,7 +304,8 @@ template SQLiteTablesCreate() {
**** tables drop
-#+BEGIN_SRC d :tangle "../src/doc_reform/io_out/sqlite.d"
+#+NAME: sqlite_tables_drop
+#+BEGIN_SRC d
template SQLiteDbDrop() {
void SQLiteDbDrop(O)(O opt_action) {
writeln("db drop");
@@ -321,7 +372,7 @@ template SQLiteDbDrop() {
** 2. imports
-#+NAME: output_imports
+#+NAME: sqlite_imports
#+BEGIN_SRC d
import doc_reform.io_out;
import
@@ -507,7 +558,7 @@ string inline_images(M,O)(
M doc_matters,
const O obj,
string _txt,
- string _suffix = ".html",
+ string _suffix = ".html",
string _xml_type = "seg",
) {
string _img_pth;
@@ -560,7 +611,7 @@ string inline_links(M,O)(
_txt = _txt.replaceFirst(
rgx.inline_link_hash,
"┥$1┝┤"
- ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root
+ ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url
~ "/"
~ pth_html.tail_fn_seg(doc_matters.src.filename, "$3.html")
~ "├"
@@ -569,7 +620,7 @@ string inline_links(M,O)(
_txt = _txt.replaceFirst(
rgx.inline_link_hash,
"┥$1┝┤"
- ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root
+ ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url
~ "/"
~ doc_matters.has.tag_associations[(m.captures[3])]["seg_lv4"]
~ ".html"
@@ -594,7 +645,7 @@ string inline_links(M,O)(
_txt = _txt.replaceFirst(
rgx.inline_link_hash,
"┥$1┝┤"
- ~ doc_matters.conf_make_meta.conf.webserv_url_doc_root
+ ~ doc_matters.conf_make_meta.conf.w_srv_data_root_url
~ "/"
~ pth_html.tail_fn_scroll(doc_matters.src.filename)
~ "#" ~ "$3"
@@ -1451,8 +1502,8 @@ DROP INDEX IF EXISTS idx_digest_clean;
DROP INDEX IF EXISTS idx_digest_all;
DROP INDEX IF EXISTS idx_clean;
DROP INDEX IF EXISTS idx_title;
-DROP INDEX IF EXISTS idx_creator_author;
-DROP INDEX IF EXISTS src_filename;
+DROP INDEX IF EXISTS idx_author;
+DROP INDEX IF EXISTS src_filename_base;
DROP INDEX IF EXISTS idx_language_document_char;
DROP INDEX IF EXISTS idx_classify_topic_register;
#+END_SRC
@@ -1484,6 +1535,7 @@ CREATE TABLE metadata_and_text (
title_language VARCHAR(100) NULL,
title_language_char VARCHAR(6) NULL,
creator_author VARCHAR(600) NOT NULL,
+ creator_author_last_first VARCHAR(600) NOT NULL,
creator_author_email VARCHAR(100) NULL,
creator_author_hon VARCHAR(100) NULL,
creator_author_nationality VARCHAR(100) NULL,
@@ -1546,7 +1598,8 @@ CREATE TABLE metadata_and_text (
notes_prefix_b TEXT NULL,
notes_suffix TEXT NULL,
publisher VARCHAR(600) NULL,
- src_filename VARCHAR(256) NOT NULL,
+ src_filename_base VARCHAR(256) NOT NULL,
+ src_filename_suffix VARCHAR(6) NOT NULL,
src_fingerprint VARCHAR(256) NULL,
src_filesize VARCHAR(10) NULL,
src_wordcount VARCHAR(10) NULL,
@@ -1617,7 +1670,7 @@ CREATE TABLE doc_objects (
last_decendant VARCHAR(16) NULL, -- headings only
digest_clean CHAR(256),
digest_all CHAR(256),
- html_seg_url CHAR(256),
+ seg_name CHAR(256),
types CHAR(1) NULL
);
#+END_SRC
@@ -1631,9 +1684,9 @@ CREATE INDEX idx_digest_clean ON doc_objects(digest_clean);
CREATE INDEX idx_digest_all ON doc_objects(digest_all);
CREATE INDEX idx_clean ON doc_objects(clean);
CREATE INDEX idx_title ON metadata_and_text(title);
-CREATE INDEX idx_author ON metadata_and_text(creator_author);
+CREATE INDEX idx_author ON metadata_and_text(creator_author_last_first);
CREATE INDEX idx_uid ON metadata_and_text(uid);
-CREATE INDEX idx_filename ON metadata_and_text(src_filename);
+CREATE INDEX idx_filename ON metadata_and_text(src_filename_base);
CREATE INDEX idx_language ON metadata_and_text(language_document_char);
CREATE INDEX idx_topics ON metadata_and_text(classify_topic_register);
#+END_SRC
@@ -1686,7 +1739,8 @@ string _insert_metadata = format(q"┃
#+BEGIN_SRC sql
INSERT INTO metadata_and_text (
uid,
- src_filename,
+ src_filename_base,
+ src_filename_suffix,
src_composite_id_per_txt,
src_composite_id_per_pod,
title,
@@ -1696,6 +1750,7 @@ string _insert_metadata = format(q"┃
title_edition,
title_language,
creator_author,
+ creator_author_last_first,
creator_author_email,
creator_illustrator,
creator_translator,
@@ -1741,7 +1796,7 @@ string _insert_metadata = format(q"┃
#+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'
+ '%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', '%s', '%s'
);
#+END_SRC
@@ -1751,7 +1806,8 @@ string _insert_metadata = format(q"┃
#+BEGIN_SRC d
┃",
_uid,
- SQLinsertDelimiter!()(doc_matters.src.filename),
+ SQLinsertDelimiter!()(doc_matters.src.filename_base),
+ SQLinsertDelimiter!()(doc_matters.src.filename_extension),
SQLinsertDelimiter!()(doc_matters.src.docname_composite_unique_per_src_doc),
SQLinsertDelimiter!()(doc_matters.src.docname_composite_unique_per_src_pod),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_full),
@@ -1761,6 +1817,7 @@ string _insert_metadata = format(q"┃
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_edition),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.title_language),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author),
+ SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author_surname_fn),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_author_email),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_illustrator),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.creator_translator),
@@ -1797,7 +1854,7 @@ string _insert_metadata = format(q"┃
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_language_char),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.original_source),
SQLinsertDelimiter!()(doc_matters.conf_make_meta.meta.publisher),
- SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.webserv_url_doc_root)
+ SQLinsertDelimiter!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url)
);
#+END_SRC
@@ -1897,7 +1954,7 @@ string _insert_doc_objects_row = format(q"┃
lev,
is_of_type,
is_a,
- html_seg_url
+ seg_name
)
#+END_SRC
@@ -1923,7 +1980,7 @@ string _insert_doc_objects_row = format(q"┃
obj.metainfo.heading_lev_markup,
obj.metainfo.is_of_type,
obj.metainfo.is_a,
- url_html.fn_seg_obj_num(doc_matters.src.filename, obj.tags.html_segment_anchor_tag_is, obj.metainfo.identifier),
+ obj.tags.html_segment_anchor_tag_is
);
#+END_SRC