diff options
Diffstat (limited to 'src/sdp/output')
-rw-r--r-- | src/sdp/output/paths_source.d | 125 | ||||
-rw-r--r-- | src/sdp/output/rgx.d | 7 | ||||
-rw-r--r-- | src/sdp/output/source_sisupod.d | 18 |
3 files changed, 125 insertions, 25 deletions
diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index de14b23..c22efe0 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -15,11 +15,11 @@ template PodManifest() { mixin SiSUrgxInit; static auto rgx = Rgx(); auto PodManifest(P)( - P _pth, + P _pth = "", ) { struct ManifestFile_ { auto pod_manifest_filename() { - string _manifest_file = "sisudoc.txt"; + string _manifest_file = "sisupod.manifest"; return _manifest_file; } auto pod_manifest_path() { @@ -30,8 +30,7 @@ template PodManifest() { } else if (_pth.match(rgx.src_pth_contents) && (_pth.isFile)) { _manifest_path = dirName(_pth); - } else { - // _manifest_path = ""; + // } else { // _manifest_path = ""; } return _manifest_path; } @@ -43,6 +42,105 @@ template PodManifest() { return ManifestFile_(); } } +template PodManifestAndSrcFile() { + mixin SiSUrgxInit; + static auto rgx = Rgx(); + auto PodManifestAndSrcFile(O,E,P,F)( + O _opt_actions, + E _env, + P _pth = "", + F _fns = "", + char[][] _manifest_fn_list = [[]], + ) { + auto _manifest = PodManifest!()(_pth); + struct ManifestFilePlus_ { + auto pwd() { + return _env["pwd"]; + } + auto home() { + return _env["home"]; + } + auto opt_action() { + return _opt_actions; + } + auto is_pod() { + auto _is_pod = (_manifest.pod_manifest_path.length > 0) ? true : false; + return _is_pod; + } + auto pod_manifest_list_of_filenames() { + return _manifest_fn_list; + } + auto pod_manifest_list_of_languages() { + string[] _lngs; + foreach (filename_; pod_manifest_list_of_filenames) { + string _k = "en"; + if (auto m = (filename_).match(rgx.language_code_and_filename)) { + _k = m.captures[1].to!string; + } + _lngs ~= _k; // all the languages from the manifest list of filenames with paths + } + return _lngs; + } + auto pod_manifest_filename() { + return _manifest.pod_manifest_filename; + } + auto pod_manifest_path() { + return _manifest.pod_manifest_path; + } + auto pod_manifest_file_with_path() { + return _manifest.pod_manifest_file_with_path; + } + auto pod_config_dirs() { // TODO + string[] _config_dirs; + return _config_dirs; + } + auto pod_image_dirs() { // TODO + string[] _image_dirs; + return _image_dirs; + } + auto src_fn() { + return _fns; + } + auto src_lng() { + string _k; + if (auto m = (src_fn).match(rgx.language_code_and_filename)) { + _k = m.captures[1]; + } else { + _k = "en"; + } + return _k; + } + auto output_path() { + auto _output_path = pwd; + if ((_opt_actions.output_dir_set.length > 0) + && isValidPath(_opt_actions.output_dir_set) + ) { + _output_path = asNormalizedPath(_opt_actions.output_dir_set).array; + if (!exists(_output_path)) { + _output_path.mkdirRecurse; + } + assert(_output_path.isDir); + } + return _output_path; + } + auto src_config_dirs() { // TODO + string[] _config_dirs; + if (is_pod) { + } else { + } + return _config_dirs; + } + auto src_image_dirs() { // TODO + string[] _image_dirs; + if (is_pod) { + } else { + } + return _image_dirs; + } + } + return ManifestFilePlus_(); + } +} template ConfigFilePaths() { mixin SiSUrgxInit; static auto rgx = Rgx(); @@ -174,10 +272,7 @@ template SiSUpathsSisupods() { string _base_dir_pod = "sisupod"; string _base_dir_doc = "sisudoc"; string _suffix = ".zip"; - auto SiSUpathsSisupods(Ps,Lng)( - Ps src_pth_info, - Lng lng, - ) { + auto SiSUpathsSisupods()() { struct _PodPaths { string base_filename_(string fn_src) { auto pth = fn_src.baseName.stripExtension; @@ -332,7 +427,7 @@ template SiSUpathsSisupods() { } return _pods(); } - auto doc_lng(string fn_src) { + auto doc_lng(string fn_src, string lng) { auto pod_root_ = pod_root(fn_src); auto pth_1_ = text_root(fn_src).zpod.chainPath(lng).array; auto pth_2_ = text_root(fn_src).filesystem_open_zpod.chainPath(lng).array; @@ -378,10 +473,10 @@ template SiSUpathsSisupods() { } return _pods(); } - auto fn_doc(string fn_src) { + auto fn_doc(string fn_src, string lng) { auto pod_root_ = pod_root(fn_src); - auto pth_1_ = doc_lng(fn_src).zpod.chainPath(fn_src.baseName).array; - auto pth_2_ = doc_lng(fn_src).filesystem_open_zpod.chainPath(fn_src.baseName).array; + auto pth_1_ = doc_lng(fn_src, lng).zpod.chainPath(fn_src.baseName).array; + auto pth_2_ = doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_src.baseName).array; struct _pods { auto zpod() { return pth_1_; @@ -393,10 +488,10 @@ template SiSUpathsSisupods() { } return _pods(); } - auto fn_doc_insert(string fn_src, string fn_insert) { + auto fn_doc_insert(string fn_src, string fn_insert, string lng) { auto pod_root_ = pod_root(fn_src); - auto pth_1_ = doc_lng(fn_src).zpod.chainPath(fn_insert.baseName).array; - auto pth_2_ = doc_lng(fn_src).filesystem_open_zpod.chainPath(fn_insert.baseName).array; + auto pth_1_ = doc_lng(fn_src, lng).zpod.chainPath(fn_insert.baseName).array; + auto pth_2_ = doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_insert.baseName).array; struct _pods { auto zpod() { return pth_1_; diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index c9f0175..9daaa3b 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -16,10 +16,13 @@ static template SiSUoutputRgxInit() { 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_contents = ctRegex!(`^(?P<path>[/]?(?:[a-zA-Z0-9._-]+/)*)(?P<filename>[a-zA-Z0-9._-]+)/sisudoc[.]txt$`); + 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])$`); - 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._-]+/sisupod[.]manifest)|(?P<filezip>[a-zA-Z0-9._-]+[.]zip))$`); + static pod_content_location = + ctRegex!(`^(?P<filename>[a-zA-Z0-9._-]+[.]ss[tm])(?P<languages>(?:\s+[a-z]{2}(?:,|$))+)`, "mg"); static src_fn = 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)$`); diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index 6e06667..106c419 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -17,9 +17,8 @@ template SiSUpod() { mixin SiSUoutputRgxInit; string pwd = doc_matters.environment["pwd"]; auto src_path_info = doc_matters.src_path_info; - string lng = doc_matters.language; auto pth_sisudoc_src = doc_matters.src_path_info; - auto pths_sisupod = SiSUpathsSisupods!()(src_path_info, lng); + auto pths_sisupod = SiSUpathsSisupods!()(); mixin SiSUlanguageCodes; auto lang = Lang(); static auto rgx = Rgx(); @@ -46,14 +45,14 @@ template SiSUpod() { if (!exists(pths_sisupod.image_root(doc_matters.source_filename).filesystem_open_zpod)) { pths_sisupod.image_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pths_sisupod.doc_lng(doc_matters.source_filename).filesystem_open_zpod)) { - pths_sisupod.doc_lng(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; + if (!exists(pths_sisupod.doc_lng(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod)) { + pths_sisupod.doc_lng(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod.mkdirRecurse; } } debug(sisupod) { writeln(__LINE__, ": ", doc_matters.source_filename, " -> ", - pths_sisupod.fn_doc(doc_matters.source_filename).filesystem_open_zpod + pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod ); } auto zip = new ZipArchive(); @@ -102,9 +101,9 @@ template SiSUpod() { } } { /+ TODO bundle primary file +/ auto fn_src_in = doc_matters.source_filename; - auto fn_src_out_sisupod_zip_base = pths_sisupod.fn_doc(doc_matters.source_filename).zpod.to!string; - auto fn_src_out_filesystem = pths_sisupod.fn_doc(doc_matters.source_filename).filesystem_open_zpod.to!string; // needed without root path: - auto fn_src_out_inside_pod = pths_sisupod.fn_doc(doc_matters.source_filename).zpod.to!string; // needed without root path: + auto fn_src_out_sisupod_zip_base = pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).zpod.to!string; + auto fn_src_out_filesystem = pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).filesystem_open_zpod.to!string; // needed without root path: + auto fn_src_out_inside_pod = pths_sisupod.fn_doc(doc_matters.source_filename, doc_matters.language).zpod.to!string; // needed without root path: string[] filelist_src_out_sisupod_arr; string[] filelist_src_zpod_arr; if (exists(fn_src_in)) { @@ -135,6 +134,7 @@ template SiSUpod() { pths_sisupod.fn_doc_insert( doc_matters.source_filename, insert_file, + doc_matters.language, ).zpod ); } @@ -143,11 +143,13 @@ template SiSUpod() { pths_sisupod.fn_doc_insert( doc_matters.source_filename, insert_file, + doc_matters.language, ).zpod.to!string; auto fn_src_out_filesystem = pths_sisupod.fn_doc_insert( doc_matters.source_filename, insert_file, + doc_matters.language, ).filesystem_open_zpod.to!string; if (exists(fn_src_in)) { if (doc_matters.opt_action.source) { |