diff options
-rw-r--r-- | org/default_paths.org | 354 | ||||
-rw-r--r-- | org/default_regex.org | 4 | ||||
-rw-r--r-- | org/output_sisupod.org | 137 | ||||
-rw-r--r-- | org/sdp.org | 33 | ||||
-rw-r--r-- | src/sdp/meta/rgx.d | 4 | ||||
-rw-r--r-- | src/sdp/output/paths_output.d | 320 | ||||
-rw-r--r-- | src/sdp/output/rgx.d | 4 | ||||
-rw-r--r-- | src/sdp/output/source_sisupod.d | 137 | ||||
-rwxr-xr-x | src/sdp/sdp.d | 32 |
9 files changed, 712 insertions, 313 deletions
diff --git a/org/default_paths.org b/org/default_paths.org index 24ece4e..e874340 100644 --- a/org/default_paths.org +++ b/org/default_paths.org @@ -95,8 +95,8 @@ import std.array, std.stdio; import sdp.meta.rgx; <<template_paths_sisupod>> -<<template_paths_sisupod_zipped_archive>> -<<template_paths_sisupod_unzipped_filesystem>> +<<template_paths_sisupod_shallow>> +<<template_paths_sisupods>> <<template_paths_out>> <<template_paths_html>> <<template_paths_epub>> @@ -126,28 +126,62 @@ doc └── _sisu └── sisu_document_make -*** pod archive +filelist for processing [things to ponder] + +- the plan is to have a src manifest of related .sst or .ssm files that + can be pointed to for processing +- multilingual documents [ponder persistence for multilingual documents] + - in the case of multilingual documents, there will be multiple + source documents on list with different language codes, and to build + this list, persistence is required +- inserted documents (from master .ssm or .sst) must track document root + so inserts can be located, else not found +- consider a commandline -o --output path specifier +- steps + - auto create filelist + - for single source file + - for multilinugual source files + - process document by pointing at filelist (rather than file) + - if necessary manually create filelist (for multilinugual source) + - keep document root for document inserts (.ssi) + +*** pod archive base #+name: template_paths_sisupod #+BEGIN_SRC d template SiSUpathsSisupod() { mixin SiSUrgxInit; static auto rgx = Rgx(); - string _base_dir = "sisupod"; + string _base_dir_pod = "sisupod"; + string _base_dir_doc = "sisudoc"; string _suffix = ".zip"; auto SiSUpathsSisupod()() { struct _PathsStruct { string base_filename(string fn_src) { - return fn_src.baseName.stripExtension; + auto pth = fn_src.baseName.stripExtension; + return pth; } string sisupod_dir() { - return _base_dir; + auto pth = _base_dir_pod; + return pth; + } + string sisudoc_dir() { + auto pth = _base_dir_doc; + return pth; } string sisupod_filename(string fn_src) { - return _base_dir.chainPath(base_filename(fn_src) ~ _suffix).array; + string pth = _base_dir_pod.chainPath(base_filename(fn_src) ~ _suffix).array; + return pth; + } + string base_filesystem(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename(fn_src)).array; + assert(pth == _base_dir_pod ~ "/" ~ base_filename(fn_src), + pth ~ " == " ~ _base_dir_pod ~ "/" ~ base_filename(fn_src) ~ "?"); + return pth; } - string base(string fn_src) { - return _base_dir.chainPath(base_filename(fn_src)).array; + string base_pod(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename(fn_src)).array; // change this + return pth; } } return _PathsStruct(); @@ -155,121 +189,251 @@ template SiSUpathsSisupod() { } #+END_SRC -*** pod zipped archive +*** pods internal, zipped, unzipped -#+name: template_paths_sisupod_zipped_archive +#+name: template_paths_sisupods #+BEGIN_SRC d -template SiSUpathsSisupodZipped() { +template SiSUpathsSisupods() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsSisupodZipped(Ps,Lng)( + string _base_dir_pod = "sisupod"; + string _base_dir_doc = "sisudoc"; + string _suffix = ".zip"; + auto SiSUpathsSisupods(Ps,Lng)( Ps src_pth_info, Lng lng, ) { - struct _PathsStruct { - auto spod_pths = SiSUpathsSisupod!()(); - string sisupod_dir() { - return spod_pths.sisupod_dir; - } - string base_filename(string fn_src) { - return spod_pths.base_filename(fn_src); - } - string sisupod_filename(string fn_src) { - return spod_pths.sisupod_filename(fn_src); - } - string base(string fn_src) { - return spod_pths.base(fn_src); + struct _PodPaths { + string base_filename_(string fn_src) { + auto pth = fn_src.baseName.stripExtension; + return pth; + } + string sisupod_dir_() { + auto pth = _base_dir_pod; + return pth; + } + string sisudoc_dir_() { + auto pth = _base_dir_doc; + return pth; + } + string sisupod_filename_(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename_(fn_src) ~ _suffix).array; + return pth; + } + string base_filesystem_(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename_(fn_src)).array; + assert(pth == _base_dir_pod ~ "/" ~ base_filename_(fn_src), + pth ~ " == " ~ _base_dir_pod ~ "/" ~ base_filename_(fn_src) ~ "?"); + return pth; + } + string base_pod_(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename_(fn_src)).array; // change this + return pth; + } + auto base_filename(string fn_src) { + auto pth_1_ = base_filename_(fn_src); + auto pth_2_ = base_filename_(fn_src); + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); + } + auto sisupod_filename(string fn_src) { + auto pth_1_ = sisupod_filename_(fn_src); + auto pth_2_ = sisupod_filename_(fn_src); + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); + } + auto base(string fn_src) { + auto pth_1_ = ""; + auto pth_2_ = base_filesystem_(fn_src); + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); } auto pod_root(string fn_src) { - return "sisudoc"; - } - auto media_root(string fn_src) { - return pod_root(fn_src).chainPath("media").array; + auto pth_1_ = ""; + auto pth_2_ = base(fn_src).filesystem_open_zpod.chainPath("").array; // "sisudoc" + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); } auto conf_root(string fn_src) { - return pod_root(fn_src).chainPath("conf").array; - } - auto text_root(string fn_src) { - return media_root(fn_src).chainPath("text").array; - } - auto doc(string fn_src) { - return text_root(fn_src); - } - auto doc_lng(string fn_src) { - return text_root(fn_src).chainPath(lng).array; - } - auto image_root(string fn_src) { - return media_root(fn_src).chainPath("image").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = "conf"; + auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("conf").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto css(string fn_src) { - return conf_root(fn_src).chainPath("css").array; - } - auto fn_doc(string fn_src) { - return (doc_lng(fn_src)).chainPath(fn_src.baseName).array; - } - auto fn_doc_insert(string fn_src, string fn_insert) { - return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array; - } - } - return _PathsStruct(); - } -} -#+END_SRC - -*** pod unzipped (sisusrc), archive on filesystem - -#+name: template_paths_sisupod_unzipped_filesystem -#+BEGIN_SRC d -template SiSUpathsSisupodFileSystem() { - mixin SiSUrgxInit; - static auto rgx = Rgx(); - auto SiSUpathsSisupodFileSystem(Ps,Lng)( - Ps src_pth_info, - Lng lng, - ) { - struct _PathsStruct { - auto spod_pths = SiSUpathsSisupod!()(); - string base_filename(string fn_src) { - return spod_pths.base_filename(fn_src); - } - string sisupod_filename(string fn_src) { - return spod_pths.sisupod_filename(fn_src); - } - string base(string fn_src) { - return spod_pths.base(fn_src); - } - auto pod_root(string fn_src) { - return base(fn_src).chainPath("sisudoc").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = conf_root(fn_src).zpod.chainPath("css").array; + auto pth_2_ = conf_root(fn_src).filesystem_open_zpod.chainPath("css").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto media_root(string fn_src) { - return pod_root(fn_src).chainPath("media").array; - } - auto conf_root(string fn_src) { - return pod_root(fn_src).chainPath("conf").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = "media"; + auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("media").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto text_root(string fn_src) { - return media_root(fn_src).chainPath("text").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = media_root(fn_src).zpod.chainPath("text").array; + auto pth_2_ = media_root(fn_src).filesystem_open_zpod.chainPath("text").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto doc(string fn_src) { - return pod_root(fn_src); + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = text_root(fn_src).zpod; + auto pth_2_ = text_root(fn_src).filesystem_open_zpod; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto doc_lng(string fn_src) { - return text_root(fn_src).chainPath(lng).array; + 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; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto image_root(string fn_src) { - return media_root(fn_src).chainPath("image").array; - } - auto css(string fn_src) { - return conf_root(fn_src).chainPath("css").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = media_root(fn_src).zpod.chainPath("image").array; + auto pth_2_ = media_root(fn_src).filesystem_open_zpod.chainPath("image").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); + } + auto fn_pod_filelist(string fn_src) { + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = "sisudoc.txt"; + auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("sisudoc.txt").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto fn_doc(string fn_src) { - return (doc_lng(fn_src)).chainPath(fn_src.baseName).array; + 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; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto fn_doc_insert(string fn_src, string fn_insert) { - return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array; + 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; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } } - return _PathsStruct(); + return _PodPaths(); } } #+END_SRC diff --git a/org/default_regex.org b/org/default_regex.org index b6227c3..2783663 100644 --- a/org/default_regex.org +++ b/org/default_regex.org @@ -412,6 +412,10 @@ 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_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_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/org/output_sisupod.org b/org/output_sisupod.org index 928165b..c9d5d2a 100644 --- a/org/output_sisupod.org +++ b/org/output_sisupod.org @@ -65,8 +65,7 @@ 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 pth_sisupod = SiSUpathsSisupodZipped!()(src_path_info, lng); -auto pth_sisupod_filesystem = SiSUpathsSisupodFileSystem!()(src_path_info, lng); +auto pths_sisupod = SiSUpathsSisupods!()(src_path_info, lng); mixin SiSUlanguageCodes; auto lang = Lang(); static auto rgx = Rgx(); @@ -76,28 +75,28 @@ assert (doc_matters.source_filename.match(rgx.src_fn)); #+name: source_sisupod_mkdirs #+BEGIN_SRC d /+ create directory structure +/ -if (!exists(pth_sisupod.sisupod_dir)) { +if (!exists(pths_sisupod.sisupod_dir_())) { // used both by sisupod zipped (& sisupod filesystem (unzipped) which makes its own recursive dirs) - pth_sisupod.sisupod_dir.mkdirRecurse; + pths_sisupod.sisupod_dir_().mkdirRecurse; } if (doc_matters.opt_action["source"]) { - if (!exists(pth_sisupod_filesystem.text_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.text_root(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.text_root(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.text_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.conf_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.conf_root(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.conf_root(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.conf_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.media_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.media_root(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.media_root(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.media_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.css(doc_matters.source_filename))) { - pth_sisupod_filesystem.css(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.css(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.css(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.image_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.image_root(doc_matters.source_filename).mkdirRecurse; + 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(pth_sisupod_filesystem.doc_lng(doc_matters.source_filename))) { - pth_sisupod_filesystem.doc_lng(doc_matters.source_filename).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; } } #+END_SRC @@ -109,102 +108,111 @@ if (doc_matters.opt_action["source"]) { debug(sisupod) { writeln(__LINE__, ": ", doc_matters.source_filename, " -> ", - pth_sisupod_filesystem.fn_doc(doc_matters.source_filename) + pths_sisupod.fn_doc(doc_matters.source_filename).filesystem_open_zpod ); } auto zip = new ZipArchive(); -auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename); +auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.source_filename).zpod; { /+ bundle images +/ foreach (image; doc_matters.image_list) { debug(sisupodimages) { writeln( pth_sisudoc_src.image_root.to!string, "/", image, " -> ", - pth_sisupod.image_root(doc_matters.source_filename), "/", image + pths_sisupod.image_root(doc_matters.source_filename).zpod, "/", image ); } - auto fn_src = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; - auto fn_out = pth_sisupod.image_root(doc_matters.source_filename).to!string ~ "/" ~ image; - auto fn_out_filesystem = pth_sisupod_filesystem.image_root(doc_matters.source_filename).to!string ~ "/" ~ image; - if (exists(fn_src)) { + auto fn_src_in = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; + auto fn_src_out_sisupod_zip_base = pths_sisupod.image_root(doc_matters.source_filename).zpod.to!string ~ "/" ~ image; + auto fn_src_out_filesystem = pths_sisupod.image_root(doc_matters.source_filename).filesystem_open_zpod.to!string ~ "/" ~ image; + if (exists(fn_src_in)) { if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write(cast(char[]) ((fn_src).read)); + zip_data.write(cast(char[]) ((fn_src_in).read)); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); } } } -} -{ /+ bundle sisu_document_make +/ - auto fn_src = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make) - auto fn_out = pth_sisupod.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make"; - auto fn_out_filesystem = pth_sisupod_filesystem.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make"; - if (exists(fn_src)) { +} { /+ bundle sisu_document_make +/ + auto fn_src_in = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make) + auto fn_src_out_sisupod_zip_base = pths_sisupod.conf_root(doc_matters.source_filename).zpod.to!string ~ "/" ~ "sisu_document_make"; + auto fn_src_out_filesystem = pths_sisupod.conf_root(doc_matters.source_filename).filesystem_open_zpod.to!string ~ "/" ~ "sisu_document_make"; + if (exists(fn_src_in)) { if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write((fn_src).readText); + zip_data.write((fn_src_in).readText); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); } } -} -{ /+ bundle primary file +/ - auto fn_src = doc_matters.source_filename; - auto fn_out = pth_sisupod.fn_doc(doc_matters.source_filename).to!string; - auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc(doc_matters.source_filename).to!string; - if (exists(fn_src)) { +} { /+ 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: + string[] filelist_src_out_sisupod_arr; + string[] filelist_src_zpod_arr; + if (exists(fn_src_in)) { + filelist_src_out_sisupod_arr ~= fn_src_out_sisupod_zip_base; + filelist_src_zpod_arr ~= fn_src_out_inside_pod; if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + auto filelist = File(pths_sisupod.fn_pod_filelist(doc_matters.source_filename).filesystem_open_zpod, "w"); + foreach (source_pth_and_fn; filelist_src_zpod_arr) { + filelist.writeln(source_pth_and_fn); + } + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write((fn_src).readText); + zip_data.write((fn_src_in).readText); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); } } -} -{ /+ bundle insert files +/ +} { /+ bundle insert files +/ if (doc_matters.file_insert_list.length > 0) { foreach (insert_file; doc_matters.file_insert_list) { debug(sisupod) { writeln( insert_file, " -> ", - pth_sisupod.fn_doc_insert( + pths_sisupod.fn_doc_insert( doc_matters.source_filename, insert_file, - )); + ).zpod + ); } - auto fn_src = insert_file; - auto fn_out = pth_sisupod.fn_doc_insert( - doc_matters.source_filename, - insert_file, - ).to!string; - auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc_insert( - doc_matters.source_filename, - insert_file, - ).to!string; - if (exists(fn_src)) { + auto fn_src_in = insert_file; + auto fn_src_out_sisupod_zip_base = + pths_sisupod.fn_doc_insert( + doc_matters.source_filename, + insert_file, + ).zpod.to!string; + auto fn_src_out_filesystem = + pths_sisupod.fn_doc_insert( + doc_matters.source_filename, + insert_file, + ).filesystem_open_zpod.to!string; + if (exists(fn_src_in)) { if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write((fn_src).readText); + zip_data.write((fn_src_in).readText); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); createZipFile!()(fn_sisupod, zip.build()); @@ -212,10 +220,9 @@ auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename); } } } -} -{ - auto fn_src = doc_matters.source_filename; - if (exists(fn_src)) { +} { + auto fn_src_in = doc_matters.source_filename; + if (exists(fn_src_in)) { if (doc_matters.opt_action["sisupod"]) { createZipFile!()(fn_sisupod, zip.build()); } diff --git a/org/sdp.org b/org/sdp.org index 39d76f6..9cd57bc 100644 --- a/org/sdp.org +++ b/org/sdp.org @@ -316,6 +316,33 @@ foreach(arg; args[1..$]) { 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)) { + import std.file, + std.path; + string contents_location_; + try { + if (exists(arg)) { + contents_location_ = arg.readText; + } + } + catch (ErrnoException ex) { + } + catch (FileException ex) { + // Handle errors + } + auto contents_locations_arr = + (cast(char[]) contents_location_).split; + auto tmp_dir_ = (arg).dirName.array; + foreach (contents_location; contents_locations_arr) { + assert(contents_location.match(rgx.src_pth), + "not a recognised file: " ~ + contents_location + ); + auto contents_location_pth_ = (contents_location).to!string; + fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]); + } + } else if (arg.match(rgx.src_pth_zip)) { + // fns_src ~= arg; // gather input markup source file names for processing } else { // anything remaining, unused arg_unrecognized ~= " " ~ arg; } @@ -373,8 +400,9 @@ scope(failure) { } } enforce( - fn_src.match(rgx.src_pth), - "not a sisu markup filename" + fn_src.match(rgx.src_pth_types), + "not a sisu markup filename: <<" ~ + fn_src ~ ">>" ); #+END_SRC @@ -403,6 +431,7 @@ if (doc_matters.opt_action["verbose"]) { SiSUabstractionSummary!()(doc_abstraction, doc_matters); } #+END_SRC + **** 1. _debug_ (document parts, checkdoc) :debug:checkdoc: - [[./meta_output_debugs.org][meta_output_debugs]] diff --git a/src/sdp/meta/rgx.d b/src/sdp/meta/rgx.d index 90cf116..13b9e9f 100644 --- a/src/sdp/meta/rgx.d +++ b/src/sdp/meta/rgx.d @@ -197,6 +197,10 @@ static template SiSUrgxInit() { 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_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_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/paths_output.d b/src/sdp/output/paths_output.d index 2204965..a5ea0d9 100644 --- a/src/sdp/output/paths_output.d +++ b/src/sdp/output/paths_output.d @@ -10,131 +10,283 @@ import sdp.meta.rgx; template SiSUpathsSisupod() { mixin SiSUrgxInit; static auto rgx = Rgx(); - string _base_dir = "sisupod"; + string _base_dir_pod = "sisupod"; + string _base_dir_doc = "sisudoc"; string _suffix = ".zip"; auto SiSUpathsSisupod()() { struct _PathsStruct { string base_filename(string fn_src) { - return fn_src.baseName.stripExtension; + auto pth = fn_src.baseName.stripExtension; + return pth; } string sisupod_dir() { - return _base_dir; + auto pth = _base_dir_pod; + return pth; + } + string sisudoc_dir() { + auto pth = _base_dir_doc; + return pth; } string sisupod_filename(string fn_src) { - return _base_dir.chainPath(base_filename(fn_src) ~ _suffix).array; + string pth = _base_dir_pod.chainPath(base_filename(fn_src) ~ _suffix).array; + return pth; } - string base(string fn_src) { - return _base_dir.chainPath(base_filename(fn_src)).array; + string base_filesystem(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename(fn_src)).array; + assert(pth == _base_dir_pod ~ "/" ~ base_filename(fn_src), + pth ~ " == " ~ _base_dir_pod ~ "/" ~ base_filename(fn_src) ~ "?"); + return pth; + } + string base_pod(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename(fn_src)).array; // change this + return pth; } } return _PathsStruct(); } } -template SiSUpathsSisupodZipped() { + +template SiSUpathsSisupods() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsSisupodZipped(Ps,Lng)( + string _base_dir_pod = "sisupod"; + string _base_dir_doc = "sisudoc"; + string _suffix = ".zip"; + auto SiSUpathsSisupods(Ps,Lng)( Ps src_pth_info, Lng lng, ) { - struct _PathsStruct { - auto spod_pths = SiSUpathsSisupod!()(); - string sisupod_dir() { - return spod_pths.sisupod_dir; - } - string base_filename(string fn_src) { - return spod_pths.base_filename(fn_src); - } - string sisupod_filename(string fn_src) { - return spod_pths.sisupod_filename(fn_src); - } - string base(string fn_src) { - return spod_pths.base(fn_src); + struct _PodPaths { + string base_filename_(string fn_src) { + auto pth = fn_src.baseName.stripExtension; + return pth; + } + string sisupod_dir_() { + auto pth = _base_dir_pod; + return pth; + } + string sisudoc_dir_() { + auto pth = _base_dir_doc; + return pth; + } + string sisupod_filename_(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename_(fn_src) ~ _suffix).array; + return pth; + } + string base_filesystem_(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename_(fn_src)).array; + assert(pth == _base_dir_pod ~ "/" ~ base_filename_(fn_src), + pth ~ " == " ~ _base_dir_pod ~ "/" ~ base_filename_(fn_src) ~ "?"); + return pth; + } + string base_pod_(string fn_src) { + string pth = _base_dir_pod.chainPath(base_filename_(fn_src)).array; // change this + return pth; + } + auto base_filename(string fn_src) { + auto pth_1_ = base_filename_(fn_src); + auto pth_2_ = base_filename_(fn_src); + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); + } + auto sisupod_filename(string fn_src) { + auto pth_1_ = sisupod_filename_(fn_src); + auto pth_2_ = sisupod_filename_(fn_src); + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); + } + auto base(string fn_src) { + auto pth_1_ = ""; + auto pth_2_ = base_filesystem_(fn_src); + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); } auto pod_root(string fn_src) { - return "sisudoc"; - } - auto media_root(string fn_src) { - return pod_root(fn_src).chainPath("media").array; + auto pth_1_ = ""; + auto pth_2_ = base(fn_src).filesystem_open_zpod.chainPath("").array; // "sisudoc" + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + return pth_2_; + } + } + return _pods(); } auto conf_root(string fn_src) { - return pod_root(fn_src).chainPath("conf").array; - } - auto text_root(string fn_src) { - return media_root(fn_src).chainPath("text").array; - } - auto doc(string fn_src) { - return text_root(fn_src); - } - auto doc_lng(string fn_src) { - return text_root(fn_src).chainPath(lng).array; - } - auto image_root(string fn_src) { - return media_root(fn_src).chainPath("image").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = "conf"; + auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("conf").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto css(string fn_src) { - return conf_root(fn_src).chainPath("css").array; - } - auto fn_doc(string fn_src) { - return (doc_lng(fn_src)).chainPath(fn_src.baseName).array; - } - auto fn_doc_insert(string fn_src, string fn_insert) { - return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array; - } - } - return _PathsStruct(); - } -} -template SiSUpathsSisupodFileSystem() { - mixin SiSUrgxInit; - static auto rgx = Rgx(); - auto SiSUpathsSisupodFileSystem(Ps,Lng)( - Ps src_pth_info, - Lng lng, - ) { - struct _PathsStruct { - auto spod_pths = SiSUpathsSisupod!()(); - string base_filename(string fn_src) { - return spod_pths.base_filename(fn_src); - } - string sisupod_filename(string fn_src) { - return spod_pths.sisupod_filename(fn_src); - } - string base(string fn_src) { - return spod_pths.base(fn_src); - } - auto pod_root(string fn_src) { - return base(fn_src).chainPath("sisudoc").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = conf_root(fn_src).zpod.chainPath("css").array; + auto pth_2_ = conf_root(fn_src).filesystem_open_zpod.chainPath("css").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto media_root(string fn_src) { - return pod_root(fn_src).chainPath("media").array; - } - auto conf_root(string fn_src) { - return pod_root(fn_src).chainPath("conf").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = "media"; + auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("media").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto text_root(string fn_src) { - return media_root(fn_src).chainPath("text").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = media_root(fn_src).zpod.chainPath("text").array; + auto pth_2_ = media_root(fn_src).filesystem_open_zpod.chainPath("text").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto doc(string fn_src) { - return pod_root(fn_src); + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = text_root(fn_src).zpod; + auto pth_2_ = text_root(fn_src).filesystem_open_zpod; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto doc_lng(string fn_src) { - return text_root(fn_src).chainPath(lng).array; + 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; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto image_root(string fn_src) { - return media_root(fn_src).chainPath("image").array; - } - auto css(string fn_src) { - return conf_root(fn_src).chainPath("css").array; + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = media_root(fn_src).zpod.chainPath("image").array; + auto pth_2_ = media_root(fn_src).filesystem_open_zpod.chainPath("image").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); + } + auto fn_pod_filelist(string fn_src) { + auto pod_root_ = pod_root(fn_src); + auto pth_1_ = "sisudoc.txt"; + auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("sisudoc.txt").array; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto fn_doc(string fn_src) { - return (doc_lng(fn_src)).chainPath(fn_src.baseName).array; + 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; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } auto fn_doc_insert(string fn_src, string fn_insert) { - return (doc_lng(fn_src)).chainPath(fn_insert.baseName).array; + 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; + struct _pods { + auto zpod() { + return pth_1_; + } + auto filesystem_open_zpod() { + assert(pod_root_.filesystem_open_zpod.chainPath(zpod).array == pth_2_); + return pth_2_; + } + } + return _pods(); } } - return _PathsStruct(); + return _PodPaths(); } } template SiSUoutPaths() { diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index 343561b..1c0f4d3 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -16,6 +16,10 @@ 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_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_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 9c83905..d83ae87 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -19,137 +19,145 @@ template SiSUpod() { auto src_path_info = doc_matters.src_path_info; string lng = doc_matters.language; auto pth_sisudoc_src = doc_matters.src_path_info; - auto pth_sisupod = SiSUpathsSisupodZipped!()(src_path_info, lng); - auto pth_sisupod_filesystem = SiSUpathsSisupodFileSystem!()(src_path_info, lng); + auto pths_sisupod = SiSUpathsSisupods!()(src_path_info, lng); mixin SiSUlanguageCodes; auto lang = Lang(); static auto rgx = Rgx(); assert (doc_matters.source_filename.match(rgx.src_fn)); try { /+ create directory structure +/ - if (!exists(pth_sisupod.sisupod_dir)) { + if (!exists(pths_sisupod.sisupod_dir_())) { // used both by sisupod zipped (& sisupod filesystem (unzipped) which makes its own recursive dirs) - pth_sisupod.sisupod_dir.mkdirRecurse; + pths_sisupod.sisupod_dir_().mkdirRecurse; } if (doc_matters.opt_action["source"]) { - if (!exists(pth_sisupod_filesystem.text_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.text_root(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.text_root(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.text_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.conf_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.conf_root(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.conf_root(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.conf_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.media_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.media_root(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.media_root(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.media_root(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.css(doc_matters.source_filename))) { - pth_sisupod_filesystem.css(doc_matters.source_filename).mkdirRecurse; + if (!exists(pths_sisupod.css(doc_matters.source_filename).filesystem_open_zpod)) { + pths_sisupod.css(doc_matters.source_filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pth_sisupod_filesystem.image_root(doc_matters.source_filename))) { - pth_sisupod_filesystem.image_root(doc_matters.source_filename).mkdirRecurse; + 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(pth_sisupod_filesystem.doc_lng(doc_matters.source_filename))) { - pth_sisupod_filesystem.doc_lng(doc_matters.source_filename).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; } } debug(sisupod) { writeln(__LINE__, ": ", doc_matters.source_filename, " -> ", - pth_sisupod_filesystem.fn_doc(doc_matters.source_filename) + pths_sisupod.fn_doc(doc_matters.source_filename).filesystem_open_zpod ); } auto zip = new ZipArchive(); - auto fn_sisupod = pth_sisupod.sisupod_filename(doc_matters.source_filename); + auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.source_filename).zpod; { /+ bundle images +/ foreach (image; doc_matters.image_list) { debug(sisupodimages) { writeln( pth_sisudoc_src.image_root.to!string, "/", image, " -> ", - pth_sisupod.image_root(doc_matters.source_filename), "/", image + pths_sisupod.image_root(doc_matters.source_filename).zpod, "/", image ); } - auto fn_src = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; - auto fn_out = pth_sisupod.image_root(doc_matters.source_filename).to!string ~ "/" ~ image; - auto fn_out_filesystem = pth_sisupod_filesystem.image_root(doc_matters.source_filename).to!string ~ "/" ~ image; - if (exists(fn_src)) { + auto fn_src_in = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; + auto fn_src_out_sisupod_zip_base = pths_sisupod.image_root(doc_matters.source_filename).zpod.to!string ~ "/" ~ image; + auto fn_src_out_filesystem = pths_sisupod.image_root(doc_matters.source_filename).filesystem_open_zpod.to!string ~ "/" ~ image; + if (exists(fn_src_in)) { if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write(cast(char[]) ((fn_src).read)); + zip_data.write(cast(char[]) ((fn_src_in).read)); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); } } } - } - { /+ bundle sisu_document_make +/ - auto fn_src = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make) - auto fn_out = pth_sisupod.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make"; - auto fn_out_filesystem = pth_sisupod_filesystem.conf_root(doc_matters.source_filename).to!string ~ "/" ~ "sisu_document_make"; - if (exists(fn_src)) { + } { /+ bundle sisu_document_make +/ + auto fn_src_in = pth_sisudoc_src.conf_root.to!string ~ "/" ~ "sisu_document_make"; // check (_sisu/sisu_document_make) + auto fn_src_out_sisupod_zip_base = pths_sisupod.conf_root(doc_matters.source_filename).zpod.to!string ~ "/" ~ "sisu_document_make"; + auto fn_src_out_filesystem = pths_sisupod.conf_root(doc_matters.source_filename).filesystem_open_zpod.to!string ~ "/" ~ "sisu_document_make"; + if (exists(fn_src_in)) { if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write((fn_src).readText); + zip_data.write((fn_src_in).readText); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); } } - } - { /+ bundle primary file +/ - auto fn_src = doc_matters.source_filename; - auto fn_out = pth_sisupod.fn_doc(doc_matters.source_filename).to!string; - auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc(doc_matters.source_filename).to!string; - if (exists(fn_src)) { + } { /+ 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: + string[] filelist_src_out_sisupod_arr; + string[] filelist_src_zpod_arr; + if (exists(fn_src_in)) { + filelist_src_out_sisupod_arr ~= fn_src_out_sisupod_zip_base; + filelist_src_zpod_arr ~= fn_src_out_inside_pod; if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + auto filelist = File(pths_sisupod.fn_pod_filelist(doc_matters.source_filename).filesystem_open_zpod, "w"); + foreach (source_pth_and_fn; filelist_src_zpod_arr) { + filelist.writeln(source_pth_and_fn); + } + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write((fn_src).readText); + zip_data.write((fn_src_in).readText); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); } } - } - { /+ bundle insert files +/ + } { /+ bundle insert files +/ if (doc_matters.file_insert_list.length > 0) { foreach (insert_file; doc_matters.file_insert_list) { debug(sisupod) { writeln( insert_file, " -> ", - pth_sisupod.fn_doc_insert( + pths_sisupod.fn_doc_insert( doc_matters.source_filename, insert_file, - )); + ).zpod + ); } - auto fn_src = insert_file; - auto fn_out = pth_sisupod.fn_doc_insert( - doc_matters.source_filename, - insert_file, - ).to!string; - auto fn_out_filesystem = pth_sisupod_filesystem.fn_doc_insert( - doc_matters.source_filename, - insert_file, - ).to!string; - if (exists(fn_src)) { + auto fn_src_in = insert_file; + auto fn_src_out_sisupod_zip_base = + pths_sisupod.fn_doc_insert( + doc_matters.source_filename, + insert_file, + ).zpod.to!string; + auto fn_src_out_filesystem = + pths_sisupod.fn_doc_insert( + doc_matters.source_filename, + insert_file, + ).filesystem_open_zpod.to!string; + if (exists(fn_src_in)) { if (doc_matters.opt_action["source"]) { - fn_src.copy(fn_out_filesystem); + fn_src_in.copy(fn_src_out_filesystem); } if (doc_matters.opt_action["sisupod"]) { auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; + zip_arc_member_file.name = fn_src_out_sisupod_zip_base; auto zip_data = new OutBuffer(); - zip_data.write((fn_src).readText); + zip_data.write((fn_src_in).readText); zip_arc_member_file.expandedData = zip_data.toBytes(); zip.addMember(zip_arc_member_file); createZipFile!()(fn_sisupod, zip.build()); @@ -157,10 +165,9 @@ template SiSUpod() { } } } - } - { - auto fn_src = doc_matters.source_filename; - if (exists(fn_src)) { + } { + auto fn_src_in = doc_matters.source_filename; + if (exists(fn_src_in)) { if (doc_matters.opt_action["sisupod"]) { createZipFile!()(fn_sisupod, zip.build()); } diff --git a/src/sdp/sdp.d b/src/sdp/sdp.d index 0075de8..c861d1d 100755 --- a/src/sdp/sdp.d +++ b/src/sdp/sdp.d @@ -145,6 +145,33 @@ void main(string[] args) { 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)) { + import std.file, + std.path; + string contents_location_; + try { + if (exists(arg)) { + contents_location_ = arg.readText; + } + } + catch (ErrnoException ex) { + } + catch (FileException ex) { + // Handle errors + } + auto contents_locations_arr = + (cast(char[]) contents_location_).split; + auto tmp_dir_ = (arg).dirName.array; + foreach (contents_location; contents_locations_arr) { + assert(contents_location.match(rgx.src_pth), + "not a recognised file: " ~ + contents_location + ); + auto contents_location_pth_ = (contents_location).to!string; + fns_src ~= (((tmp_dir_).chainPath(contents_location_pth_)).array).to!(char[]); + } + } else if (arg.match(rgx.src_pth_zip)) { + // fns_src ~= arg; // gather input markup source file names for processing } else { // anything remaining, unused arg_unrecognized ~= " " ~ arg; } @@ -178,8 +205,9 @@ void main(string[] args) { } } enforce( - fn_src.match(rgx.src_pth), - "not a sisu markup filename" + fn_src.match(rgx.src_pth_types), + "not a sisu markup filename: <<" ~ + fn_src ~ ">>" ); auto t = SiSUabstraction!()(fn_src, opts, env); static assert(!isTypeTuple!(t)); |