diff options
Diffstat (limited to 'org')
-rw-r--r-- | org/default_paths.org | 209 | ||||
-rw-r--r-- | org/default_regex.org | 10 | ||||
-rw-r--r-- | org/imports.org | 1 | ||||
-rw-r--r-- | org/meta_read_source_files.org | 25 | ||||
-rw-r--r-- | org/sdp.org | 20 |
5 files changed, 165 insertions, 100 deletions
diff --git a/org/default_paths.org b/org/default_paths.org index cb1826d..805e8a9 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -26,84 +26,97 @@ +/ module sdp.output.paths_source; import std.array, + std.file, std.path, std.regex, - std.stdio; + std.stdio, + std.conv : to; import sdp.meta.rgx; -template SiSUpathsSRC() { +<<template_paths_src>> +<<template_paths_sisupod>> +<<template_paths_sisupod_shallow>> +<<template_paths_sisupods>> +#+END_SRC + +** _manifest_ :manifest: + +#+name: template_paths_src +#+BEGIN_SRC d +template ManifestFile() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsSRC(D,Fn)( - D _pwd, - Fn _fn_src_and_relative_path, + auto ManifestFile(P)( + P _pth, ) { - struct SisuSrcPaths { - auto pwd() { - return _pwd; - } - auto language() { - // use command line info as well? - string _k; - if (auto m = _fn_src_and_relative_path.match(rgx.language_code_and_filename)) { - _k = m.captures[1]; + struct ManifestFile_ { + auto manifest_file() { + string _manifest_file = "sisudoc.txt"; + return _manifest_file; + } + auto manifest_file_and_path() { + string _manifest_file_and_path; + if (isValidPath(_pth) && _pth.isDir + && ((_pth.chainPath(manifest_file).array).isFile)) { + _manifest_file_and_path = _pth.chainPath(manifest_file).array; + } else if (_pth.match(rgx.src_pth_contents) + && (_pth.isFile)) { + _manifest_file_and_path = _pth; } else { - _k = "xx"; // original default was "en" but is not known + // _manifest_file_and_path = ""; } - return _k; - } - auto doc_root() { - return "sisudoc"; - } - auto media_root() { - return doc_root.chainPath("media").array; - } - auto conf_root() { - return doc_root.chainPath("conf").array; - } - auto text_root() { - return media_root.chainPath("text").array; - } - auto image_root() { - return media_root.chainPath("image").array; - } - auto doc_src_fn_with_path_for_text_root_and_lng() { - return text_root.chainPath(language).array; - } - auto doc_src_with_relative_path() { - return pwd.chainPath(_fn_src_and_relative_path).array; - } - auto doc_src_fn() { - return _fn_src_and_relative_path.baseName.array; + return _manifest_file_and_path; } } - return SisuSrcPaths(); + return ManifestFile_(); } } #+END_SRC -* 1. output paths :module:sdp:paths_output: -** 0. module template +** _config_ :config: -#+BEGIN_SRC d :tangle ../src/sdp/output/paths_output.d -/++ - default settings -+/ -module sdp.output.paths_output; -import std.array, - std.path, - std.regex, - std.stdio; -import sdp.meta.rgx; -<<template_paths_sisupod>> -<<template_paths_sisupod_shallow>> -<<template_paths_sisupods>> -<<template_paths_out>> -<<template_paths_html>> -<<template_paths_epub>> -<<template_paths_sqlite>> +#+name: template_paths_src +#+BEGIN_SRC d +template ConfigFilePaths() { + mixin SiSUrgxInit; + static auto rgx = Rgx(); + auto ConfigFilePaths(E)( + 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; + /+ 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; + } + } + return ConfFilePaths(); + } +} #+END_SRC -** _sisupod_ (output bundled source) :sisupod: +** _sisupod_ (including generated bundled source) :sisupod: +*** notes tree sisupod sisupod @@ -148,6 +161,61 @@ filelist for processing [things to ponder] - if necessary manually create filelist (for multilinugual source) - keep document root for document inserts (.ssi) +*** manual source + +#+name: template_paths_src +#+BEGIN_SRC d +template SiSUpathsSRC() { + mixin SiSUrgxInit; + static auto rgx = Rgx(); + auto SiSUpathsSRC(D,Fn)( + D _pwd, + Fn _fn_src_and_relative_path, + ) { + struct SisuSrcPaths { + auto pwd() { + return _pwd; + } + auto language() { + // use command line info as well? + string _k; + if (auto m = _fn_src_and_relative_path.match(rgx.language_code_and_filename)) { + _k = m.captures[1]; + } else { /+ unknown until doc_meta read, (could provide & use command line info?) +/ + _k = "xx"; // original default was "en" but is not known + } + return _k; + } + auto doc_root() { + return "sisudoc"; + } + auto media_root() { + return doc_root.chainPath("media").array; + } + auto conf_root() { + return doc_root.chainPath("conf").array; + } + auto text_root() { + return media_root.chainPath("text").array; + } + auto image_root() { + return media_root.chainPath("image").array; + } + auto doc_src_fn_with_path_for_text_root_and_lng() { + return text_root.chainPath(language).array; + } + auto doc_src_with_relative_path() { + return pwd.chainPath(_fn_src_and_relative_path).array; + } + auto doc_src_fn() { + return _fn_src_and_relative_path.baseName.array; + } + } + return SisuSrcPaths(); + } +} +#+END_SRC + *** pod archive base #+name: template_paths_sisupod @@ -441,6 +509,25 @@ template SiSUpathsSisupods() { } #+END_SRC +* 1. output paths :module:sdp:paths_output: +** 0. module template + +#+BEGIN_SRC d :tangle ../src/sdp/output/paths_output.d +/++ + default settings ++/ +module sdp.output.paths_output; +import std.array, + std.path, + std.regex, + std.stdio; +import sdp.meta.rgx; +<<template_paths_out>> +<<template_paths_html>> +<<template_paths_epub>> +<<template_paths_sqlite>> +#+END_SRC + ** shared out path, base directory :out: #+name: template_paths_out diff --git a/org/default_regex.org b/org/default_regex.org index 9a17633..334b025 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -411,13 +411,13 @@ static nbsp_char_and_space = ctRegex!(`░[ ]`, "mg") #+name: prgmkup_rgx #+BEGIN_SRC d -static src_pth = 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._-]+)/sisudoc[.]txt$`); -static src_pth_zip = ctRegex!(`^(?P<path>(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+[.]zip)$`); +static src_pth = 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._-]+)/sisudoc[.]txt$`); +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])$`); -static src_pth_types = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/sisudoc[.]txt)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); +static src_pth_types = ctRegex!(`^(?P<path>[/]?[a-zA-Z0-9._-]+/)*(?P<gotfile>(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])|(?P<filelist>[a-zA-Z0-9._-]+/sisudoc[.]txt)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); static src_fn = - ctRegex!(`^([a-zA-Z0-9._-]+/)*(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); + ctRegex!(`^([/]?(?:[a-zA-Z0-9._-]+/)*)(?P<fn_src>(?P<fn_base>[a-zA-Z0-9._-]+)[.](?P<fn_src_suffix>ss[tm]))$`); static src_fn_master = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssm)$`); static src_fn_text = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]sst)$`); static src_fn_insert = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ssi)$`); diff --git a/org/imports.org b/org/imports.org index bc1ce3e..3fd71a2 100644 --- a/org/imports.org +++ b/org/imports.org @@ -73,6 +73,7 @@ public import // std.uni, std.utf; public import + sdp.output.paths_source, sdp.output.defaults, sdp.output.paths_output, sdp.output.rgx; diff --git a/org/meta_read_source_files.org b/org/meta_read_source_files.org index 5e32b1f..6b44dfb 100644 --- a/org/meta_read_source_files.org +++ b/org/meta_read_source_files.org @@ -21,6 +21,7 @@ #+BEGIN_SRC d import sdp.meta, + sdp.output.paths_source, std.file, std.path; #+END_SRC @@ -47,29 +48,7 @@ module sdp.meta.read_config_files; static template configIn() { <<imports_std>> final string configIn(C,E)(C conf_sdl, E env) { - /+ 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; - /+ 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" - ]; + auto possible_config_path_locations = ConfigFilePaths!()(env).possible_config_path_locations; string config_file_str; foreach(pth; possible_config_path_locations) { auto conf_file = format( diff --git a/org/sdp.org b/org/sdp.org index a6e552f..e6b26fc 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -26,7 +26,7 @@ struct Version { int minor; int patch; } -enum ver = Version(0, 20, 1); +enum ver = Version(0, 20, 2); #+END_SRC #+NAME: version_txt @@ -485,21 +485,19 @@ auto _opt_action = OptActions(); #+NAME: sdp_args #+BEGIN_SRC d foreach(arg; args[1..$]) { + auto _manifest = ManifestFile!()(arg); if (arg.match(rgx.flag_action)) { flag_action ~= " " ~ arg; // flags not taken by getopt } else if (arg.match(rgx.src_pth)) { fns_src ~= arg; // gather input markup source file names for processing - } else if (arg.match(rgx.src_pth_contents) - || ((arg.isDir) && ((arg.chainPath("sisudoc.txt").array).isFile)) - ) { + } else if (_manifest.manifest_file_and_path) { string contents_location_; - string sisudoc_txt_; - if ((arg.chainPath("sisudoc.txt").array).isFile) { - sisudoc_txt_ = arg.chainPath("sisudoc.txt").array; - } else if (arg.match(rgx.src_pth_contents)) { - sisudoc_txt_ = arg; - } else { - } + string sisudoc_txt_ = _manifest.manifest_file_and_path; + enforce( + exists(sisudoc_txt_)!=0, + "file not found: «" ~ + sisudoc_txt_ ~ "»" + ); try { if (exists(sisudoc_txt_)) { contents_location_ = sisudoc_txt_.readText; |