aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2017-02-04 21:02:56 -0500
committerRalph Amissah <ralph@amissah.com>2019-04-10 15:14:14 -0400
commit262f00d21e5c03fb1387d409ac10c4921d9ff27c (patch)
tree49cd60d92a2771f1b81db47a031e5ad2f1b8bfa4 /src
parentreorganize org file (diff)
output, sisupod & a few switchesdoc-reform_v0.0.12
Diffstat (limited to 'src')
-rw-r--r--src/sdp/output_epub.d12
-rw-r--r--src/sdp/output_html.d12
-rw-r--r--src/sdp/output_hub.d2
-rw-r--r--src/sdp/source_sisupod.d86
4 files changed, 88 insertions, 24 deletions
diff --git a/src/sdp/output_epub.d b/src/sdp/output_epub.d
index 076265c..f914f16 100644
--- a/src/sdp/output_epub.d
+++ b/src/sdp/output_epub.d
@@ -342,9 +342,15 @@ template outputEPub() {
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");
diff --git a/src/sdp/output_html.d b/src/sdp/output_html.d
index 7b99f4e..1d55033 100644
--- a/src/sdp/output_html.d
+++ b/src/sdp/output_html.d
@@ -34,7 +34,9 @@ template outputHTML() {
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);
@@ -185,7 +187,9 @@ template outputHTML() {
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]) {
@@ -1644,7 +1648,9 @@ template outputHTML() {
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) {
diff --git a/src/sdp/output_hub.d b/src/sdp/output_hub.d
index 6d6c134..f0df06c 100644
--- a/src/sdp/output_hub.d
+++ b/src/sdp/output_hub.d
@@ -41,7 +41,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"]) {
diff --git a/src/sdp/source_sisupod.d b/src/sdp/source_sisupod.d
index 1edbbfc..9ed2c97 100644
--- a/src/sdp/source_sisupod.d
+++ b/src/sdp/source_sisupod.d
@@ -22,11 +22,8 @@ template SiSUpod() {
ao_rgx,
output_xhtmls;
- 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;
@@ -36,28 +33,83 @@ template SiSUpod() {
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