aboutsummaryrefslogtreecommitdiffhomepage
path: root/org
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2019-10-16 12:26:36 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2019-10-17 19:07:20 -0400
commitab80f734713d5571f9014d17ec1f04d09b38011e (patch)
tree63e2e2a358834033fcee54bb58fd08ed6e9b4201 /org
parent0.8.2 yaml pod.manifest, read site config first (diff)
multilingual pods, zipped source
Diffstat (limited to 'org')
-rw-r--r--org/doc_reform.org18
-rw-r--r--org/output_hub.org14
-rw-r--r--org/output_src_pod.org176
3 files changed, 133 insertions, 75 deletions
diff --git a/org/doc_reform.org b/org/doc_reform.org
index 6b08fd2..995dde6 100644
--- a/org/doc_reform.org
+++ b/org/doc_reform.org
@@ -454,7 +454,7 @@ if (helpInfo.helpWanted) {
#+NAME: doc_reform_args
#+BEGIN_SRC d
-enum outTask { pod, source, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff }
+enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff }
struct OptActions {
bool assertions() {
return opts["assertions"];
@@ -573,6 +573,9 @@ struct OptActions {
bool source() {
return opts["source"];
}
+ bool source_or_pod() {
+ return (opts["pod"] || opts["source"]) ? true : false;
+ }
bool sqlite_discrete() {
return opts["sqlite-discrete"];
}
@@ -677,8 +680,7 @@ struct OptActions {
|| odt
|| latex
|| manifest
- || pod
- || source
+ || source_or_pod
|| sqlite_discrete
) {
_is = true;
@@ -690,11 +692,8 @@ struct OptActions {
}
auto output_task_scheduler() {
int[] schedule;
- if (pod) {
- schedule ~= outTask.pod;
- }
- if (source) {
- schedule ~= outTask.source;
+ if (source_or_pod) {
+ schedule ~= outTask.source_or_pod;
}
if (sqlite_discrete) {
schedule ~= outTask.sqlite;
@@ -723,8 +722,7 @@ struct OptActions {
bool _is;
if (opts["abstraction"]
|| concordance
- || source
- || pod
+ || source_or_pod
|| harvest
|| html
|| epub
diff --git a/org/output_hub.org b/org/output_hub.org
index e3b4607..d77d671 100644
--- a/org/output_hub.org
+++ b/org/output_hub.org
@@ -34,7 +34,7 @@ template outputHub() {
mixin Msg;
auto msg = Msg!()(doc_matters);
static auto rgx = Rgx();
- enum outTask { pod, source, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff }
+ enum outTask { source_or_pod, sqlite, sqlite_multi, latex, odt, epub, html_scroll, html_seg, html_stuff }
void Scheduled(D,I)(int sched, D doc_abstraction, I doc_matters) {
auto msg = Msg!()(doc_matters);
<<output_scheduled_task>>
@@ -82,21 +82,19 @@ import doc_reform.output,
#+name: output_scheduled_task
#+BEGIN_SRC d
-if (sched == outTask.source
- || sched == outTask.pod
-) {
- if (sched == outTask.source) {
+if (sched == outTask.source_or_pod) {
+ if (doc_matters.opt.action.source) {
msg.v("doc reform source processing... ");
}
- if (sched == outTask.pod) {
+ if (doc_matters.opt.action.pod) {
msg.v("doc reform source pod processing... ");
}
import doc_reform.output.source_pod;
DocReformPod!()(doc_matters);
- if (sched == outTask.source) {
+ if (doc_matters.opt.action.source) {
msg.vv("doc reform source done");
}
- if (sched == outTask.pod) {
+ if (doc_matters.opt.action.pod) {
msg.vv("doc reform source pod done");
}
}
diff --git a/org/output_src_pod.org b/org/output_src_pod.org
index 1e61c72..16cc35d 100644
--- a/org/output_src_pod.org
+++ b/org/output_src_pod.org
@@ -27,6 +27,7 @@ template DocReformPod() {
<<output_imports>>
void DocReformPod(T)(T doc_matters) {
<<source_pod_init>>
+ <<source_pod_archive>>
try {
<<source_pod_mkdirs>>
<<source_pod_copy>>
@@ -73,6 +74,37 @@ static auto rgx = Rgx();
assert (doc_matters.src.filename.match(rgx.src_fn));
#+END_SRC
+*** pod zip archive
+
+#+name: source_pod_archive
+#+BEGIN_SRC d
+auto pod_archive(Z)(
+ string _source_type,
+ string _data_in,
+ string _pth_out,
+ Z zip
+) {
+ auto zip_arc_member_file = new ArchiveMember();
+ zip_arc_member_file.name = _pth_out;
+ auto zip_data = new OutBuffer();
+ switch (_source_type) {
+ case "file_path_bin":
+ zip_data.write(cast(char[]) ((_data_in).read));
+ goto default;
+ case "file_path_text":
+ zip_data.write((_data_in).readText);
+ goto default;
+ case "string":
+ zip_data.write(_data_in);
+ goto default;
+ default:
+ zip_arc_member_file.expandedData = zip_data.toBytes();
+ zip.addMember(zip_arc_member_file);
+ }
+ return zip;
+}
+#+END_SRC
+
** mkdir :mkdir:
#+name: source_pod_mkdirs
@@ -142,12 +174,7 @@ auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
fn_src_in.copy(fn_src_out_filesystem);
}
if (doc_matters.opt.action.pod) {
- auto zip_arc_member_file = new ArchiveMember();
- zip_arc_member_file.name = fn_src_out_pod_zip_base;
- auto zip_data = new OutBuffer();
- zip_data.write(cast(char[]) ((fn_src_in).read));
- zip_arc_member_file.expandedData = zip_data.toBytes();
- zip.addMember(zip_arc_member_file);
+ zip = pod_archive("file_path_bin", fn_src_in, fn_src_out_pod_zip_base, zip);
}
} else {
if (doc_matters.opt.action.debug_do
@@ -174,12 +201,7 @@ auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
fn_src_in.copy(fn_src_out_filesystem);
}
if (doc_matters.opt.action.pod) {
- auto zip_arc_member_file = new ArchiveMember();
- zip_arc_member_file.name = fn_src_out_pod_zip_base;
- auto zip_data = new OutBuffer();
- zip_data.write((fn_src_in).readText);
- zip_arc_member_file.expandedData = zip_data.toBytes();
- zip.addMember(zip_arc_member_file);
+ zip = pod_archive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
}
} else {
if (doc_matters.opt.action.debug_do
@@ -223,17 +245,12 @@ auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
pod_filelist_yaml_string.writeln(_pm);
}
if (doc_matters.opt.action.pod) {
- auto zip_arc_member_file = new ArchiveMember();
- zip_arc_member_file.name = fn_src_out_pod_zip_base;
- auto zip_data = new OutBuffer();
- zip_data.write(_pm);
- zip_arc_member_file.expandedData = zip_data.toBytes();
- zip.addMember(zip_arc_member_file);
+ zip = pod_archive("string", _pm, fn_src_out_pod_zip_base, zip);
}
}
}
} { /+ bundle primary file (.ssm/.sst) +/
- auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string;
+ auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string; // original source file, inlcudes language code
auto fn_src_out_pod_zip_base
= pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).zpod.to!string;
auto fn_src_out_filesystem
@@ -248,13 +265,28 @@ auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
}
filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base;
filelist_src_zpod_arr ~= fn_src_out_inside_pod;
+ string _pod_to_markup_file = doc_matters.src.pod_name ~ "/" ~ "media/text/" ~ doc_matters.src.language ~ "/" ~ doc_matters.src.filename;
+ if (doc_matters.opt.action.source) {
+ fn_src_in.copy(fn_src_out_filesystem);
+ }
if (doc_matters.opt.action.pod) {
- auto zip_arc_member_file = new ArchiveMember();
- zip_arc_member_file.name = fn_src_out_pod_zip_base;
- auto zip_data = new OutBuffer();
- zip_data.write((fn_src_in).readText);
- zip_arc_member_file.expandedData = zip_data.toBytes();
- zip.addMember(zip_arc_member_file);
+ auto _rgx = regex(r"(?P<path_to_pod>\S+?)(?P<podname>[a-z_-]+)/(?P<from_root>media/text/)(?P<language>\S+?)/(?P<filename>\S+?\.ss[mt])");
+ if (auto _x = fn_src_in.match(_rgx)){
+ if (doc_matters.src.lng == doc_matters.pod.manifest_list_of_languages[$-1]) {
+ string _path_to_pod = _x.captures["path_to_pod"];
+ string _podname = _x.captures["podname"];
+ string _root_to_lang = _x.captures["from_root"];
+ string _language = _x.captures["language"];
+ string _filename = _x.captures["filename"];
+ foreach (_lang; doc_matters.pod.manifest_list_of_languages) {
+ string _pth_mkup_src_in = _path_to_pod ~ _podname ~ "/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename;
+ string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename;
+ zip = pod_archive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip);
+ }
+ }
+ } else {
+ zip = pod_archive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
+ }
}
} else {
if (doc_matters.opt.action.debug_do
@@ -264,6 +296,7 @@ auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
}
} { /+ bundle insert files (.ssi) +/
if (doc_matters.srcs.file_insert_list.length > 0) {
+ auto _rgx = regex(r"(?P<path_to_pod>\S+?)(?P<podname>[a-z_-]+)/(?P<from_root>media/text/)(?P<language>\S+?)/(?P<filename>\S+?\.ss[i])");
foreach (insert_file; doc_matters.srcs.file_insert_list) {
debug(pod) {
writeln(
@@ -275,39 +308,66 @@ auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod;
).zpod
);
}
- auto fn_src_in = insert_file;
- auto fn_src_out_pod_zip_base
- = pths_pod.fn_doc_insert(
- doc_matters.src.filename,
- insert_file,
- doc_matters.src.language,
- ).zpod.to!string;
- auto fn_src_out_filesystem
- = pths_pod.fn_doc_insert(
- doc_matters.src.filename,
- insert_file,
- doc_matters.src.language,
- ).filesystem_open_zpod.to!string;
- if (exists(fn_src_in)) {
- debug(io) {
- writeln("(io debug) src out found: ", fn_src_in);
- }
- if (doc_matters.opt.action.source) {
- fn_src_in.copy(fn_src_out_filesystem);
- }
- if (doc_matters.opt.action.pod) {
- auto zip_arc_member_file = new ArchiveMember();
- zip_arc_member_file.name = fn_src_out_pod_zip_base;
- auto zip_data = new OutBuffer();
- zip_data.write((fn_src_in).readText);
- zip_arc_member_file.expandedData = zip_data.toBytes();
- zip.addMember(zip_arc_member_file);
- createZipFile!()(fn_pod, zip.build());
+ if (auto _x = insert_file.match(_rgx)){
+ if (doc_matters.src.lng == doc_matters.pod.manifest_list_of_languages[$-1]) {
+ string _path_to_pod = _x.captures["path_to_pod"];
+ string _podname = _x.captures["podname"];
+ string _root_to_lang = _x.captures["from_root"];
+ string _language = _x.captures["language"];
+ string _filename = _x.captures["filename"];
+ foreach (_lang; doc_matters.pod.manifest_list_of_languages) {
+ string _pth_mkup_src_in = _path_to_pod ~ _podname ~ "/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename;
+ string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename;
+ if (exists(_pth_mkup_src_in)) {
+ if (doc_matters.opt.action.source) {
+ auto fn_src_out_filesystem // you need to change language sources
+ = pths_pod.fn_doc_insert(
+ doc_matters.src.filename, // doc_matters.src.filename
+ _pth_mkup_src_in, // insert_file
+ _lang,
+ ).filesystem_open_zpod.to!string;
+ _pth_mkup_src_in.copy(fn_src_out_filesystem); // check why here, thought dealt with elsewhere
+ }
+ if (doc_matters.opt.action.pod) {
+ zip = pod_archive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip);
+ }
+ } else {
+ if (doc_matters.opt.action.debug_do
+ && doc_matters.opt.action.verbose) {
+ writeln("WARNING (io) src out NOT found (insert file): ", _pth_mkup_src_in);
+ }
+ }
+ }
}
} else {
- if (doc_matters.opt.action.debug_do
- && doc_matters.opt.action.verbose) {
- writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in);
+ auto fn_src_in = insert_file;
+ auto fn_src_out_pod_zip_base
+ = pths_pod.fn_doc_insert(
+ doc_matters.src.filename,
+ insert_file,
+ doc_matters.src.language,
+ ).zpod.to!string;
+ auto fn_src_out_filesystem
+ = pths_pod.fn_doc_insert(
+ doc_matters.src.filename,
+ insert_file,
+ doc_matters.src.language,
+ ).filesystem_open_zpod.to!string;
+ if (exists(fn_src_in)) {
+ debug(io) {
+ writeln("(io debug) src out found: ", fn_src_in);
+ }
+ if (doc_matters.opt.action.source) {
+ fn_src_in.copy(fn_src_out_filesystem);
+ }
+ if (doc_matters.opt.action.pod) {
+ zip = pod_archive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip);
+ }
+ } else {
+ if (doc_matters.opt.action.debug_do
+ && doc_matters.opt.action.verbose) {
+ writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in);
+ }
}
}
}
@@ -339,7 +399,9 @@ if (exists(fn_pod)) {
if (doc_matters.opt.action.verbose) {
writeln(" ", doc_matters.src.filename, " > ");
}
- writefln(" %s\n %-(%02x%)", fn_pod, data.sha256Of);
+ if (doc_matters.opt.action.pod) {
+ writefln(" %s\n %s %-(%02x%)", fn_pod, "sha256", data.sha256Of);
+ }
}
debug(pod) {
try {