From 1d68345250b0fd26d3ea657ed28899dccaa324df Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 8 Nov 2017 20:02:48 -0500 Subject: process filesystem/unzipped sisupod.zip - src pod dir structure changes - notes - 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) process filesystem/unzipped sisupod.zip - source/sisupod path/dir structure representation changes --- org/output_sisupod.org | 137 ++++++++++++++++++++++++++----------------------- 1 file changed, 72 insertions(+), 65 deletions(-) (limited to 'org/output_sisupod.org') 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()); } -- cgit v1.2.3