aboutsummaryrefslogtreecommitdiffhomepage
path: root/org/output.org
diff options
context:
space:
mode:
Diffstat (limited to 'org/output.org')
-rw-r--r--org/output.org112
1 files changed, 88 insertions, 24 deletions
diff --git a/org/output.org b/org/output.org
index 673fc4f..054937e 100644
--- a/org/output.org
+++ b/org/output.org
@@ -59,7 +59,7 @@ template outputHub() {
}
if (doc_matters.opt_action_bool["sisupod"]) {
if ((doc_matters.opt_action_bool["verbose"])) {write("sisupod source processing... ");}
- SiSUpod!()(doc_matters.source_filename);
+ SiSUpod!()(doc_matters);
if ((doc_matters.opt_action_bool["verbose"])) {writeln("sisupod done");}
}
if (doc_matters.opt_action_bool["text"]) {
@@ -154,11 +154,8 @@ template SiSUpod() {
#+name: source_sisupod_config
#+BEGIN_SRC d
-void SiSUpod(S)(
- S fn_src,
-) {
+void SiSUpod(T)(T doc_matters) {
debug(asserts){
- static assert(is(typeof(fn_src) == string));
}
mixin SiSUrgxInit;
mixin SiSUpaths;
@@ -168,28 +165,83 @@ void SiSUpod(S)(
auto rgx = Rgx();
/+
dir structure
- /tmp/_sisu_processing_/ralph/en/sisupod
+ /tmp/_sisu_processing_/ralph/sisupod
+ ├── conf
+ ├── css (unless should be within conf?)
├── doc
- │   └── en
+ │ ├── en
+ │ ├── es
+ │ ├── fr
+ │   └── zh
└── image
- - create directory structure
-
+ - tasks
+ - create directory structure
+ - map other language directories
+ - check for corresponding files within
+/
- assert (match(fn_src, rgx.src_fn));
+ assert (match(doc_matters.source_filename, rgx.src_fn));
try {
/+ create directory structure +/
- mkdirRecurse(pth_sisupod.doc(fn_src));
- mkdirRecurse(pth_sisupod.conf(fn_src));
- mkdirRecurse(pth_sisupod.css(fn_src));
- mkdirRecurse(pth_sisupod.image(fn_src));
+ if (!exists(pth_sisupod.doc(doc_matters.source_filename))) {
+ mkdirRecurse(pth_sisupod.doc(doc_matters.source_filename));
+ }
+ if (!exists(pth_sisupod.conf(doc_matters.source_filename))) {
+ mkdirRecurse(pth_sisupod.conf(doc_matters.source_filename));
+ }
+ if (!exists(pth_sisupod.css(doc_matters.source_filename))) {
+ mkdirRecurse(pth_sisupod.css(doc_matters.source_filename));
+ }
+ if (!exists(pth_sisupod.image(doc_matters.source_filename))) {
+ mkdirRecurse(pth_sisupod.image(doc_matters.source_filename));
+ }
/+ copy relevant files +/
- auto f_out = pth_sisupod.fn_doc(fn_src, "en"); // you need fn without path and then to insert back language code for output sub-directory
debug(sisupod) {
- writeln(__LINE__, ": ", fn_src, " -> ", f_out);
+ writeln(__LINE__, ": ",
+ // doc_matters.environment["pwd"], "/",
+ doc_matters.source_filename, " -> ",
+ // doc_matters.environment["pwd"], "/",
+ pth_sisupod.fn_doc(doc_matters.source_filename, "en")
+ );
+ }
+ // need to extract language code directories (from directory structure or filenames & have a default)
+ if (!exists(pth_sisupod.doc_lng(doc_matters.source_filename, "en"))) {
+ mkdirRecurse(pth_sisupod.doc_lng(doc_matters.source_filename, "en"));
+ }
+ if (exists(doc_matters.source_filename)) {
+ copy(doc_matters.source_filename,
+ pth_sisupod.fn_doc(doc_matters.source_filename, "en"));
+ }
+ if (doc_matters.file_insert_list.length > 0) {
+ foreach (insert_file; doc_matters.file_insert_list) {
+ debug(sisupod) {
+ writeln(
+ // doc_matters.environment["pwd"], "/",
+ insert_file, " -> ",
+ // doc_matters.environment["pwd"], "/",
+ pth_sisupod.fn_doc(doc_matters.source_filename, "en")
+ );
+ }
+ if (exists(insert_file)) {
+ copy(insert_file,
+ pth_sisupod.fn_doc(doc_matters.source_filename, "en"));
+ }
+ }
+ }
+ foreach (image; doc_matters.image_list) {
+ debug(sisupod) {
+ writeln(
+ // doc_matters.environment["pwd"], "/",
+ "_sisu/image/", image, " -> ",
+ // doc_matters.environment["pwd"], "/",
+ pth_sisupod.image(doc_matters.source_filename), "/", image
+ );
+ }
+ if (exists("_sisu/image/"~ image)) {
+ copy(("_sisu/image/"~ image),
+ (pth_sisupod.image(doc_matters.source_filename) ~ "/" ~ image));
+ }
}
- mkdirRecurse(pth_sisupod.doc_lng(fn_src, "en")); // need to extract language code directories (from directory structure or filenames & have a default)
- copy(fn_src, f_out);
}
catch (ErrnoException ex) {
// Handle error
@@ -564,7 +616,9 @@ void scroll_write_output_file(Fn,C)(
mixin SiSUpaths;
auto pth_html = HtmlPaths();
try {
- mkdirRecurse(pth_html.base);
+ if (!exists(pth_html.base)) {
+ mkdirRecurse(pth_html.base);
+ }
auto f = File(pth_html.fn_scroll(fn_src), "w");
foreach (o; doc) {
f.writeln(o);
@@ -728,7 +782,9 @@ void seg_write_output_files(M,C)(
auto xhtml_format = outputXHTMLs();
auto m = matchFirst(doc_matters.source_filename, rgx.src_fn);
try {
- mkdirRecurse(pth_html.seg(doc_matters.source_filename));
+ if (!exists(pth_html.seg(doc_matters.source_filename))) {
+ mkdirRecurse(pth_html.seg(doc_matters.source_filename));
+ }
foreach (seg_filename; doc_matters.segnames) {
auto f = File(pth_html.fn_seg(doc_matters.source_filename, seg_filename), "w");
foreach (docseg; doc_html[seg_filename]) {
@@ -2199,7 +2255,9 @@ auto css_write() {
auto pth_css= "_sisu/css";
auto pth_css_fn= pth_css ~ "/html.css";
try {
- mkdirRecurse(pth_css);
+ if (!exists(pth_css)) {
+ mkdirRecurse(pth_css);
+ }
auto f = File(pth_css_fn, "w");
f.writeln(html_css);
// foreach (o; doc) {
@@ -2583,9 +2641,15 @@ void epub_write_output_files(C,EpD,Mt,Mic,Ot,Oc)(
auto pth_epub = EpubPaths();
auto xhtml_format = outputXHTMLs();
try {
- mkdirRecurse(pth_epub.doc_meta_inf(doc_matters.source_filename));
- mkdirRecurse(pth_epub.doc_oebps_css(doc_matters.source_filename));
- mkdirRecurse(pth_epub.doc_oebps_image(doc_matters.source_filename));
+ if (!exists(pth_epub.doc_meta_inf(doc_matters.source_filename))) {
+ mkdirRecurse(pth_epub.doc_meta_inf(doc_matters.source_filename));
+ }
+ if (!exists(pth_epub.doc_oebps_css(doc_matters.source_filename))) {
+ mkdirRecurse(pth_epub.doc_oebps_css(doc_matters.source_filename));
+ }
+ if (!exists(pth_epub.doc_oebps_image(doc_matters.source_filename))) {
+ mkdirRecurse(pth_epub.doc_oebps_image(doc_matters.source_filename));
+ }
/+ OEBPS/[segments].xhtml +/
foreach (seg_filename; doc_matters.segnames) {
auto f = File(pth_epub.fn_oebps_content_xhtml(doc_matters.source_filename, seg_filename), "w");