diff options
author | Ralph Amissah <ralph@amissah.com> | 2017-12-15 14:06:16 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 2e852762085122d1b36641a04bcc63d5235139cd (patch) | |
tree | b0f039492688fc0604f98ff4eb588deb266f1e0d /src/sdp | |
parent | 0.23.1 use output path specified if any (diff) |
0.23.2 config paths for pod
Diffstat (limited to 'src/sdp')
-rw-r--r-- | src/sdp/meta/metadoc.d | 12 | ||||
-rw-r--r-- | src/sdp/meta/read_config_files.d | 8 | ||||
-rw-r--r-- | src/sdp/meta/read_source_files.d | 6 | ||||
-rw-r--r-- | src/sdp/meta/rgx.d | 2 | ||||
-rw-r--r-- | src/sdp/output/paths_source.d | 87 | ||||
-rw-r--r-- | src/sdp/output/rgx.d | 2 | ||||
-rw-r--r-- | src/sdp/output/source_sisupod.d | 4 | ||||
-rwxr-xr-x | src/sdp/sdp.d | 6 |
8 files changed, 85 insertions, 42 deletions
diff --git a/src/sdp/meta/metadoc.d b/src/sdp/meta/metadoc.d index e3947e5..8fafc24 100644 --- a/src/sdp/meta/metadoc.d +++ b/src/sdp/meta/metadoc.d @@ -31,14 +31,14 @@ template SiSUabstraction() { enum makeMeta { make, meta } enum docAbst { doc_abstraction, section_keys, segnames, segnames_0_4, images } static auto rgx = Rgx(); - auto SiSUabstraction(M,O,E)( - M _manifest, - O _opt_action, + auto SiSUabstraction(E,O,M)( E _env, + O _opt_action, + M _manifest, ){ - auto sdl_root_config_share = configRead!()("config_share", _env); - auto sdl_root_config_local = configRead!()("config_local", _env); - auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_share, sdl_root_config_local); + auto sdl_root_config_document = configRead!()(_manifest, _env, "config_document"); // document config file + auto sdl_root_config_local_site = configRead!()(_manifest, _env, "config_local_site"); // local site config + auto conf_files_composite_make = confFilesSDLtoStruct!()(sdl_root_config_document, sdl_root_config_local_site); /+ ↓ read file (filename with path) +/ /+ ↓ file tuple of header and content +/ debug(steps) { diff --git a/src/sdp/meta/read_config_files.d b/src/sdp/meta/read_config_files.d index 369d9c2..b3c7f1b 100644 --- a/src/sdp/meta/read_config_files.d +++ b/src/sdp/meta/read_config_files.d @@ -10,8 +10,8 @@ static template configIn() { sdp.output.paths_source, std.file, std.path; - final string configIn(C,E)(C conf_sdl, E env) { - auto possible_config_path_locations = ConfigFilePaths!()(env).possible_config_path_locations; + final string configIn(M,E,C)(M manifest, E env, C conf_sdl) { + auto possible_config_path_locations = ConfigFilePaths!()(manifest, env).possible_config_path_locations; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( @@ -70,8 +70,8 @@ static template configRead() { std.file, std.path; - final auto configRead(C,E)(C conf_sdl, E env) { - auto configuration = configIn!()(conf_sdl, env); + final auto configRead(M,E,C)(M manifest, E env, C conf_sdl) { + auto configuration = configIn!()(manifest, env, conf_sdl); auto sdl_root = ConfigSDLang!()(configuration, conf_sdl); return sdl_root; } diff --git a/src/sdp/meta/read_source_files.d b/src/sdp/meta/read_source_files.d index 2fce0be..95a9dbe 100644 --- a/src/sdp/meta/read_source_files.d +++ b/src/sdp/meta/read_source_files.d @@ -115,7 +115,7 @@ static template SiSUrawMarkupContent() { auto markupSourceReadIn(in string fn_src) { static auto rgx = Rgx(); enforce( - fn_src.match(rgx.src_pth), + fn_src.match(rgx.src_pth_sst_or_ssm), "not a sisu markup filename: «" ~ fn_src ~ "»" ); @@ -161,7 +161,7 @@ static template SiSUrawMarkupContent() { mixin SiSUrgxInitFlags; char[][] contents_insert; auto type1 = flags_type_init; - auto fn_pth_full = fn_src.match(rgx.src_pth); + auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; foreach (line; markup_sourcefile_insert_content) { if (type1["curly_code"] == 1) { @@ -260,7 +260,7 @@ static template SiSUrawMarkupContent() { mixin SiSUrgxInitFlags; char[][] contents; auto type = flags_type_init; - auto fn_pth_full = fn_src.match(rgx.src_pth); + auto fn_pth_full = fn_src.match(rgx.src_pth_sst_or_ssm); auto markup_src_file_path = fn_pth_full.captures[1]; char[][] contents_insert; string[] _images =[]; diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d index 73f7bfe..37db8e7 100644 --- a/src/sdp/meta/rgx.d +++ b/src/sdp/meta/rgx.d @@ -196,7 +196,7 @@ static template SiSUrgxInit() { static nbsp_chars_line_start = ctRegex!(`^░+`, "mg"); static nbsp_and_space = ctRegex!(` [ ]`, "mg"); static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); - static src_pth = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`); + static src_pth_sst_or_ssm = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`); static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+)/sisupod[.]manifest$`); static src_pth_zip = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); static src_pth_unzip_pod = ctRegex!(`^(?P<path>media/text/[a-z]{2}/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 0a8b447..4f8eb54 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -117,9 +117,16 @@ template PodMatters() { ) { _output_path = asNormalizedPath(_opt_actions.output_dir_set).array; if (!exists(_output_path)) { - _output_path.mkdirRecurse; + try { + _output_path.mkdirRecurse; + } + catch (Exception ex) { + // Handle error + } } - assert(_output_path.isDir); + assert(_output_path.isDir, + "not a directory: " ~ _output_path); + // TODO always test that is a directory and it is writable } return _output_path; } @@ -144,34 +151,70 @@ template PodMatters() { template ConfigFilePaths() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto ConfigFilePaths(E)( + auto ConfigFilePaths(M,E)( + M _manifest, E _env, ) { struct ConfFilePaths { auto possible_config_path_locations() { /+ FIX clean up conf paths ↓ +/ - string _sisudoc_conf_pwd = chainPath(to!string(_env["pwd"]), "sisudoc/conf").array; - string _sisudoc_conf_pwd_a = chainPath(to!string(_env["pwd"]), "conf").array; - string _sisudoc_conf_pwd_b = chainPath(to!string(_env["pwd"]), "../conf").array; - string _sisudoc_conf_pwd_c = chainPath(to!string(_env["pwd"]), "../../conf").array; - string _sisudoc_conf_pwd_d = chainPath(to!string(_env["pwd"]), "../../../conf").array; + /+ config local site (file system only, not in pod) +/ + string _dot_pwd; + string _underscore_pwd; + string _dot_home; + /+ config document (& or local site) on filesystem +/ + string _sisudoc_conf_pwd; // think about + string _sisudoc_conf_pwd_a; + string _sisudoc_conf_pwd_b; + string _sisudoc_conf_pwd_c; + string _sisudoc_conf_pwd_d; + /+ config document in pod +/ + string _sisudoc_conf_pod; + string _sisudoc_conf_pod_text; + /+ return paths +/ + string[] _possible_config_path_locations; + if (_manifest.is_pod) { + /+ config document in pod +/ + _sisudoc_conf_pod = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifest.pod_manifest_path ~ "/conf" + )).array; + _sisudoc_conf_pod_text = asNormalizedPath(chainPath( + to!string(_env["pwd"]), + _manifest.pod_manifest_path ~ "/media/text/" ~ _manifest.src_lng ~ "/conf" + )).array; + /+ return paths +/ + _possible_config_path_locations = [ + _sisudoc_conf_pod_text, + _sisudoc_conf_pod, + ]; + } else { + /+ config local site (file system only, not in pod) +/ + _dot_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), ".sisu")).array; + _underscore_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "_sisu")).array; + _dot_home = asNormalizedPath(chainPath(to!string(_env["home"]), ".sisu")).array; + /+ config document (& or local site) on filesystem +/ + _sisudoc_conf_pwd = asNormalizedPath(chainPath(to!string(_env["pwd"]), "sisudoc/conf")).array; // think about + _sisudoc_conf_pwd_a = asNormalizedPath(chainPath(to!string(_env["pwd"]), "conf")).array; + _sisudoc_conf_pwd_b = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../conf")).array; + _sisudoc_conf_pwd_c = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../conf")).array; + _sisudoc_conf_pwd_d = asNormalizedPath(chainPath(to!string(_env["pwd"]), "../../../conf")).array; + /+ return paths +/ + _possible_config_path_locations = [ + _sisudoc_conf_pwd, + _sisudoc_conf_pwd_a, + _sisudoc_conf_pwd_b, + _sisudoc_conf_pwd_c, + _sisudoc_conf_pwd_d, + _dot_pwd, + _underscore_pwd, + _dot_home, + "/etc/sisu" + ]; + } /+ FIX clean up conf paths ↑ (compare pwd to doc path location, and build config path) +/ - string _dot_pwd = chainPath(to!string(_env["pwd"]), ".sisu").array; - string _underscore_pwd = chainPath(to!string(_env["pwd"]), "_sisu").array; - string _dot_home = chainPath(to!string(_env["home"]), ".sisu").array; - string[] _possible_config_path_locations = [ - _sisudoc_conf_pwd, - _sisudoc_conf_pwd_a, - _sisudoc_conf_pwd_b, - _sisudoc_conf_pwd_c, - _sisudoc_conf_pwd_d, - _dot_pwd, - _underscore_pwd, - _dot_home, - "/etc/sisu" - ]; return _possible_config_path_locations; } } diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index 9daaa3b..3e03620 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -15,7 +15,7 @@ static template SiSUoutputRgxInit() { static nbsp_chars_line_start = ctRegex!(`^░+`, "mg"); static nbsp_and_space = ctRegex!(` [ ]`, "mg"); static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg"); - static src_pth = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`); + static src_pth_sst_or_ssm = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])$`); static src_pth_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+)/sisupod[.]manifest$`); static src_pth_zip = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); static src_pth_unzip_pod = ctRegex!(`^(?P<path>media/text/[a-z]{2}/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index 20eaf39..0d529b6 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -190,7 +190,7 @@ template SiSUpod() { catch (ZipException ex) { // Handle errors } - if (doc_matters.source_filename == "sisudoc/text/en/the_wealth_of_networks.yochai_benkler.sst") { + if (doc_matters.source_filename == "sisudoc/media/text/en/the_wealth_of_networks.yochai_benkler.sst") { assert( ((data).sha256Of).toHexString == "626F83A31ED82F42CF528E922C1643498A137ABA3F2E5AFF8A379EA79EA22A1E", @@ -200,7 +200,7 @@ template SiSUpod() { ~ ((data).sha256Of).toHexString ); } - if (doc_matters.source_filename == "sisudoc/text/en/sisu_markup_stress_test.sst") { + if (doc_matters.source_filename == "sisudoc/media/text/en/sisu_markup_stress_test.sst") { assert( ((data).sha256Of).toHexString == "AAE0C87AB3F6D5F7385AEEA6EE661F56D40475CFE87AD930C78C9FE07FFB0D91", diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d index f4d738f..418eb1f 100755 --- a/src/sdp/sdp.d +++ b/src/sdp/sdp.d @@ -309,7 +309,7 @@ void main(string[] args) { _manifest_start = PodManifest!()(arg); if (arg.match(rgx.flag_action)) { flag_action ~= " " ~ arg; // flags not taken by getopt - } else if (arg.match(rgx.src_pth)) { + } else if (arg.match(rgx.src_pth_sst_or_ssm)) { _manifests ~= PodMatters!()(_opt_action, _env, arg, arg); // gather input markup source file names for processing } else if (_manifest_start.pod_manifest_file_with_path) { string contents_location_raw_; @@ -343,7 +343,7 @@ void main(string[] args) { (cast(char[]) contents_location_).split; auto tmp_dir_ = (sisudoc_txt_).dirName.array; foreach (contents_location; contents_locations_arr) { - assert(contents_location.match(rgx.src_pth), + assert(contents_location.match(rgx.src_pth_sst_or_ssm), "not a recognised file: «" ~ contents_location ~ "»" ); @@ -393,7 +393,7 @@ void main(string[] args) { "not a sisu markup filename: «" ~ manifest.src_fn ~ "»" ); - auto t = SiSUabstraction!()(manifest, _opt_action, _env); + auto t = SiSUabstraction!()(_env, _opt_action, manifest); static assert(!isTypeTuple!(t)); static assert(t.length==2); auto doc_abstraction = t[dAM.abstraction]; |