From 9cf470e69b2d579701ee607f796de612dc600565 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 20 Apr 2017 13:57:03 -0400 Subject: 0.14.0 reorganized files, and paths --- src/sdp/output_epub3.d | 60 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'src/sdp/output_epub3.d') diff --git a/src/sdp/output_epub3.d b/src/sdp/output_epub3.d index 314fe64..f16b25b 100644 --- a/src/sdp/output_epub3.d +++ b/src/sdp/output_epub3.d @@ -25,7 +25,8 @@ template outputEPub3() { create_zip_file, defaults, output_rgx, - output_xhtmls; + output_xhtmls, + paths_output; mixin InternalMarkup; mixin outputXHTMLs; string epub3_mimetypes() { @@ -45,6 +46,7 @@ template outputEPub3() { return o; } string epub3_oebps_content(D,I,P)(D doc_abstraction, I doc_matters, P parts) { + auto pth_epub3 = SiSUpathsEPUB!()(doc_matters.src_path_info, doc_matters.language); string uuid = "18275d951861c77f78acd05672c9906924c59f18a2e0ba06dad95959693e9bd8"; // TODO sort uuid in doc_matters! string content = format(q"¶ @@ -70,7 +72,7 @@ template outputEPub3() { - + ¶", @@ -91,16 +93,19 @@ template outputEPub3() { uuid, uuid, uuid, + (pth_epub3.fn_oebps_css(doc_matters.source_filename)).chompPrefix("OEBPS/"), ); content ~= " " ~ "" ~ "\n "; content ~= parts["manifest_documents"]; // TODO sort jpg & png content ~= " " ~ "" ~ "\n "; foreach (image; doc_matters.image_list) { - content ~= format(q"¶ + content ~= format(q"¶ ¶", - image, // strip image type, remove .png .jpg suffix, use in media-type="image/" + image.baseName.stripExtension, + (pth_epub3.doc_oebps_image(doc_matters.source_filename)).chompPrefix("OEBPS/"), image, + image.extension.chompPrefix("."), ); } content ~= " " ~ "" ~ "\n "; @@ -208,9 +213,12 @@ template outputEPub3() { foreach_reverse (k; 0 .. 7) { switch (obj.dom_markedup[k]) { case DomTags.close : + // writeln(markup.indent_by_spaces_provided(k), ""); // --debug dom tags toc ~= ""; break; case DomTags.close_and_open : + // writeln(markup.indent_by_spaces_provided(k), ""); // --debug dom tags + // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags ++counter; toc ~= ""; toc ~= format(q"¶ @@ -224,6 +232,7 @@ template outputEPub3() { ); break; case DomTags.open : + // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags ++counter; toc ~= format(q"¶ @@ -375,7 +384,7 @@ template outputEPub3() { doc_epub3[segment_filename] ~= to!string(t[0]); doc_epub3_endnotes[segment_filename] ~= t[1]; break; - case "poem": + case "poem": // double check why both poem & verse break; case "verse": auto t = xhtml_format.verse_seg(obj, suffix); @@ -530,22 +539,29 @@ template outputEPub3() { static assert(is(typeof(oebps_toc_ncx) == string)); static assert(is(typeof(oebps_content_opf) == string)); } - mixin SiSUpaths; - auto pth_epub3 = Epub3paths(); + auto src_path_info = doc_matters.src_path_info; + string fn_rel_pth = doc_matters.source_filename; + string lng = doc_matters.language; + auto pth_epub3 = SiSUpathsEPUB!()(src_path_info, lng); auto xhtml_format = outputXHTMLs(); /+ zip file +/ auto fn_epub = pth_epub3.epub_file(doc_matters.source_filename); auto zip = new ZipArchive(); // ZipArchive zip = new ZipArchive(); /+ zip archive member files +/ try { - if (!exists(pth_epub3.doc_meta_inf(doc_matters.source_filename))) { - pth_epub3.doc_meta_inf(doc_matters.source_filename).mkdirRecurse; + if (!exists(pth_epub3.base)) { + pth_epub3.base.mkdirRecurse; } - if (!exists(pth_epub3.doc_oebps_css(doc_matters.source_filename))) { - pth_epub3.doc_oebps_css(doc_matters.source_filename).mkdirRecurse; - } - if (!exists(pth_epub3.doc_oebps_image(doc_matters.source_filename))) { - pth_epub3.doc_oebps_image(doc_matters.source_filename).mkdirRecurse; + debug(epub_output) { + if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.source_filename))) { + pth_epub3.dbg_doc_meta_inf(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_css(doc_matters.source_filename))) { + pth_epub3.dbg_doc_oebps_css(doc_matters.source_filename).mkdirRecurse; + } + if (!exists(pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename))) { + pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename).mkdirRecurse; + } } { /+ OEBPS/[segments].xhtml (the document contents) +/ foreach (seg_filename; doc_matters.segnames) { @@ -630,7 +646,7 @@ template outputEPub3() { /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } - { /+ TODO OEBPS/toc.ncx (navigation toc epub2) +/ + { /+ OEBPS/toc.ncx (navigation toc epub2) +/ debug(epub_output) { fn_dbg = pth_epub3.dbg_fn_oebps_toc_ncx(doc_matters.source_filename); File(fn_dbg, "w").writeln(oebps_toc_ncx); @@ -647,7 +663,7 @@ template outputEPub3() { /+ create the zip file +/ createZipFile!()(fn_epub, zip.build()); } - { /+ TODO OEBPS/content.opf (doc manifest) +/ + { /+ OEBPS/content.opf (doc manifest) +/ debug(epub_output) { fn_dbg = pth_epub3.dbg_fn_oebps_content_opf(doc_matters.source_filename); File(fn_dbg, "w").writeln(oebps_content_opf); @@ -666,19 +682,19 @@ template outputEPub3() { } { /+ OEBPS/_sisu/image (images) +/ foreach (image; doc_matters.image_list) { - if (exists("_sisu/image/"~ image)) { - ("_sisu/image/"~ image) - .copy((pth_epub3.doc_oebps_image(doc_matters.source_filename)) ~ "/" ~ 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.source_filename)) ~ "/" ~ image); } } foreach (image; doc_matters.image_list) { debug(epub_images) { writeln( - "_sisu/image/", image, " -> ", - pth_epub3.doc_oebps_image(doc_matters.source_filename), "/", image + doc_matters.src_path_info.image_root, image, " -> ", + pth_epub3.dbg_doc_oebps_image(doc_matters.source_filename), "/", image ); } - auto fn_src = "_sisu/image/"~ image; + auto fn_src = doc_matters.src_path_info.image_root ~ image; auto fn_out = pth_epub3.doc_oebps_image(doc_matters.source_filename).to!string ~ "/" ~ image; if (exists(fn_src)) { { -- cgit v1.2.3