aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output/source_sisupod.d
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-11-08 20:02:48 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit1d68345250b0fd26d3ea657ed28899dccaa324df (patch)
treea94ad71bfc5d081c15fd253f6bcc7a694141cd7f /src/sdp/output/source_sisupod.d
parent0.20.0 sisupod & source dir structure changed (diff)
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
Diffstat (limited to 'src/sdp/output/source_sisupod.d')
-rw-r--r--src/sdp/output/source_sisupod.d137
1 files changed, 72 insertions, 65 deletions
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());
}