From 433f0b2ed0f9d5461c0fdf2b49e41eb26802cc2e Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 9 Oct 2019 15:21:34 -0400 Subject: 0.8.2 yaml pod.manifest, read site config first - yaml (configuration & metadata) site config, pod: pod.manifest, doc header: make, meta - pod.manifest in yaml breaks - older program reading new pod and - newer program reading old pod - read config first, - get site default language in case it is absent in pod.manifest - ensure config is not read too many times (it is at present, revisit) --- src/doc_reform/output/hub.d | 18 ++++++-- src/doc_reform/output/source_pod.d | 84 +++++++++++++++++++++++++++----------- 2 files changed, 75 insertions(+), 27 deletions(-) (limited to 'src/doc_reform/output') diff --git a/src/doc_reform/output/hub.d b/src/doc_reform/output/hub.d index 8f16528..a4a402b 100644 --- a/src/doc_reform/output/hub.d +++ b/src/doc_reform/output/hub.d @@ -18,11 +18,23 @@ template outputHub() { enum outTask { pod, source, 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); - if (sched == outTask.pod) { - msg.v("doc reform source processing... "); + if (sched == outTask.source + || sched == outTask.pod + ) { + if (sched == outTask.source) { + msg.v("doc reform source processing... "); + } + if (sched == outTask.pod) { + msg.v("doc reform source pod processing... "); + } import doc_reform.output.source_pod; DocReformPod!()(doc_matters); - msg.vv("doc reform source done"); + if (sched == outTask.source) { + msg.vv("doc reform source done"); + } + if (sched == outTask.pod) { + msg.vv("doc reform source pod done"); + } } if (sched == outTask.epub) { msg.v("epub3 processing... "); diff --git a/src/doc_reform/output/source_pod.d b/src/doc_reform/output/source_pod.d index 73c8d47..bf07715 100644 --- a/src/doc_reform/output/source_pod.d +++ b/src/doc_reform/output/source_pod.d @@ -91,7 +91,8 @@ template DocReformPod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose) { + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { writeln("WARNING (io) src out NOT found (image): ", fn_src_in); } } @@ -122,19 +123,19 @@ template DocReformPod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose - || doc_matters.opt.action.debug_do) { + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); } } - } { /+ bundle primary file +/ + } { /+ pod manifest +/ auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string; auto fn_src_out_pod_zip_base - = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).zpod.to!string; + = pths_pod.pod_manifest(doc_matters.src.filename).zpod.to!string; auto fn_src_out_filesystem - = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.to!string; // without root path: + = pths_pod.pod_manifest(doc_matters.src.filename).filesystem_open_zpod.to!string; // needed without root path auto fn_src_out_inside_pod - = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).zpod.to!string; // without root path: + = pths_pod.pod_manifest(doc_matters.src.filename).zpod.to!string; // needed without root path string[] filelist_src_out_pod_arr; string[] filelist_src_zpod_arr; if (exists(fn_src_in)) { @@ -143,14 +144,51 @@ template DocReformPod() { } filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base; filelist_src_zpod_arr ~= fn_src_out_inside_pod; - if (doc_matters.opt.action.source) { - auto filelist + { + import dyaml; + auto pod_filelist_yaml_string = File(pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod, "w"); - foreach (source_pth_and_fn; filelist_src_zpod_arr) { - filelist.writeln(source_pth_and_fn); + Node _pmy; + string _pm = "doc:\n filename: " ~ doc_matters.src.filename ~ "\n language: " ~ doc_matters.pod.manifest_list_of_languages.to!string ~ "\n"; + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { + _pmy = Loader.fromString(_pm).load(); + writeln("pod filename: ", _pmy["doc"]["filename"].get!string); + writeln("pod languages: ", doc_matters.pod.manifest_list_of_languages.to!string); + writeln("pod languages: ", doc_matters.src.language); + // foreach(string _l; _pmy["doc"]["language"]) { + // writeln("language: ", _l); + // } } - fn_src_in.copy(fn_src_out_filesystem); + if (doc_matters.opt.action.source) { + 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); + } + } + } + } { /+ bundle primary file (.ssm/.sst) +/ + auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string; + 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 + = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.to!string; // needed without root path: + auto fn_src_out_inside_pod + = pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).zpod.to!string; // needed without root path: + string[] filelist_src_out_pod_arr; + string[] filelist_src_zpod_arr; + if (exists(fn_src_in)) { + debug(io) { + writeln("(io debug) src in found: ", fn_src_in); } + filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base; + filelist_src_zpod_arr ~= fn_src_out_inside_pod; if (doc_matters.opt.action.pod) { auto zip_arc_member_file = new ArchiveMember(); zip_arc_member_file.name = fn_src_out_pod_zip_base; @@ -160,12 +198,12 @@ template DocReformPod() { zip.addMember(zip_arc_member_file); } } else { - if (doc_matters.opt.action.verbose - || doc_matters.opt.action.debug_do) { + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { writeln("WARNING (io) src in NOT found (markup source): ", fn_src_in); } } - } { /+ bundle insert files +/ + } { /+ bundle insert files (.ssi) +/ if (doc_matters.srcs.file_insert_list.length > 0) { foreach (insert_file; doc_matters.srcs.file_insert_list) { debug(pod) { @@ -208,8 +246,8 @@ template DocReformPod() { createZipFile!()(fn_pod, zip.build()); } } else { - if (doc_matters.opt.action.verbose - || doc_matters.opt.action.debug_do) { + if (doc_matters.opt.action.debug_do + && doc_matters.opt.action.verbose) { writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); } } @@ -230,7 +268,8 @@ template DocReformPod() { } if (exists(fn_pod)) { try { - if (!(doc_matters.opt.action.quiet)) { + if (!(doc_matters.opt.action.quiet) + && doc_matters.opt.action.pod) { auto data = (cast(byte[]) (fn_pod).read); if (doc_matters.opt.action.verbose) { writeln(" ", doc_matters.src.filename, " > "); @@ -244,8 +283,7 @@ template DocReformPod() { auto data = zipped.expand(member); writeln("> ", filename, " length ", data.length); } - } - catch (ZipException ex) { + } catch (ZipException ex) { // Handle errors } if (doc_matters.src.filename == "dr_doc/media/text/en/the_wealth_of_networks.yochai_benkler.sst") { @@ -269,14 +307,12 @@ template DocReformPod() { ); } } - } - catch (ErrnoException ex) { + } catch (ErrnoException ex) { // Handle errors } } - } - catch (ErrnoException ex) { + } catch (ErrnoException ex) { // Handle error } } -- cgit v1.2.3