aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/meta/conf_make_meta_yaml.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2020-04-15 20:05:56 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2020-05-20 11:27:26 -0400
commit0b484b0a1a6405a53616416aaaa6512a602b6072 (patch)
treee9737b80ad9fd83254510368198f3fb6dfb8926c /src/doc_reform/meta/conf_make_meta_yaml.d
parentcgi search form: path; theme; download remote src (diff)
cli precedence over config file settings
- cli precedence over config file settings - latex papersize settings sorted
Diffstat (limited to 'src/doc_reform/meta/conf_make_meta_yaml.d')
-rw-r--r--src/doc_reform/meta/conf_make_meta_yaml.d184
1 files changed, 134 insertions, 50 deletions
diff --git a/src/doc_reform/meta/conf_make_meta_yaml.d b/src/doc_reform/meta/conf_make_meta_yaml.d
index c33b04a..d6f9e22 100644
--- a/src/doc_reform/meta/conf_make_meta_yaml.d
+++ b/src/doc_reform/meta/conf_make_meta_yaml.d
@@ -20,10 +20,11 @@ template contentYAMLtoSpineStruct() {
doc_reform.meta.defaults,
doc_reform.meta.rgx;
ConfComposite _struct_composite;
- @system auto contentYAMLtoSpineStruct(C,Y,M)(
+ @system auto contentYAMLtoSpineStruct(C,Y,M,O)(
C _struct_composite,
Y _yaml,
M _manifested,
+ O _opt_action,
string _identifier
) {
mixin spineRgxIn;
@@ -281,7 +282,9 @@ template contentYAMLtoSpineStruct() {
) {
_struct_composite.conf.w_srv_cgi_bin_path = _yaml["webserv"]["cgi_bin_path"].get!string;
}
- if ("cgi_search_script" in _yaml["webserv"]
+ if (_opt_action.cgi_sqlite_search_filename.length > 0) {
+ _struct_composite.conf.w_srv_cgi_search_script = _opt_action.cgi_sqlite_search_filename;
+ } else if ("cgi_search_script" in _yaml["webserv"]
&& _yaml["webserv"]["cgi_search_script"].type.string
&& _yaml["webserv"]["cgi_search_script"].tag.match(rgx.yaml_tag_is_str)
) {
@@ -289,7 +292,9 @@ template contentYAMLtoSpineStruct() {
} else {
_struct_composite.conf.w_srv_cgi_search_script = "spine-search";
}
- if ("cgi_search_script_raw_fn_d" in _yaml["webserv"]
+ 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;
+ } else if ("cgi_search_script_raw_fn_d" in _yaml["webserv"]
&& _yaml["webserv"]["cgi_search_script_raw_fn_d"].type.string
&& _yaml["webserv"]["cgi_search_script_raw_fn_d"].tag.match(rgx.yaml_tag_is_str)
) {
@@ -314,13 +319,6 @@ template contentYAMLtoSpineStruct() {
) {
_struct_composite.conf.w_srv_cgi_user = _yaml["webserv"]["cgi_user"].get!string;
}
- if ("cgi_action" in _yaml["webserv"]
- && _yaml["webserv"]["cgi_action"].type.string
- && _yaml["webserv"]["cgi_action"].tag.match(rgx.yaml_tag_is_str)
- ) {
- _struct_composite.conf.w_srv_cgi_action = _yaml["webserv"]["cgi_action"].get!string;
- } else { // action is composite, build
- }
if ("cgi_bin_url" in _yaml["webserv"]
&& _yaml["webserv"]["cgi_bin_url"].type.string
&& _yaml["webserv"]["cgi_bin_url"].tag.match(rgx.yaml_tag_is_str)
@@ -338,13 +336,24 @@ template contentYAMLtoSpineStruct() {
~ "/"
~ _struct_composite.conf.w_srv_cgi_bin_part;
}
+ if (_opt_action.cgi_sqlite_search_filename.length > 0) {
+ _struct_composite.conf.w_srv_cgi_action = _struct_composite.conf.w_srv_cgi_bin_url ~ "/" ~ _opt_action.cgi_sqlite_search_filename;
+ } else if ("cgi_action" in _yaml["webserv"]
+ && _yaml["webserv"]["cgi_action"].type.string
+ && _yaml["webserv"]["cgi_action"].tag.match(rgx.yaml_tag_is_str)
+ ) {
+ _struct_composite.conf.w_srv_cgi_action = _yaml["webserv"]["cgi_action"].get!string;
+ } else { // action is composite, build
+ }
// if ("cgi_file_links" in _yaml["webserv"]
// && _yaml["webserv"]["cgi_file_links"].type.string
// && _yaml["webserv"]["cgi_file_links"].tag.match(rgx.yaml_tag_is_str)
// ) {
// _struct_composite.conf.w_srv_cgi_file_links = _yaml["webserv"]["cgi_file_links"].get!string;
// }
- if ("db_sqlite" in _yaml["webserv"]
+ 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)
) {
@@ -356,7 +365,9 @@ template contentYAMLtoSpineStruct() {
if (!(_struct_composite.conf.output_path)) {
_struct_composite.conf.output_path = ((_manifested.output.path).asNormalizedPath).array;
}
- if ("output" in _yaml
+ if (_opt_action.output_dir_set.length > 0) {
+ _struct_composite.conf.output_path = (_opt_action.output_dir_set.asNormalizedPath).array;
+ } else if ("output" in _yaml
&& _yaml["output"].type.sequence
) {
if (_yaml["output"].type.mapping
@@ -456,42 +467,113 @@ template contentYAMLtoSpineStruct() {
}
}
}
- if ("default" in _yaml
+ string[] selected_papersize(string _sizes_str) {
+ string[] _sizes = _sizes_str.split(regex(r"\s*,\s*"));
+ string[] _selected_sizes;
+ foreach (_size; _sizes) {
+ switch (_size) {
+ case "a4":
+ _selected_sizes ~= "a4.portrait";
+ _selected_sizes ~= "a4.landscape";
+ break;
+ case "a4.portrait":
+ _selected_sizes ~= _size;
+ break;
+ case "a4.landscape":
+ _selected_sizes ~= _size;
+ break;
+ case "a5":
+ _selected_sizes ~= "a5.portrait";
+ _selected_sizes ~= "a5.landscape";
+ break;
+ case "a5.portrait":
+ _selected_sizes ~= _size;
+ break;
+ case "a5.landscape":
+ _selected_sizes ~= _size;
+ break;
+ case "b4":
+ _selected_sizes ~= "b4.portrait";
+ _selected_sizes ~= "b4.landscape";
+ break;
+ case "b4.portrait":
+ _selected_sizes ~= _size;
+ break;
+ case "b4.landscape":
+ _selected_sizes ~= _size;
+ break;
+ case "letter":
+ _selected_sizes ~= "letter.portrait";
+ _selected_sizes ~= "letter.landscape";
+ break;
+ case "letter.portrait":
+ _selected_sizes ~= _size;
+ break;
+ case "letter.landscape":
+ _selected_sizes ~= _size;
+ break;
+ case "legal":
+ _selected_sizes ~= "legal.portrait";
+ _selected_sizes ~= "legal.landscape";
+ break;
+ case "legal.portrait":
+ _selected_sizes ~= _size;
+ break;
+ case "legal.landscape":
+ _selected_sizes ~= _size;
+ break;
+ default: break;
+ }
+ }
+ return _selected_sizes;
+ }
+ if (_opt_action.latex_papersize.length > 0) {
+ _struct_composite.conf.set_papersize = selected_papersize(_opt_action.latex_papersize);
+ } else if (
+ "default" in _yaml
&& _yaml["default"].type.sequence
+ && _yaml["default"].type.mapping
+ && _yaml["default"].tag.match(rgx.yaml_tag_is_map)
) {
- if (_yaml["default"].type.mapping
- && _yaml["default"].tag.match(rgx.yaml_tag_is_map)
+ if ("papersize" in _yaml["default"]
+ && _yaml["default"]["papersize"].type.string
+ && _yaml["default"]["papersize"].tag.match(rgx.yaml_tag_is_str)
) {
- if ("papersize" in _yaml["default"]
- && _yaml["default"]["papersize"].type.string
- && _yaml["default"]["papersize"].tag.match(rgx.yaml_tag_is_str)
- ) {
- _struct_composite.conf.default_papersize = _yaml["default"]["papersize"].get!string;
- }
- if ("text_wrap" in _yaml["default"]
- && _yaml["default"]["text_wrap"].type.string
- && _yaml["default"]["text_wrap"].tag.match(rgx.yaml_tag_is_str)
- ) {
- _struct_composite.conf.default_text_wrap = _yaml["default"]["text_wrap"].get!string;
- }
- if ("emphasis" in _yaml["default"]
- && _yaml["default"]["emphasis"].type.string
- && _yaml["default"]["emphasis"].tag.match(rgx.yaml_tag_is_str)
- ) {
- _struct_composite.conf.default_emphasis = _yaml["default"]["emphasis"].get!string;
- }
- if ("language" in _yaml["default"]
- && _yaml["default"]["language"].type.string
- && _yaml["default"]["language"].tag.match(rgx.yaml_tag_is_str)
- ) {
- _struct_composite.conf.default_language = _yaml["default"]["language"].get!string;
- }
- if ("digest" in _yaml["default"]
- && _yaml["default"]["digest"].type.string
- && _yaml["default"]["digest"].tag.match(rgx.yaml_tag_is_str)
- ) {
- _struct_composite.conf.default_digest = _yaml["default"]["digest"].get!string;
- }
+ _struct_composite.conf.set_papersize = selected_papersize(_yaml["default"]["papersize"].get!string);
+ }
+ }
+ if (_struct_composite.conf.set_papersize.length == 0) {
+ _struct_composite.conf.set_papersize = ["a4.portrait", "a4.landscape"];
+ }
+ if (
+ "default" in _yaml
+ && _yaml["default"].type.sequence
+ && _yaml["default"].type.mapping
+ && _yaml["default"].tag.match(rgx.yaml_tag_is_map)
+ ) {
+ if ("text_wrap" in _yaml["default"]
+ && _yaml["default"]["text_wrap"].type.string
+ && _yaml["default"]["text_wrap"].tag.match(rgx.yaml_tag_is_str)
+ ) {
+ _struct_composite.conf.set_text_wrap = _yaml["default"]["text_wrap"].get!string;
+ }
+ if ("emphasis" in _yaml["default"]
+ && _yaml["default"]["emphasis"].type.string
+ && _yaml["default"]["emphasis"].tag.match(rgx.yaml_tag_is_str)
+ ) {
+ _struct_composite.conf.set_emphasis = _yaml["default"]["emphasis"].get!string;
+ }
+ if ("language" in _yaml["default"]
+ && _yaml["default"]["language"].type.string
+ && _yaml["default"]["language"].tag.match(rgx.yaml_tag_is_str)
+ ) {
+ _struct_composite.conf.set_language = _yaml["default"]["language"].get!string;
+ }
+ if ("digest" in _yaml["default"]
+ && _yaml["default"]["digest"].type.string
+ && _yaml["default"]["digest"].tag.match(rgx.yaml_tag_is_str)
+ ) {
+ _struct_composite.conf.set_digest = _yaml["default"]["digest"].get!string;
}
}
if ("search" in _yaml
@@ -906,17 +988,18 @@ template configParseYAMLreturnSpineStruct() {
doc_reform.meta.conf_make_meta_structs,
doc_reform.meta.conf_make_meta_json;
mixin contentYAMLtoSpineStruct;
- @system auto configParseYAMLreturnSpineStruct(T,CCm,M)(
+ @system auto configParseYAMLreturnSpineStruct(T,CCm,M,O)(
T _document_struct,
CCm _make_and_meta_struct,
- M _manifested
+ M _manifested,
+ O _opt_action
){
Node _yaml;
if (_document_struct.content.length > 0) {
try {
_yaml = Loader.fromString(_document_struct.content).load();
_make_and_meta_struct
- = contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _document_struct.filename); // struct from yaml
+ = contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _opt_action, _document_struct.filename);
} catch {
import std.stdio;
writeln("ERROR failed to parse content as yaml: ", _document_struct.filename);
@@ -944,10 +1027,11 @@ template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() {
mixin spineRgxIn;
mixin contentJSONtoSpineStruct;
static auto rgx = RgxI();
- @system auto docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(CCm,Src,M)(
+ @system auto docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct(CCm,Src,M,O)(
Src header_src,
CCm _make_and_meta_struct,
M _manifested,
+ O _opt_action,
) {
Node _yaml;
try {
@@ -955,7 +1039,7 @@ template docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct() {
if (("title" in _yaml) && ("creator" in _yaml)) {} else { // need test for _yaml content (does not work)
writeln("ERROR failed to read document header, yaml header does not contain essential information related to title and author");
}
- return contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, "header");
+ return contentYAMLtoSpineStruct!()(_make_and_meta_struct, _yaml, _manifested, _opt_action, "header");
} catch {
import std.stdio;
writeln("ERROR failed to read document header, header not parsed as yaml: ", _manifested.src.filename);