aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sdp/output_epub3.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/sdp/output_epub3.d')
-rw-r--r--src/sdp/output_epub3.d60
1 files changed, 38 insertions, 22 deletions
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"¶ <?xml version='1.0' encoding='utf-8'?>
<package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="EPB-UUID">
@@ -70,7 +72,7 @@ template outputEPub3() {
<!-- NCX epub2 navigation -->
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml" />
<!-- CSS Style Sheets -->
- <item id="main-css" href="css/xhtml.css" media-type="text/css" />
+ <link rel="stylesheet" href="%s" type="text/css" id="main-css" />
<!-- nav epub3 navigation -->
<item id="nav" href="toc_nav.xhtml" media-type="application/xhtml+xml" properties="nav" />
¶",
@@ -91,16 +93,19 @@ template outputEPub3() {
uuid,
uuid,
uuid,
+ (pth_epub3.fn_oebps_css(doc_matters.source_filename)).chompPrefix("OEBPS/"),
);
content ~= " " ~ "<!-- Content Documents -->" ~ "\n ";
content ~= parts["manifest_documents"];
// TODO sort jpg & png
content ~= " " ~ "<!-- Images -->" ~ "\n ";
foreach (image; doc_matters.image_list) {
- content ~= format(q"¶ <item id="%s" href="image/%s" media-type="image/png" />
+ content ~= format(q"¶ <item id="%s" href="%s/%s" media-type="image/%s" />
¶",
- 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 ~= " " ~ "</manifest>" ~ "\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), "</", k, ">"); // --debug dom tags
toc ~= "</navPoint>";
break;
case DomTags.close_and_open :
+ // writeln(markup.indent_by_spaces_provided(k), "</", k, ">"); // --debug dom tags
+ // writeln(markup.indent_by_spaces_provided(k), "<", k, ">", obj.text); // --debug dom tags
++counter;
toc ~= "</navPoint>";
toc ~= format(q"¶<navPoint class="chapter" id="navpoint" playOrder="%s">
@@ -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"¶<navPoint class="chapter" id="navpoint" playOrder="%s">
<navLabel>
@@ -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)) {
{