diff options
Diffstat (limited to 'src/doc_reform/meta')
-rw-r--r-- | src/doc_reform/meta/conf_make_meta_json.d | 10 | ||||
-rw-r--r-- | src/doc_reform/meta/conf_make_meta_structs.d | 100 | ||||
-rw-r--r-- | src/doc_reform/meta/conf_make_meta_yaml.d | 184 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc.d | 6 | ||||
-rw-r--r-- | src/doc_reform/meta/metadoc_show_config.d | 20 |
5 files changed, 202 insertions, 118 deletions
diff --git a/src/doc_reform/meta/conf_make_meta_json.d b/src/doc_reform/meta/conf_make_meta_json.d index 23b9631..5f36fb1 100644 --- a/src/doc_reform/meta/conf_make_meta_json.d +++ b/src/doc_reform/meta/conf_make_meta_json.d @@ -317,27 +317,27 @@ static template contentJSONtoSpineStruct() { if ("papersize" in _json.object["default"] && (_json.object["default"]["papersize"].type().to!string == "string") ) { - _struct_composite.conf.default_papersize = _json.object["default"]["papersize"].str; + _struct_composite.conf.set_papersize = _json.object["default"]["papersize"].str; } if ("text_wrap" in _json.object["default"] && (_json.object["default"]["text_wrap"].type().to!string == "string") ) { - _struct_composite.conf.default_text_wrap = _json.object["default"]["text_wrap"].str; + _struct_composite.conf.set_text_wrap = _json.object["default"]["text_wrap"].str; } if ("emphasis" in _json.object["default"] && (_json.object["default"]["emphasis"].type().to!string == "string") ) { - _struct_composite.conf.default_emphasis = _json.object["default"]["emphasis"].str; + _struct_composite.conf.set_emphasis = _json.object["default"]["emphasis"].str; } if ("language" in _json.object["default"] && (_json.object["default"]["language"].type().to!string == "string") ) { - _struct_composite.conf.default_language = _json.object["default"]["language"].str; + _struct_composite.conf.set_language = _json.object["default"]["language"].str; } if ("digest" in _json.object["default"] && (_json.object["default"]["digest"].type().to!string == "string") ) { - _struct_composite.conf.default_digest = _json.object["default"]["digest"].str; + _struct_composite.conf.set_digest = _json.object["default"]["digest"].str; } } if ("search" in _json.object) { diff --git a/src/doc_reform/meta/conf_make_meta_structs.d b/src/doc_reform/meta/conf_make_meta_structs.d index 3bab7d0..34b30a3 100644 --- a/src/doc_reform/meta/conf_make_meta_structs.d +++ b/src/doc_reform/meta/conf_make_meta_structs.d @@ -141,56 +141,56 @@ struct ConfCompositeMakeInit { string texpdf_font; } struct ConfCompositeSiteLocal { - string w_srv_http; - string w_srv_domain; - string w_srv_data_http; // if not set same as webserv_http - string w_srv_data_domain; // if not set same as webserv_domain - string w_srv_data_root_part; - string w_srv_data_root_url; - string w_srv_data_root_url_html; - string w_srv_data_root_path; - string w_srv_images_root_part; - // string w_srv_url_doc_path; - string w_srv_cgi_title; - string w_srv_cgi_http; // if not set same as webserv_http - string w_srv_cgi_domain; // if not set same as webserv_domain - string w_srv_cgi_bin_part; - string w_srv_cgi_bin_path; - string w_srv_cgi_search_script; - string w_srv_cgi_search_script_raw_fn_d; - string w_srv_cgi_port; - 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_pg; - string w_srv_db_pg_table; - string w_srv_db_pg_user; - // string webserv_cgi_file_links; - string output_path; - string processing_path; - string processing_dir; - string processing_concord_max; - string flag_act0; - string flag_act1; - string flag_act2; - string flag_act3; - string flag_act4; - string flag_act5; - string flag_act6; - string flag_act7; - string flag_act8; - string flag_act9; - string default_papersize; - string default_text_wrap; - string default_emphasis; - string default_language; - string default_digest; - string permission_share_source; - string search_flag; - string search_action; - string search_db; - string search_title; + string w_srv_http; + string w_srv_domain; + string w_srv_data_http; // if not set same as webserv_http + string w_srv_data_domain; // if not set same as webserv_domain + string w_srv_data_root_part; + string w_srv_data_root_url; + string w_srv_data_root_url_html; + string w_srv_data_root_path; + string w_srv_images_root_part; + // string w_srv_url_doc_path; + string w_srv_cgi_title; + string w_srv_cgi_http; // if not set same as webserv_http + string w_srv_cgi_domain; // if not set same as webserv_domain + string w_srv_cgi_bin_part; + string w_srv_cgi_bin_path; + string w_srv_cgi_search_script; + string w_srv_cgi_search_script_raw_fn_d; + string w_srv_cgi_port; + 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_pg; + string w_srv_db_pg_table; + string w_srv_db_pg_user; + // string webserv_cgi_file_links; + string output_path; + string processing_path; + string processing_dir; + string processing_concord_max; + string flag_act0; + string flag_act1; + string flag_act2; + string flag_act3; + string flag_act4; + string flag_act5; + string flag_act6; + string flag_act7; + string flag_act8; + string flag_act9; + string[] set_papersize; + string set_text_wrap; + string set_emphasis; + string set_language; + string set_digest; + string permission_share_source; + string search_flag; + string search_action; + string search_db; + string search_title; } struct MetaComposite { string classify_dewey; 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); diff --git a/src/doc_reform/meta/metadoc.d b/src/doc_reform/meta/metadoc.d index 8432073..ebc5344 100644 --- a/src/doc_reform/meta/metadoc.d +++ b/src/doc_reform/meta/metadoc.d @@ -14,7 +14,6 @@ template spineAbstraction() { doc_reform.io_in.read_source_files, doc_reform.io_out.hub; mixin spineRgxIn; - mixin contentJSONtoSpineStruct; mixin spineBiblio; mixin spineRgxDocStructFlags; mixin outputHub; @@ -32,7 +31,7 @@ template spineAbstraction() { { /+ document config/make file +/ auto _config_document_struct = readConfigDoc!()(_manifest, _env); import doc_reform.meta.conf_make_meta_yaml; - _make_and_meta_struct = _config_document_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifest); + _make_and_meta_struct = _config_document_struct.configParseYAMLreturnSpineStruct!()(_make_and_meta_struct, _manifest, _opt_action); } /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ @@ -67,6 +66,7 @@ template spineAbstraction() { _header_body_insertfilelist_imagelist[headBody.header], _make_and_meta_struct, _manifest, + _opt_action, ); if ((_opt_action.debug_do) || (_opt_action.very_verbose) @@ -165,7 +165,7 @@ template spineAbstraction() { @safe auto action() { /+ getopt options, commandline instructions, raw - processing instructions --epub --html etc. - - command line config instructions --output-path + - command line config instructions --output +/ return _opt_action; } diff --git a/src/doc_reform/meta/metadoc_show_config.d b/src/doc_reform/meta/metadoc_show_config.d index c642cb9..4c2b976 100644 --- a/src/doc_reform/meta/metadoc_show_config.d +++ b/src/doc_reform/meta/metadoc_show_config.d @@ -63,15 +63,15 @@ template spineShowSiteConfig() { // "- flag act0:", // config.conf.flag_act0, "- default papersize:", - config.conf.default_papersize, + config.conf.set_papersize, "- default text wrap:", - config.conf.default_text_wrap, + config.conf.set_text_wrap, "- default emphasis markup symbol:", - config.conf.default_emphasis, + config.conf.set_emphasis, "- default language:", - config.conf.default_language, + config.conf.set_language, "- default hash digest:", - config.conf.default_digest, + config.conf.set_digest, "- search flag:", config.conf.search_flag, "- search action:", @@ -161,15 +161,15 @@ template spineShowConfig() { // "- flag act0:", // doc_matters.conf_make_meta.conf.flag_act0, "- default papersize:", - doc_matters.conf_make_meta.conf.default_papersize, + doc_matters.conf_make_meta.conf.set_papersize, "- default text wrap:", - doc_matters.conf_make_meta.conf.default_text_wrap, + doc_matters.conf_make_meta.conf.set_text_wrap, "- default emphasis markup symbol:", - doc_matters.conf_make_meta.conf.default_emphasis, + doc_matters.conf_make_meta.conf.set_emphasis, "- default language:", - doc_matters.conf_make_meta.conf.default_language, + doc_matters.conf_make_meta.conf.set_language, "- default hash digest:", - doc_matters.conf_make_meta.conf.default_digest, + doc_matters.conf_make_meta.conf.set_digest, "- search flag:", doc_matters.conf_make_meta.conf.search_flag, "- search action:", |