From 1dbbdec89acdb2ef12cdfc0572997c4c4652466b Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 4 Dec 2017 01:54:58 -0500 Subject: 0.23.1 use output path specified if any --- src/sdp/output/epub3.d | 8 ++-- src/sdp/output/html.d | 17 +++----- src/sdp/output/paths_output.d | 92 +++++++++++++++++++++------------------- src/sdp/output/paths_source.d | 46 ++++++++++---------- src/sdp/output/sqlite.d | 2 +- src/sdp/output/sqlite_discrete.d | 2 +- 6 files changed, 83 insertions(+), 84 deletions(-) (limited to 'src') diff --git a/src/sdp/output/epub3.d b/src/sdp/output/epub3.d index e31d114..2641784 100644 --- a/src/sdp/output/epub3.d +++ b/src/sdp/output/epub3.d @@ -31,7 +31,7 @@ template outputEPub3() { } string epub3_oebps_content(D,I,P)(D doc_abstraction, I doc_matters, P parts) { auto xhtml_format = outputXHTMLs(); - auto pth_epub3 = SiSUpathsEPUB!()(doc_matters.src_path_info, doc_matters.language); + auto pth_epub3 = SiSUpathsEPUB!()(doc_matters.output_path, doc_matters.language); string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! string content = format(q"ΒΆ @@ -591,9 +591,7 @@ template outputEPub3() { static assert(is(typeof(oebps_toc_ncx) == string)); static assert(is(typeof(oebps_content_opf) == string)); } - auto src_path_info = doc_matters.src_path_info; - string lng = doc_matters.language; - auto pth_epub3 = SiSUpathsEPUB!()(src_path_info, lng); + auto pth_epub3 = SiSUpathsEPUB!()(doc_matters.output_path, doc_matters.language); auto xhtml_format = outputXHTMLs(); /+ zip file +/ auto fn_epub = pth_epub3.epub_file(doc_matters.source_filename); @@ -765,7 +763,7 @@ template outputEPub3() { catch (ErrnoException ex) { // Handle error } - writeln(" ", doc_matters.environment.pwd, "/", fn_epub); + writeln(" ", fn_epub); debug(epub_archive) { if (exists(fn_epub)) { try { diff --git a/src/sdp/output/html.d b/src/sdp/output/html.d index a422a81..6767e11 100644 --- a/src/sdp/output/html.d +++ b/src/sdp/output/html.d @@ -165,15 +165,12 @@ template outputHTML() { debug(asserts) { static assert(is(typeof(doc) == string[])); } - string fn_src = doc_matters.source_filename; - auto src_path_info = doc_matters.src_path_info; - string lng = doc_matters.language; - auto pth_html = SiSUpathsHTML!()(src_path_info, lng); + auto pth_html = SiSUpathsHTML!()(doc_matters.output_path, doc_matters.language); try { if (!exists(pth_html.base)) { pth_html.base.mkdirRecurse; } - auto f = File(pth_html.fn_scroll(fn_src), "w"); + auto f = File(pth_html.fn_scroll(doc_matters.source_filename), "w"); foreach (o; doc) { f.writeln(o); } @@ -181,7 +178,7 @@ template outputHTML() { catch (ErrnoException ex) { // Handle error } - writeln(" ", doc_matters.environment.pwd, "/", pth_html.fn_scroll(fn_src)); + writeln(" ", pth_html.fn_scroll(doc_matters.source_filename)); } void seg(D,I)( auto return ref const D doc_abstraction, @@ -417,9 +414,7 @@ template outputHTML() { } mixin SiSUoutputRgxInit; auto rgx = Rgx(); - auto src_path_info = doc_matters.src_path_info; - string lng = doc_matters.language; - auto pth_html = SiSUpathsHTML!()(src_path_info, lng); + auto pth_html = SiSUpathsHTML!()(doc_matters.output_path, doc_matters.language); auto xhtml_format = outputXHTMLs(); auto m = doc_matters.source_filename.matchFirst(rgx.src_fn); try { @@ -440,13 +435,13 @@ template outputHTML() { catch (ErrnoException ex) { // handle error } - writeln(" ", doc_matters.environment.pwd, "/", pth_html.fn_seg(doc_matters.source_filename, "toc")); + writeln(" ", pth_html.fn_seg(doc_matters.source_filename, "toc")); } void css(M)( auto return ref M doc_matters, ) { auto css = SiSUcss(); - auto pth_html = SiSUpathsHTML!()(doc_matters.src_path_info, doc_matters.language); + auto pth_html = SiSUpathsHTML!()(doc_matters.output_path, doc_matters.language); try { if (!exists(pth_html.css)) { (pth_html.css).mkdirRecurse; diff --git a/src/sdp/output/paths_output.d b/src/sdp/output/paths_output.d index accfcaf..4a1c2e4 100644 --- a/src/sdp/output/paths_output.d +++ b/src/sdp/output/paths_output.d @@ -8,16 +8,22 @@ import std.array, std.stdio; import sdp.meta.rgx; template SiSUoutPaths() { - auto SiSUoutPaths(Ps,Lng)( - Ps src_pth_info, + auto SiSUoutPaths(Po,Lng)( + Po output_pth_root, Lng lng, ) { struct _PathsStruct { string output_root() { - return "sisugen"; + string out_root_; + if (output_pth_root.length > 0) { + out_root_ = output_pth_root; + } else { + out_root_ = "sisugen"; + } + return out_root_; } string output_base() { - return output_root.chainPath(lng).array; + return asNormalizedPath(output_root.chainPath(lng)).array; } } return _PathsStruct(); @@ -26,11 +32,11 @@ template SiSUoutPaths() { template SiSUpathsHTML() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsHTML(Ps,Lng)( - Ps src_pth_info, + auto SiSUpathsHTML(Po,Lng)( + Po output_pth_root, Lng lng, ) { - auto out_pth = SiSUoutPaths!()(src_pth_info, lng); + auto out_pth = SiSUoutPaths!()(output_pth_root, lng); string base_dir = "html"; string suffix = ".html"; struct _PathsStruct { @@ -38,28 +44,28 @@ template SiSUpathsHTML() { return fn_src.baseName.stripExtension; } string base() { - return (out_pth.output_base).chainPath(base_dir).array; + return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; } string image() { - return (out_pth.output_root).chainPath("image").array; + return asNormalizedPath((out_pth.output_root).chainPath("image")).array; } string css() { - return (out_pth.output_root).chainPath("css").array; + return asNormalizedPath((out_pth.output_root).chainPath("css")).array; } string fn_seg_css() { - return css.chainPath("html_seg.css").array; + return asNormalizedPath(css.chainPath("html_seg.css")).array; } string fn_scroll_css() { - return css.chainPath("html_scroll.css").array; + return asNormalizedPath(css.chainPath("html_scroll.css")).array; } string seg(string fn_src) { - return base.chainPath(base_filename(fn_src)).array; + return asNormalizedPath(base.chainPath(base_filename(fn_src))).array; } string fn_scroll(string fn_src) { - return base.chainPath(base_filename(fn_src) ~ suffix).array; + return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ suffix)).array; } string fn_seg(string fn_src, string seg_filename) { - return seg(fn_src).chainPath(seg_filename ~ suffix).array; + return asNormalizedPath(seg(fn_src).chainPath(seg_filename ~ suffix)).array; } } return _PathsStruct(); @@ -68,57 +74,57 @@ template SiSUpathsHTML() { template SiSUpathsEPUB() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsEPUB(Ps,Lng)( - Ps src_pth_info, + auto SiSUpathsEPUB(Po,Lng)( + Po output_pth_root, Lng lng, ) { - auto out_pth = SiSUoutPaths!()(src_pth_info, lng); + auto out_pth = SiSUoutPaths!()( output_pth_root, lng); string base_dir = "epub"; struct _PathsStruct { string base() { - return (out_pth.output_base).chainPath(base_dir).array; + return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; } string base_filename(string fn_src) { return fn_src.baseName.stripExtension; } string epub_file(string fn_src) { - return base.chainPath(base_filename(fn_src) ~ ".epub").array; + return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ ".epub")).array; } string dirtop() { return "".chainPath("").array; } string doc_meta_inf(string fn_src) { - return dirtop.chainPath("META-INF").array; + return asNormalizedPath(dirtop.chainPath("META-INF")).array; } string doc_oebps(string fn_src) { - return dirtop.chainPath("OEBPS").array; + return asNormalizedPath(dirtop.chainPath("OEBPS")).array; } string doc_oebps_css(string fn_src) { - return doc_oebps(fn_src).chainPath("css").array; + return asNormalizedPath(doc_oebps(fn_src).chainPath("css")).array; } string doc_oebps_image(string fn_src) { - return doc_oebps(fn_src).chainPath("image").array; + return asNormalizedPath(doc_oebps(fn_src).chainPath("image")).array; } string fn_mimetypes(string fn_src) { - return dirtop.chainPath("mimetypes").array; + return asNormalizedPath(dirtop.chainPath("mimetypes")).array; } string fn_dmi_container_xml(string fn_src) { - return doc_meta_inf(fn_src).chainPath("container.xml").array; + return asNormalizedPath(doc_meta_inf(fn_src).chainPath("container.xml")).array; } string fn_oebps_toc_nav_xhtml(string fn_src) { - return doc_oebps(fn_src).chainPath("toc_nav.xhtml").array; + return asNormalizedPath(doc_oebps(fn_src).chainPath("toc_nav.xhtml")).array; } string fn_oebps_toc_ncx(string fn_src) { - return doc_oebps(fn_src).chainPath("toc.ncx").array; + return asNormalizedPath(doc_oebps(fn_src).chainPath("toc.ncx")).array; } string fn_oebps_content_opf(string fn_src) { - return doc_oebps(fn_src).chainPath("content.opf").array; + return asNormalizedPath(doc_oebps(fn_src).chainPath("content.opf")).array; } string fn_oebps_content_xhtml(string fn_src, string seg_filename) { - return doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array; + return asNormalizedPath(doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml")).array; } string fn_oebps_css(string fn_src) { - return doc_oebps_css(fn_src).chainPath("epub.css").array; + return asNormalizedPath(doc_oebps_css(fn_src).chainPath("epub.css")).array; } debug(epub_output) { string dbg_docdir(string fn_src) { @@ -168,24 +174,24 @@ template SiSUpathsEPUB() { template SiSUpathsSQLiteDiscrete() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsSQLiteDiscrete(Ps,Lng)( - Ps src_pth_info, + auto SiSUpathsSQLiteDiscrete(Po,Lng)( + Po output_pth_root, Lng lng, ) { - auto out_pth = SiSUoutPaths!()(src_pth_info, lng); + auto out_pth = SiSUoutPaths!()(output_pth_root, lng); string base_dir = "sqlite"; struct _PathsStruct { string base_filename(string fn_src) { return fn_src.baseName.stripExtension; } string base() { - return (out_pth.output_base).chainPath(base_dir).array; + return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; } string seg(string fn_src) { - return base.chainPath(base_filename(fn_src)).array; + return asNormalizedPath(base.chainPath(base_filename(fn_src))).array; } string sqlite_file(string fn_src) { - return base.chainPath(base_filename(fn_src) ~ ".sqlite").array; + return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ ".sqlite")).array; } } return _PathsStruct(); @@ -194,24 +200,24 @@ template SiSUpathsSQLiteDiscrete() { template SiSUpathsSQLite() { mixin SiSUrgxInit; static auto rgx = Rgx(); - auto SiSUpathsSQLite(Ps,Lng)( - Ps src_pth_info, + auto SiSUpathsSQLite(Po,Lng)( + Po output_pth_root, Lng lng, ) { - auto out_pth = SiSUoutPaths!()(src_pth_info, lng); + auto out_pth = SiSUoutPaths!()(output_pth_root, lng); string base_dir = "sqlite"; struct _PathsStruct { string base_filename(string fn_src) { return fn_src.baseName.stripExtension; } string base() { - return (out_pth.output_base).chainPath(base_dir).array; + return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array; } string seg(string fn_src) { - return base.chainPath(base_filename(fn_src)).array; + return asNormalizedPath(base.chainPath(base_filename(fn_src))).array; } string sqlite_file(string fn_src) { - return base.chainPath(base_filename(fn_src) ~ ".sqlite").array; + return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ ".sqlite")).array; } } return _PathsStruct(); diff --git a/src/sdp/output/paths_source.d b/src/sdp/output/paths_source.d index 967a632..0a8b447 100644 --- a/src/sdp/output/paths_source.d +++ b/src/sdp/output/paths_source.d @@ -203,25 +203,25 @@ template SiSUpathsSRC() { return "sisudoc"; } auto media_root() { - return doc_root.chainPath("media").array; + return asNormalizedPath(doc_root.chainPath("media")).array; } auto conf_root() { - return doc_root.chainPath("conf").array; + return asNormalizedPath(doc_root.chainPath("conf")).array; } auto text_root() { - return media_root.chainPath("text").array; + return asNormalizedPath(media_root.chainPath("text")).array; } auto image_root() { - return media_root.chainPath("image").array; + return asNormalizedPath(media_root.chainPath("image")).array; } auto doc_src_fn_with_path_for_text_root_and_lng() { - return text_root.chainPath(language).array; + return asNormalizedPath(text_root.chainPath(language)).array; } auto doc_src_with_relative_path() { - return pwd.chainPath(_fn_src_and_relative_path).array; + return asNormalizedPath(pwd.chainPath(_fn_src_and_relative_path)).array; } auto doc_src_fn() { - return _fn_src_and_relative_path.baseName.array; + return asNormalizedPath(_fn_src_and_relative_path.baseName).array; } } return SisuSrcPaths(); @@ -341,7 +341,7 @@ template SiSUpathsSisupods() { } auto pod_root(string fn_src) { auto pth_1_ = ""; - auto pth_2_ = base(fn_src).filesystem_open_zpod.chainPath("").array; // "sisudoc" + auto pth_2_ = asNormalizedPath(base(fn_src).filesystem_open_zpod.chainPath("")).array; // "sisudoc" struct _pods { auto zpod() { return pth_1_; @@ -355,7 +355,7 @@ template SiSUpathsSisupods() { auto conf_root(string fn_src) { auto pod_root_ = pod_root(fn_src); auto pth_1_ = "conf"; - auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("conf").array; + auto pth_2_ = asNormalizedPath(pod_root(fn_src).filesystem_open_zpod.chainPath("conf")).array; struct _pods { auto zpod() { return pth_1_; @@ -369,8 +369,8 @@ template SiSUpathsSisupods() { } auto css(string fn_src) { 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; + auto pth_1_ = asNormalizedPath(conf_root(fn_src).zpod.chainPath("css")).array; + auto pth_2_ = asNormalizedPath(conf_root(fn_src).filesystem_open_zpod.chainPath("css")).array; struct _pods { auto zpod() { return pth_1_; @@ -385,7 +385,7 @@ template SiSUpathsSisupods() { auto media_root(string fn_src) { auto pod_root_ = pod_root(fn_src); auto pth_1_ = "media"; - auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath("media").array; + auto pth_2_ = asNormalizedPath(pod_root(fn_src).filesystem_open_zpod.chainPath("media")).array; struct _pods { auto zpod() { return pth_1_; @@ -399,8 +399,8 @@ template SiSUpathsSisupods() { } auto text_root(string fn_src) { 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; + auto pth_1_ = asNormalizedPath(media_root(fn_src).zpod.chainPath("text")).array; + auto pth_2_ = asNormalizedPath(media_root(fn_src).filesystem_open_zpod.chainPath("text")).array; struct _pods { auto zpod() { return pth_1_; @@ -429,8 +429,8 @@ template SiSUpathsSisupods() { } 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; + auto pth_1_ = asNormalizedPath(text_root(fn_src).zpod.chainPath(lng)).array; + auto pth_2_ = asNormalizedPath(text_root(fn_src).filesystem_open_zpod.chainPath(lng)).array; struct _pods { auto zpod() { return pth_1_; @@ -444,8 +444,8 @@ template SiSUpathsSisupods() { } auto image_root(string fn_src) { 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; + auto pth_1_ = asNormalizedPath(media_root(fn_src).zpod.chainPath("image")).array; + auto pth_2_ = asNormalizedPath(media_root(fn_src).filesystem_open_zpod.chainPath("image")).array; struct _pods { auto zpod() { return pth_1_; @@ -461,7 +461,7 @@ template SiSUpathsSisupods() { auto pod_root_ = pod_root(fn_src); auto _manifest = PodManifest!()(fn_src).pod_manifest_filename; auto pth_1_ = _manifest; - auto pth_2_ = pod_root(fn_src).filesystem_open_zpod.chainPath(_manifest).array; + auto pth_2_ = asNormalizedPath(pod_root(fn_src).filesystem_open_zpod.chainPath(_manifest)).array; struct _pods { auto zpod() { return pth_1_; @@ -475,8 +475,8 @@ template SiSUpathsSisupods() { } auto fn_doc(string fn_src, string lng) { auto pod_root_ = pod_root(fn_src); - 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; + auto pth_1_ = asNormalizedPath(doc_lng(fn_src, lng).zpod.chainPath(fn_src.baseName)).array; + auto pth_2_ = asNormalizedPath(doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_src.baseName)).array; struct _pods { auto zpod() { return pth_1_; @@ -490,8 +490,8 @@ template SiSUpathsSisupods() { } 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, lng).zpod.chainPath(fn_insert.baseName).array; - auto pth_2_ = doc_lng(fn_src, lng).filesystem_open_zpod.chainPath(fn_insert.baseName).array; + auto pth_1_ = asNormalizedPath(doc_lng(fn_src, lng).zpod.chainPath(fn_insert.baseName)).array; + auto pth_2_ = asNormalizedPath(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/sqlite.d b/src/sdp/output/sqlite.d index ee44d8a..5804da7 100644 --- a/src/sdp/output/sqlite.d +++ b/src/sdp/output/sqlite.d @@ -456,7 +456,7 @@ template SQLiteBuildTablesAndPopulate() { Statement SQLiteInstruct(I)( auto ref I doc_matters, ) { - auto pth_sqlite = SiSUpathsSQLite!()(doc_matters.src_path_info, doc_matters.language); + auto pth_sqlite = SiSUpathsSQLite!()(doc_matters.output_path, doc_matters.language); auto db = Database(pth_sqlite.sqlite_file(doc_matters.environment.pwd.baseName)); // auto db = Database(":memory:"); // open database in memory if (doc_matters.opt_action.sqlite_create) { diff --git a/src/sdp/output/sqlite_discrete.d b/src/sdp/output/sqlite_discrete.d index 7415f4c..f97692f 100644 --- a/src/sdp/output/sqlite_discrete.d +++ b/src/sdp/output/sqlite_discrete.d @@ -456,7 +456,7 @@ template SQLiteDiscreteBuildTablesAndPopulate() { Statement SQLiteInstruct(I)( auto ref I doc_matters, ) { - auto pth_sqlite = SiSUpathsSQLiteDiscrete!()(doc_matters.src_path_info, doc_matters.language); + auto pth_sqlite = SiSUpathsSQLiteDiscrete!()(doc_matters.output_path, doc_matters.language); auto db = Database(pth_sqlite.sqlite_file(doc_matters.source_filename)); // auto db = Database(":memory:"); // open database in memory db.run(" -- cgit v1.2.3