diff options
Diffstat (limited to 'org/default_paths.org')
-rw-r--r-- | org/default_paths.org | 209 |
1 files changed, 148 insertions, 61 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 |