aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2021-08-11 03:06:47 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2021-08-11 11:03:07 -0400
commit118ea61dc79bf9b1c45bbf81b31361a749e32fdd (patch)
tree3d803e1b7d9e99187c82cbb1b1af735972c09510 /src/doc_reform
parentspine_search (work on) (diff)
spine search and configuration related
Diffstat (limited to 'src/doc_reform')
-rw-r--r--src/doc_reform/io_in/read_config_files.d53
-rw-r--r--src/doc_reform/io_out/cgi_sqlite_search_form.d2
-rw-r--r--src/doc_reform/io_out/epub3.d4
-rw-r--r--src/doc_reform/io_out/html.d2
-rw-r--r--src/doc_reform/io_out/hub.d2
-rw-r--r--src/doc_reform/io_out/metadata.d4
-rw-r--r--src/doc_reform/io_out/paths_output.d2
-rw-r--r--src/doc_reform/io_out/sqlite.d42
-rw-r--r--src/doc_reform/io_out/xmls.d4
-rw-r--r--src/doc_reform/meta/conf_make_meta_structs.d3
-rw-r--r--src/doc_reform/meta/conf_make_meta_yaml.d21
-rw-r--r--src/doc_reform/meta/metadoc.d14
-rw-r--r--src/doc_reform/meta/metadoc_harvests_authors.d4
-rw-r--r--src/doc_reform/meta/metadoc_harvests_topics.d4
-rw-r--r--src/doc_reform/meta/metadoc_show_config.d4
-rwxr-xr-xsrc/doc_reform/spine.d8
16 files changed, 102 insertions, 71 deletions
diff --git a/src/doc_reform/io_in/read_config_files.d b/src/doc_reform/io_in/read_config_files.d
index 005a436..037fa22 100644
--- a/src/doc_reform/io_in/read_config_files.d
+++ b/src/doc_reform/io_in/read_config_files.d
@@ -72,35 +72,37 @@ flag:
act0: "--html"
act1: "--html --epub"
output:
- path: "/var/www/html"
+ path: "%s"
default:
language: "en"
papersize: "a4"
- text_wrap: "80"
- digest: "sha256"
+ text_wrap: "80"
+ digest: "sha256"
webserv:
- http: "%s"
- domain: "%s"
- data_http: "%s"
- data_domain: "%s"
- data_root_url: "%s"
- data_root_path: "%s"
- data_root_part: ""
- images_root_part: "image"
- cgi_title: "%s"
- cgi_http: "%s"
- cgi_domain: "%s"
- cgi_bin_url: "%s"
- cgi_bin_part: "cgi-bin"
- cgi_bin_path: "%s"
- cgi_search_script: "%s"
- cgi_port: ""
- cgi_user: ""
- cgi_action: "%s"
- db_sqlite: "%s"
- db_pg_table: ""
- db_pg_user: ""
+ http: "%s"
+ domain: "%s"
+ data_http: "%s"
+ data_domain: "%s"
+ data_root_url: "%s"
+ data_root_path: "%s"
+ data_root_part: ""
+ images_root_part: "image"
+ cgi_title: "%s"
+ cgi_http: "%s"
+ cgi_domain: "%s"
+ cgi_bin_url: "%s"
+ cgi_bin_part: "cgi-bin"
+ cgi_bin_path: "%s"
+ cgi_search_script: "%s"
+ cgi_port: ""
+ cgi_user: ""
+ cgi_action: "%s"
+ db_sqlite_path: "%s"
+ db_sqlite_filename: "%s"
+ db_pg_table: ""
+ db_pg_user: ""
┃",
+ _cfg.www_doc_root, // doc root
_cfg.www_http, // http
_cfg.www_domain, // domain
_cfg.www_http, // data http
@@ -114,7 +116,8 @@ webserv:
_cfg.cgi_bin_root, // cgi bin path
_cfg.cgi_filename, // cgi filename
_cfg.cgi_url_action, // cgi action
- _cfg.db_sqlite_filename, // db filename
+ _cfg.db_sqlite_path, // sqlite db path
+ _cfg.db_sqlite_filename, // sqlite db filename
);
foreach(conf_fn; [_conf_file_details.config_filename_site]) {
foreach(pth; _conf_file_details.possible_config_path_locations.config_local_site) {
diff --git a/src/doc_reform/io_out/cgi_sqlite_search_form.d b/src/doc_reform/io_out/cgi_sqlite_search_form.d
index 362d02c..3265ae7 100644
--- a/src/doc_reform/io_out/cgi_sqlite_search_form.d
+++ b/src/doc_reform/io_out/cgi_sqlite_search_form.d
@@ -56,7 +56,7 @@ template CGIsearchSQLite() {
std.format;
import doc_reform.io_out;
string _sqlite_db_fn = (opt_action.sqlite_filename.empty)
- ? make_and_meta_struct.conf.w_srv_db_sqlite
+ ? make_and_meta_struct.conf.w_srv_db_sqlite_filename
: opt_action.sqlite_filename;
string _cgi_search_script = (opt_action.cgi_sqlite_search_filename.empty)
? make_and_meta_struct.conf.w_srv_cgi_search_script
diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d
index 1a8d924..aa875ad 100644
--- a/src/doc_reform/io_out/epub3.d
+++ b/src/doc_reform/io_out/epub3.d
@@ -344,7 +344,7 @@ template outputEPub3() {
</ncx>┃");
return toc;
}
-
+
@system void outputEPub3(D,I)(
const D doc_abstraction,
I doc_matters,
@@ -858,5 +858,5 @@ template outputEPub3() {
}
}
}
-
+
}
diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d
index ceaf9f9..c6f36a1 100644
--- a/src/doc_reform/io_out/html.d
+++ b/src/doc_reform/io_out/html.d
@@ -560,7 +560,7 @@ template outputHTML() {
M doc_matters,
) {
{ /+ (copy html images) +/
-
+
auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language);
if (!exists(pth_html.image)) {
pth_html.image.mkdirRecurse;
diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d
index 5b2d74b..4188d6e 100644
--- a/src/doc_reform/io_out/hub.d
+++ b/src/doc_reform/io_out/hub.d
@@ -190,7 +190,7 @@ template outputHubOp() {
if ((opt_action.cgi_search_form_codegen)) {
if ((opt_action.verbose)) {
string _sqlite_db_fn = (opt_action.sqlite_filename.empty)
- ? config.conf.w_srv_db_sqlite
+ ? config.conf.w_srv_db_sqlite_filename
: opt_action.sqlite_filename;
string _cgi_search_script = (opt_action.cgi_sqlite_search_filename.empty)
? config.conf.w_srv_cgi_search_script
diff --git a/src/doc_reform/io_out/metadata.d b/src/doc_reform/io_out/metadata.d
index d196988..58d8b33 100644
--- a/src/doc_reform/io_out/metadata.d
+++ b/src/doc_reform/io_out/metadata.d
@@ -72,10 +72,10 @@ template outputMetadata() {
<!-- SiSU Spine Search -->
</div>┃",
doc_matters.conf_make_meta.conf.w_srv_cgi_action,
- (doc_matters.conf_make_meta.conf.w_srv_db_sqlite.empty)
+ (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty)
? ""
: "\n <input type=\"hidden\" name=\"db\" value=\""
- ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite
+ ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename
~ "\">",
doc_matters.src.filename_base,
);
diff --git a/src/doc_reform/io_out/paths_output.d b/src/doc_reform/io_out/paths_output.d
index 62bf6c0..96ef12d 100644
--- a/src/doc_reform/io_out/paths_output.d
+++ b/src/doc_reform/io_out/paths_output.d
@@ -612,7 +612,7 @@ template spinePathsSQLite() {
}
string base() {
auto out_pth = spineOutPathSQLite!()(output_pth_root); // decide whether to have separate files for each language
- string base_dir = "sqlite";
+ string base_dir = "";
return (((out_pth.output_root).chainPath(base_dir)).asNormalizedPath).array;
}
string sqlite_file() {
diff --git a/src/doc_reform/io_out/sqlite.d b/src/doc_reform/io_out/sqlite.d
index a97a39d..abdfc7a 100644
--- a/src/doc_reform/io_out/sqlite.d
+++ b/src/doc_reform/io_out/sqlite.d
@@ -66,7 +66,7 @@ template SQLiteHubBuildTablesAndPopulate() {
const D doc_abstraction,
M doc_matters,
) {
- auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.output_path);
+ auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.sqlite.path);
pth_sqlite.base.mkdirRecurse;
auto db = Database(pth_sqlite.sqlite_file);
template SQLiteDbStatementComposite() {
@@ -79,7 +79,7 @@ template SQLiteHubBuildTablesAndPopulate() {
{
string _db_statement;
if ((doc_matters.opt.action.sqlite_db_create)) {
- auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.output_path);
+ auto pth_sqlite = spinePathsSQLite!()(doc_matters.sqlite.filename, doc_matters.sqlite.path);
pth_sqlite.base.mkdirRecurse;
_db_statement ~= SQLiteTablesReCreate!()();
SQLiteDbRun!()(db, _db_statement, doc_matters.opt.action, "TABLE RE-CREATE");
@@ -114,7 +114,7 @@ template SQLiteHubDiscreteBuildTablesAndPopulate() {
M doc_matters,
) {
auto url_html = spineUrlsHTML!()(doc_matters.conf_make_meta.conf.w_srv_data_root_url_html, doc_matters.src.language);
- auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language);
+ auto pth_sqlite = spinePathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); // doc_matters.db_path
pth_sqlite.base.mkdirRecurse;
auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename));
template SQLiteDiscreteDbStatementComposite() {
@@ -1550,19 +1550,19 @@ template SQLiteTablesCreate() {
string _db_statement;
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
+ : (config.conf.w_srv_db_sqlite_filename.length > 0)
+ ? config.conf.w_srv_db_sqlite_filename
: "";
- string output_path = (opt_action.output_dir_set.length > 0)
+ string db_path = (opt_action.output_dir_set.length > 0)
? opt_action.output_dir_set
- : (config.conf.output_path.length > 0)
- ? config.conf.output_path
+ : (config.conf.w_srv_db_sqlite_path.length > 0)
+ ? config.conf.w_srv_db_sqlite_path
: "";
- if (db_filename.length > 0 && output_path.length > 0) {
+ if (db_filename.length > 0 && db_path.length > 0) {
if ((opt_action.verbose)) {
- writeln("db name & path: ", config.conf.output_path, "/sqlite/", db_filename);
+ writeln("db name & path: ", db_path, db_filename);
}
- auto pth_sqlite = spinePathsSQLite!()(db_filename, output_path);
+ auto pth_sqlite = spinePathsSQLite!()(db_filename, db_path);
pth_sqlite.base.mkdirRecurse;
auto db = Database(pth_sqlite.sqlite_file);
{
@@ -1572,7 +1572,7 @@ template SQLiteTablesCreate() {
} 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);
+ writeln("db path: ", db_path);
}
}
}
@@ -1583,16 +1583,16 @@ template SQLiteDbDrop() {
if ((opt_action.sqlite_db_drop)) {
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
+ : (config.conf.w_srv_db_sqlite_filename.length > 0)
+ ? config.conf.w_srv_db_sqlite_filename
: "";
- 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
+ string db_path = (opt_action.sqlite_db_path.length > 0) //
+ ? opt_action.sqlite_db_path
+ : (config.conf.w_srv_db_sqlite_path.length > 0)
+ ? config.conf.w_srv_db_sqlite_path
: "";
- if (db_filename.length > 0 && output_path.length > 0) {
- auto pth_sqlite = spinePathsSQLite!()(db_filename, output_path);
+ if (db_filename.length > 0 && db_path.length > 0) {
+ auto pth_sqlite = spinePathsSQLite!()(db_filename, db_path);
writeln("remove(", pth_sqlite.sqlite_file, ")");
try {
remove(pth_sqlite.sqlite_file);
@@ -1602,7 +1602,7 @@ template SQLiteDbDrop() {
} 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);
+ writeln("db path: ", db_path);
}
}
}
diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d
index e8e0978..e6012fe 100644
--- a/src/doc_reform/io_out/xmls.d
+++ b/src/doc_reform/io_out/xmls.d
@@ -220,10 +220,10 @@ template outputXHTMLs() {
<!-- SiSU Spine Search -->
</div>┃",
doc_matters.conf_make_meta.conf.w_srv_cgi_action,
- (doc_matters.conf_make_meta.conf.w_srv_db_sqlite.empty)
+ (doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename.empty)
? ""
: "\n <input type=\"hidden\" name=\"db\" value=\""
- ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite
+ ~ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename
~ "\">",
doc_matters.src.filename_base,
);
diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d
index f0d30b3..2863f0d 100644
--- a/src/doc_reform/meta/conf_make_meta_structs.d
+++ b/src/doc_reform/meta/conf_make_meta_structs.d
@@ -213,7 +213,8 @@ struct ConfCompositeSiteLocal {
string w_srv_cgi_user;
string w_srv_cgi_action;
string w_srv_cgi_bin_url;
- string w_srv_db_sqlite;
+ string w_srv_db_sqlite_filename;
+ string w_srv_db_sqlite_path;
// string w_srv_db_pg;
string w_srv_db_pg_table;
string w_srv_db_pg_user;
diff --git a/src/doc_reform/meta/conf_make_meta_yaml.d b/src/doc_reform/meta/conf_make_meta_yaml.d
index 0940f49..3780553 100644
--- a/src/doc_reform/meta/conf_make_meta_yaml.d
+++ b/src/doc_reform/meta/conf_make_meta_yaml.d
@@ -350,7 +350,7 @@ template contentYAMLtoSpineStruct() {
) {
_struct_composite.conf.w_srv_cgi_search_script = _yaml["webserv"]["cgi_search_script"].get!string;
} else {
- _struct_composite.conf.w_srv_cgi_search_script = "spine-search";
+ _struct_composite.conf.w_srv_cgi_search_script = "spine_search";
}
if (_opt_action.cgi_sqlite_search_filename_d.length > 0) {
_struct_composite.conf.w_srv_cgi_search_script_raw_fn_d = _opt_action.cgi_sqlite_search_filename_d;
@@ -412,12 +412,21 @@ template contentYAMLtoSpineStruct() {
// _struct_composite.conf.w_srv_cgi_file_links = _yaml["webserv"]["cgi_file_links"].get!string;
// }
if (_opt_action.sqlite_filename.length > 0) {
- _struct_composite.conf.w_srv_db_sqlite = _opt_action.sqlite_filename;
- } else if ("db_sqlite" in _yaml["webserv"]
- && _yaml["webserv"]["db_sqlite"].type.string
- && _yaml["webserv"]["db_sqlite"].tag.match(rgx.yaml_tag_is_str)
+ _struct_composite.conf.w_srv_db_sqlite_filename = _opt_action.sqlite_filename;
+ } else if ("db_sqlite_filename" in _yaml["webserv"]
+ && _yaml["webserv"]["db_sqlite_filename"].type.string
+ && _yaml["webserv"]["db_sqlite_filename"].tag.match(rgx.yaml_tag_is_str)
) {
- _struct_composite.conf.w_srv_db_sqlite = _yaml["webserv"]["db_sqlite"].get!string;
+ _struct_composite.conf.w_srv_db_sqlite_filename = _yaml["webserv"]["db_sqlite_filename"].get!string;
+ } else { // set default ?
+ }
+ if (_opt_action.sqlite_path.length > 0) {
+ _struct_composite.conf.w_srv_db_sqlite_path = _opt_action.sqlite_path;
+ } else if ("db_sqlite_path" in _yaml["webserv"]
+ && _yaml["webserv"]["db_sqlite_path"].type.string
+ && _yaml["webserv"]["db_sqlite_path"].tag.match(rgx.yaml_tag_is_str)
+ ) {
+ _struct_composite.conf.w_srv_db_sqlite_path = _yaml["webserv"]["db_sqlite_path"].get!string;
} else { // set default ?
}
}
diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d
index 1113183..525b32b 100644
--- a/src/doc_reform/meta/metadoc.d
+++ b/src/doc_reform/meta/metadoc.d
@@ -184,13 +184,23 @@ template spineAbstraction() {
struct SQLite_ {
@safe string filename() {
string _fn = "";
+ string _pth = "";
if (_opt_action.sqlite_filename.length > 0) {
_fn = _opt_action.sqlite_filename;
- } else if (_make_and_meta_struct.conf.w_srv_db_sqlite.length > 0) {
- _fn = _make_and_meta_struct.conf.w_srv_db_sqlite;
+ } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.length > 0) {
+ _fn = _make_and_meta_struct.conf.w_srv_db_sqlite_filename;
}
return _fn;
}
+ @safe string path() {
+ string _pth = "";
+ if (_opt_action.sqlite_path.length > 0) {
+ _pth = _opt_action.sqlite_path;
+ } else if (_make_and_meta_struct.conf.w_srv_db_sqlite_path.length > 0) {
+ _pth = _make_and_meta_struct.conf.w_srv_db_sqlite_path;
+ }
+ return _pth;
+ }
@safe string cgi_filename() {
string _fn = "";
if (_opt_action.cgi_sqlite_search_filename.length > 0) {
diff --git a/src/doc_reform/meta/metadoc_harvests_authors.d b/src/doc_reform/meta/metadoc_harvests_authors.d
index 6e68766..182b1cd 100644
--- a/src/doc_reform/meta/metadoc_harvests_authors.d
+++ b/src/doc_reform/meta/metadoc_harvests_authors.d
@@ -89,10 +89,10 @@ template spineMetaDocHarvestsAuthors() {
<!-- SiSU Spine Search -->
</div>┃",
_make_and_meta_struct.conf.w_srv_cgi_action,
- (_make_and_meta_struct.conf.w_srv_db_sqlite.empty)
+ (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty)
? ""
: "\n <input type=\"hidden\" name=\"db\" value=\""
- ~ _make_and_meta_struct.conf.w_srv_db_sqlite
+ ~ _make_and_meta_struct.conf.w_srv_db_sqlite_filename
~ "\">",
);
} else {
diff --git a/src/doc_reform/meta/metadoc_harvests_topics.d b/src/doc_reform/meta/metadoc_harvests_topics.d
index 5ac01c9..5848723 100644
--- a/src/doc_reform/meta/metadoc_harvests_topics.d
+++ b/src/doc_reform/meta/metadoc_harvests_topics.d
@@ -89,10 +89,10 @@ template spineMetaDocHarvestsTopics() {
<!-- SiSU Spine Search -->
</div>┃",
_make_and_meta_struct.conf.w_srv_cgi_action,
- (_make_and_meta_struct.conf.w_srv_db_sqlite.empty)
+ (_make_and_meta_struct.conf.w_srv_db_sqlite_filename.empty)
? ""
: "\n <input type=\"hidden\" name=\"db\" value=\""
- ~ _make_and_meta_struct.conf.w_srv_db_sqlite
+ ~ _make_and_meta_struct.conf.w_srv_db_sqlite_filename
~ "\">",
);
} else {
diff --git a/src/doc_reform/meta/metadoc_show_config.d b/src/doc_reform/meta/metadoc_show_config.d
index 759f88b..20e796f 100644
--- a/src/doc_reform/meta/metadoc_show_config.d
+++ b/src/doc_reform/meta/metadoc_show_config.d
@@ -107,7 +107,7 @@ template spineShowSiteConfig() {
// "- webserv cgi file links:",
// config.conf.w_srv_cgi_file_links,
"- webserv sqlite db:",
- config.conf.w_srv_db_sqlite,
+ config.conf.w_srv_db_sqlite_filename,
"- output path:",
config.conf.output_path,
"- processing concordance max:",
@@ -201,7 +201,7 @@ template spineShowConfig() {
// "- webserv cgi file links:",
// doc_matters.conf_make_meta.conf.w_srv_cgi_file_links,
"- webserv sqlite db:",
- doc_matters.conf_make_meta.conf.w_srv_db_sqlite,
+ doc_matters.conf_make_meta.conf.w_srv_db_sqlite_filename,
"- output path:",
doc_matters.conf_make_meta.conf.output_path,
"- processing concordance max:",
diff --git a/src/doc_reform/spine.d b/src/doc_reform/spine.d
index 418177c..d7d175e 100755
--- a/src/doc_reform/spine.d
+++ b/src/doc_reform/spine.d
@@ -187,6 +187,7 @@ string program_name = "spine";
"set-papersize" : "", //_cfg.default_papersize, // suggest: a4
"set-textwrap" : "", //_cfg.default_text_wrap, // suggest: 80
"set-digest" : "", //_cfg.default_hash_digest, // suggest: sha256
+ "sqlite-db-path" : "", //_cfg.db_sqlite_path, // suggest: "/var/www/sqlite"
"sqlite-db-filename" : "", //_cfg.db_sqlite_filename, // suggest: "spine-search.db"
];
auto helpInfo = getopt(args,
@@ -269,6 +270,7 @@ string program_name = "spine";
"config", "=/path/to/config/file/including/filename", &settings["config"],
"lang", "=[lang code e.g. =en or =en,es]", &settings["lang"],
"output", "=/path/to/output/dir specify where to place output", &settings["output"],
+ "sqlite-db-path", "sqlite db path", &settings["sqlite-db-path"],
"sqlite-db-filename", "sqlite db to create, populate & make available for search", &settings["sqlite-db-filename"],
// "sqlite-db-filename", "=[filename].sql.db", &settings["sqlite-db-filename"],
);
@@ -381,6 +383,9 @@ string program_name = "spine";
@trusted bool source_or_pod() {
return (opts["pod"] || opts["source"]) ? true : false;
}
+ @trusted string sqlite_db_path() {
+ return settings["sqlite-db-path"];
+ }
@trusted string sqlite_db_filename() {
return settings["sqlite-db-filename"];
}
@@ -459,6 +464,9 @@ string program_name = "spine";
@trusted string sqlite_filename() {
return settings["sqlite-db-filename"];
}
+ @trusted string sqlite_path() {
+ return settings["sqlite-db-path"];
+ }
@trusted string cgi_bin_root() {
return settings["cgi-bin-root"];
}