diff options
author | Ralph Amissah <ralph@amissah.com> | 2018-01-25 17:13:52 -0500 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2019-04-10 15:14:14 -0400 |
commit | 524baa6ddd5f9cb49b1c5b015fbd6ef75ff72968 (patch) | |
tree | c66713d8559aa04f15f95825a6f5faec16827ce6 /src/sdp/output | |
parent | 0.23.3 work on source & target file paths/locations (diff) |
paths, further adjustmentsdoc-reform_v0.0.23
Diffstat (limited to 'src/sdp/output')
-rw-r--r-- | src/sdp/output/epub3.d | 14 | ||||
-rw-r--r-- | src/sdp/output/paths_output.d | 2 | ||||
-rw-r--r-- | src/sdp/output/paths_source.d | 67 | ||||
-rw-r--r-- | src/sdp/output/rgx.d | 1 | ||||
-rw-r--r-- | src/sdp/output/source_sisupod.d | 46 | ||||
-rw-r--r-- | src/sdp/output/sqlite.d | 30 | ||||
-rw-r--r-- | src/sdp/output/sqlite_discrete.d | 30 |
7 files changed, 118 insertions, 72 deletions
diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d index 3c8eb4d..131d6f9 100644 --- a/src/sdp/output/epub3.d +++ b/src/sdp/output/epub3.d @@ -84,7 +84,7 @@ template outputEPub3() { content ~= parts["manifest_documents"]; // TODO sort jpg & png content ~= " " ~ "<!-- Images -->" ~ "\n "; - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { content ~= format(q"¶ <item id="%s" href="%s/%s" media-type="image/%s" /> ¶", image.baseName.stripExtension, @@ -712,24 +712,24 @@ template outputEPub3() { createZipFile!()(fn_epub, zip.build()); } { /+ OEBPS/_sisu/image (images) +/ - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { debug(epub_output) { - if (exists(doc_matters.src.path_info.image_root ~ "/" ~ image)) { - (doc_matters.src.path_info.image_root ~ "/" ~ image) + if (exists(doc_matters.src_path_info.image_root ~ "/" ~ image)) { + (doc_matters.src_path_info.image_root ~ "/" ~ image) .copy((pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename)) ~ "/" ~ image); } } } - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { debug(epub_output) { debug(epub_images) { writeln( - doc_matters.src.path_info.image_root, image, " -> ", + doc_matters.src_path_info.image_root, image, " -> ", pth_epub3.dbg_doc_oebps_image(doc_matters.src.filename), "/", image ); } } - auto fn_src = doc_matters.src.path_info.image_root ~ image; + auto fn_src = doc_matters.src_path_info.image_root ~ image; auto fn_out = pth_epub3.doc_oebps_image(doc_matters.src.filename).to!string ~ "/" ~ image; if (exists(fn_src)) { { diff --git a/src/sdp/output/paths_output.d b/src/sdp/output/paths_output.d index 4a1c2e4..537de45 100644 --- a/src/sdp/output/paths_output.d +++ b/src/sdp/output/paths_output.d @@ -211,7 +211,7 @@ template SiSUpathsSQLite() { return fn_src.baseName.stripExtension; } string base() { - return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; + return asNormalizedPath((out_pth.output_root).chainPath(base_dir)).array; } string seg(string fn_src) { return asNormalizedPath(base.chainPath(base_filename(fn_src))).array; diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index d141b86..731fff3 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -24,19 +24,30 @@ template PodManifest() { } auto pod_manifest_path() { string _manifest_path; - if (isValidPath(_pth) && _pth.isDir - && ((_pth.chainPath(pod_manifest_filename).array).isFile)) { + if ((isValidPath(_pth) && exists(_pth)!=0 && _pth.isDir) + && (exists(_pth.chainPath(pod_manifest_filename).array)!=0 + && (_pth.chainPath(pod_manifest_filename).array).isFile)) { _manifest_path = _pth; } else if (_pth.match(rgx.src_pth_contents) - && (_pth.isFile)) { + && exists(_pth)!=0 && _pth.isDir && (_pth.isFile)) { _manifest_path = dirName(_pth); - // } else { // _manifest_path = ""; + } else { + _manifest_path = _pth; // _manifest_path = null; } return _manifest_path; } - auto pod_manifest_file_with_path() { - string _manifest_path_and_file = pod_manifest_path.chainPath(pod_manifest_filename).array; - return _manifest_path_and_file; + string pod_manifest_file_with_path() { + string _k; + if (exists(pod_manifest_path.chainPath(pod_manifest_filename).array)!=0) { + _k = pod_manifest_path.chainPath(pod_manifest_filename).array; + } else if (exists(pod_manifest_path)!=0) { + _k = pod_manifest_path; + } + if (exists(_k)==0) { + writeln("ERROR >> Processing Skipped! Manifest not found: ", _k); + _k = null; + } + return _k; } } return ManifestFile_(); @@ -139,6 +150,9 @@ template PathMatters() { } return _k; } + auto language() { + return lng(); + } auto file_with_absolute_path() { string _pth = _env["pwd"].chainPath(path_and_fn).array; return _pth; @@ -153,13 +167,15 @@ template PathMatters() { auto m = (absolute_path_to_src) .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) ) { - _dir = asAbsolutePath(path_and_fn.chainPath("../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../")).array; assert(_dir == m.captures["dir"]); } else { - _dir = asAbsolutePath(path_and_fn.chainPath("../../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../../")).array; assert(_dir == absolute_path_to_src.match(rgx.src_base_parent_dir_name).captures["dir"]); } - writeln("--> ", _dir); + if ((_opt_actions.debug_do)) { + writeln("--> (base_dir) ", _dir); + } return _dir; } auto base_parent_dir_path() { @@ -168,35 +184,42 @@ template PathMatters() { auto m = (absolute_path_to_src) .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) ) { - _dir = asAbsolutePath(path_and_fn.chainPath("../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../")).array; } else { - _dir = asAbsolutePath(path_and_fn.chainPath("../../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../../")).array; } return _dir; } auto base_dir_path() { // looks like there is work to do string _dir; - if ( // TODO this should catch generated --source sisupod, untested, needs manifest + if ( auto m = (absolute_path_to_src) - .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) + .match(rgx.src_formalised_file_path_parts) + ) { + _dir = asNormalizedPath(m.captures["pth"]).array; + } else if ( // TODO this should catch generated --source sisupod, untested, needs manifest + auto m = (absolute_path_to_src) + .match(regex(r"[/](?P<dir>(?:[a-zA-Z0-9._-]+))/sisupod/" ~ filename.stripExtension)) ) { - _dir = asAbsolutePath(path_and_fn.chainPath("../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../")).array; } else { - _dir = asAbsolutePath(path_and_fn.chainPath("../../")).array; + _dir = asNormalizedPath(path_and_fn.chainPath("../../")).array; + } + if ((_opt_actions.debug_do)) { + writeln("--> (base_dir_path) ", _dir); } - writeln("--> ", _dir); return _dir; } auto media_dir_path() { // TODO rework, can base directly on src fn path - auto _dir = asAbsolutePath(base_dir_path.chainPath("media")).array; + string _dir = asNormalizedPath(base_dir_path.chainPath("media")).array; return _dir; } auto image_dir_path() { - auto _dir = asAbsolutePath(base_dir_path.chainPath("media/image")).array; + string _dir = asNormalizedPath(base_dir_path.chainPath("media/image")).array; return _dir; } auto conf_dir_path() { - auto _dir = asAbsolutePath(base_dir_path.chainPath("conf")).array; + auto _dir = asNormalizedPath(base_dir_path.chainPath("conf")).array; return _dir; } auto base_parent_dir() { @@ -209,7 +232,9 @@ template PathMatters() { } else { _dir = (absolute_path_to_src).match(rgx.src_base_parent_dir_name).captures["dir"]; } - writeln("--> ", _dir); + if ((_opt_actions.debug_do)) { + writeln("--> (base_parent_dir) ", _dir); + } return _dir; } auto config_dirs() { // TODO diff --git a/src/sdp/output/rgx.d b/src/sdp/output/rgx.d index 1c32351..c962937 100644 --- a/src/sdp/output/rgx.d +++ b/src/sdp/output/rgx.d @@ -31,6 +31,7 @@ static template SiSUoutputRgxInit() { static src_fn_find_inserts = ctRegex!(`^(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[im])$`); static insert_src_fn_ssi_or_sst = ctRegex!(`^<<\s*(?P<path>[a-zA-Z0-9._-]+/)*(?P<filename>[a-zA-Z0-9._-]+[.]ss[ti])$`); static src_base_parent_dir_name = ctRegex!(`[/](?P<dir>(?:[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalizes dir structure + static src_formalised_file_path_parts = ctRegex!(`(?P<pth>(?:[/a-zA-Z0-9._-]+?)(?P<dir>[a-zA-Z0-9._-]+))(?:/media/text/[a-z]{2})$`); // formalized dir structure /+ inline markup footnotes endnotes +/ static inline_notes_al = ctRegex!(`【(?:[*+]\s+|\s*)(.+?)】`, "mg"); static inline_notes_al_gen = ctRegex!(`【.+?】`, "m"); diff --git a/src/sdp/output/source_sisupod.d b/src/sdp/output/source_sisupod.d index c48a0e3..4e3bfc1 100644 --- a/src/sdp/output/source_sisupod.d +++ b/src/sdp/output/source_sisupod.d @@ -16,8 +16,8 @@ template SiSUpod() { } mixin SiSUoutputRgxInit; string pwd = doc_matters.env.pwd; - auto src_path_info = doc_matters.src.path_info; - auto pth_sisudoc_src = doc_matters.src.path_info; + auto src_path_info = doc_matters.src_path_info; + auto pth_sisudoc_src = doc_matters.src_path_info; auto pths_sisupod = SiSUpathsSisupods!()(doc_matters); mixin SiSUlanguageCodes; auto lang = Lang(); @@ -58,14 +58,17 @@ template SiSUpod() { auto zip = new ZipArchive(); auto fn_sisupod = pths_sisupod.sisupod_filename(doc_matters.src.filename).zpod; { /+ bundle images +/ - foreach (image; doc_matters.src.image_list) { + foreach (image; doc_matters.srcs.image_list) { debug(sisupodimages) { writeln( pth_sisudoc_src.image_root.to!string, "/", image, " -> ", pths_sisupod.image_root(doc_matters.src.filename).zpod, "/", image ); } - auto fn_src_in = pth_sisudoc_src.image_root.to!string ~ "/" ~ image; + auto fn_src_in = ((doc_matters.src.is_pod) + ? doc_matters.src.image_dir_path + : pth_sisudoc_src.image_root).to!string + ~ "/" ~ image; auto fn_src_out_sisupod_zip_base = pths_sisupod.image_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ image; @@ -74,7 +77,7 @@ template SiSUpod() { ~ "/" ~ image; if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } if (doc_matters.opt.action.source) { fn_src_in.copy(fn_src_out_filesystem); @@ -89,13 +92,15 @@ template SiSUpod() { } } else { if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (image): ", fn_src_in); + writeln("WARNING (io) src out NOT found (image): ", fn_src_in); } } } } { /+ 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_in = ((doc_matters.src.is_pod) + ? doc_matters.src.conf_dir_path + : pth_sisudoc_src.conf_root).to!string + ~ "/" ~ "sisu_document_make"; auto fn_src_out_sisupod_zip_base = pths_sisupod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "sisu_document_make"; auto fn_src_out_filesystem @@ -103,7 +108,7 @@ template SiSUpod() { ~ "/" ~ "sisu_document_make"; // TODO if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } if (doc_matters.opt.action.source) { fn_src_in.copy(fn_src_out_filesystem); @@ -117,8 +122,9 @@ template SiSUpod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (document make): ", fn_src_in); + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); } } } { /+ TODO bundle primary file +/ @@ -133,7 +139,7 @@ template SiSUpod() { string[] filelist_src_zpod_arr; if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } filelist_src_out_sisupod_arr ~= fn_src_out_sisupod_zip_base; filelist_src_zpod_arr ~= fn_src_out_inside_pod; @@ -154,13 +160,14 @@ template SiSUpod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (markup source): ", fn_src_in); + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (markup source): ", fn_src_in); } } } { /+ bundle insert files +/ - if (doc_matters.src.file_insert_list.length > 0) { - foreach (insert_file; doc_matters.src.file_insert_list) { + if (doc_matters.srcs.file_insert_list.length > 0) { + foreach (insert_file; doc_matters.srcs.file_insert_list) { debug(sisupod) { writeln( insert_file, " -> ", @@ -186,7 +193,7 @@ template SiSUpod() { ).filesystem_open_zpod.to!string; if (exists(fn_src_in)) { debug(io) { - writeln("src out found: ", fn_src_in); + writeln("WARNING (io debug) src out found: ", fn_src_in); } if (doc_matters.opt.action.source) { fn_src_in.copy(fn_src_out_filesystem); @@ -201,8 +208,9 @@ template SiSUpod() { createZipFile!()(fn_sisupod, zip.build()); } } else { - if (doc_matters.opt.action.verbose) { - writeln("src out NOT found (insert file): ", fn_src_in); + if (doc_matters.opt.action.verbose + || doc_matters.opt.action.debug_do) { + writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); } } } diff --git a/src/sdp/output/sqlite.d b/src/sdp/output/sqlite.d index 4abe3d1..25940cc 100644 --- a/src/sdp/output/sqlite.d +++ b/src/sdp/output/sqlite.d @@ -457,6 +457,7 @@ template SQLiteBuildTablesAndPopulate() { auto ref I doc_matters, ) { auto pth_sqlite = SiSUpathsSQLite!()(doc_matters.output_path, doc_matters.src.language); + pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file(doc_matters.env.pwd.baseName)); // auto db = Database(":memory:"); // open database in memory if (doc_matters.opt.action.sqlite_create) { @@ -816,7 +817,10 @@ template SQLiteBuildTablesAndPopulate() { // insert_metadata.bind(":links", doc_matters.conf_make_meta.meta.links); insert_metadata.execute(); insert_metadata.reset(); /+ watch +/ - writeln("sql statement executed"); + writeln(" ", pth_sqlite.sqlite_file(doc_matters.env.pwd.baseName)); + if ((doc_matters.opt.action.verbose)) { + writeln("sql statement executed"); + } assert(db.totalChanges == 1); // Statement insert_doc_objects = db.prepare(" @@ -1030,17 +1034,19 @@ template SQLiteBuildTablesAndPopulate() { break; } if (obj.is_a == "heading") { - writeln( - "markup: ", obj.heading_lev_markup, - "> ", obj.dom_markedup, - "; collapsed: ", obj.heading_lev_collapsed, - "> ", obj.dom_collapsed, - "; ocn: ", obj.ocn, - " node: ", obj.node, - "; parent: ", obj.parent_lev_markup, - "; ocn: ", obj.parent_ocn, - "; ", - ); + if ((doc_matters.opt.action.verbose)) { + writeln( + "markup: ", obj.heading_lev_markup, + "> ", obj.dom_markedup, + "; collapsed: ", obj.heading_lev_collapsed, + "> ", obj.dom_collapsed, + "; ocn: ", obj.ocn, + " node: ", obj.node, + "; parent: ", obj.parent_lev_markup, + "; ocn: ", obj.parent_ocn, + "; ", + ); + } } insert_doc_objects.bind(":t_of", obj.is_of); insert_doc_objects.bind(":t_is", obj.is_a); diff --git a/src/sdp/output/sqlite_discrete.d b/src/sdp/output/sqlite_discrete.d index 0c323d1..b256389 100644 --- a/src/sdp/output/sqlite_discrete.d +++ b/src/sdp/output/sqlite_discrete.d @@ -457,6 +457,7 @@ template SQLiteDiscreteBuildTablesAndPopulate() { auto ref I doc_matters, ) { auto pth_sqlite = SiSUpathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.src.language); + pth_sqlite.base.mkdirRecurse; auto db = Database(pth_sqlite.sqlite_file(doc_matters.src.filename)); // auto db = Database(":memory:"); // open database in memory db.run(" @@ -813,7 +814,10 @@ template SQLiteDiscreteBuildTablesAndPopulate() { // insert_metadata.bind(":links", doc_matters.conf_make_meta.meta.links); insert_metadata.execute(); insert_metadata.reset(); /+ watch +/ - writeln("sql statement executed"); + writeln(" ", pth_sqlite.sqlite_file(doc_matters.src.filename)); + if ((doc_matters.opt.action.verbose)) { + writeln("sql statement executed"); + } assert(db.totalChanges == 1); // Statement insert_doc_objects = db.prepare(" @@ -1027,17 +1031,19 @@ template SQLiteDiscreteBuildTablesAndPopulate() { break; } if (obj.is_a == "heading") { - writeln( - "markup: ", obj.heading_lev_markup, - "> ", obj.dom_markedup, - "; collapsed: ", obj.heading_lev_collapsed, - "> ", obj.dom_collapsed, - "; ocn: ", obj.ocn, - " node: ", obj.node, - "; parent: ", obj.parent_lev_markup, - "; ocn: ", obj.parent_ocn, - "; ", - ); + if ((doc_matters.opt.action.verbose)) { + writeln( + "markup: ", obj.heading_lev_markup, + "> ", obj.dom_markedup, + "; collapsed: ", obj.heading_lev_collapsed, + "> ", obj.dom_collapsed, + "; ocn: ", obj.ocn, + " node: ", obj.node, + "; parent: ", obj.parent_lev_markup, + "; ocn: ", obj.parent_ocn, + "; ", + ); + } } insert_doc_objects.bind(":t_of", obj.is_of); insert_doc_objects.bind(":t_is", obj.is_a); |