diff options
Diffstat (limited to 'org/meta_conf_make_meta.org')
-rw-r--r-- | org/meta_conf_make_meta.org | 294 |
1 files changed, 189 insertions, 105 deletions
diff --git a/org/meta_conf_make_meta.org b/org/meta_conf_make_meta.org index 4a5e610..d80a270 100644 --- a/org/meta_conf_make_meta.org +++ b/org/meta_conf_make_meta.org @@ -251,56 +251,56 @@ struct ConfCompositeMakeInit { #+NAME: meta_defaults_template_structs #+BEGIN_SRC d 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; } #+END_SRC @@ -410,10 +410,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; @@ -689,7 +690,9 @@ if ("webserv" in _yaml ) { _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) ) { @@ -697,7 +700,9 @@ if ("webserv" in _yaml } 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) ) { @@ -722,13 +727,6 @@ if ("webserv" in _yaml ) { _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) @@ -746,13 +744,24 @@ if ("webserv" in _yaml ~ "/" ~ _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) ) { @@ -764,7 +773,9 @@ if ("webserv" in _yaml 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 @@ -864,42 +875,113 @@ if ("flag" in _yaml } } } -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 @@ -1652,27 +1734,27 @@ if ("default" in _json.object) { 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) { @@ -1988,17 +2070,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); @@ -2031,10 +2114,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 { @@ -2042,7 +2126,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); |