diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sisudoc/io_in/read_source_files.d | 154 | ||||
-rw-r--r-- | src/sisudoc/io_out/hub.d | 16 | ||||
-rw-r--r-- | src/sisudoc/io_out/latex.d | 1 | ||||
-rw-r--r-- | src/sisudoc/io_out/metadata.d | 45 | ||||
-rw-r--r-- | src/sisudoc/io_out/odt.d | 2 | ||||
-rw-r--r-- | src/sisudoc/io_out/source_pod.d | 660 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc.d | 22 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_from_src.d | 21 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_from_src_functions.d | 20 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_object_setter.d | 1 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_show_config.d | 4 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_show_make.d | 2 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_show_metadata.d | 2 | ||||
-rw-r--r-- | src/sisudoc/meta/metadoc_show_summary.d | 8 | ||||
-rwxr-xr-x | src/sisudoc/spine.d | 31 |
15 files changed, 550 insertions, 439 deletions
diff --git a/src/sisudoc/io_in/read_source_files.d b/src/sisudoc/io_in/read_source_files.d index 4ba0b4f..b465cc3 100644 --- a/src/sisudoc/io_in/read_source_files.d +++ b/src/sisudoc/io_in/read_source_files.d @@ -56,6 +56,7 @@ module sisudoc.io_in.read_source_files; @safe: template spineRawMarkupContent() { import + std.digest.sha, std.file, std.path; import @@ -77,21 +78,33 @@ template spineRawMarkupContent() { return images_; } auto rawsrc = RawMarkupContent(); - alias ContentsInsertsImages = Tuple!( - char[][], "contents", - string[], "insert_files", - string[], "images" - ); - alias HeaderContentInsertsImages = Tuple!( - char[], "header", - char[][], "src_txt", - string[], "insert_files", - string[], "images" - ); - auto spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) { - auto _0_header_1_body_content_2_insert_filelist_tuple + struct ST_contents_inserts_images { + char[][] contents; + string[] insert_files; + string[] images; + } + struct ST_header_content_inserts_images { + char[] header; + char[][] src_txt; + string[] insert_files; + string[] images; + } + struct ST_doc_digest { + ubyte[32] markup_doc; + ubyte[32] header; + ubyte[32] text; + } + struct ST_doc_parts { + char[] header_raw; + char[][] sourcefile_body_content; + string[] insert_file_list; + string[] images_list; + ST_doc_digest doc_digest; + } + ST_doc_parts spineRawMarkupContent(O,Fn)(O _opt_action, Fn fn_src) { + ST_doc_parts _0_header_1_body_content_2_insert_filelist_struct = rawsrc.sourceContentSplitIntoHeaderAndBody(_opt_action, rawsrc.sourceContent(fn_src), fn_src); - return _0_header_1_body_content_2_insert_filelist_tuple; + return _0_header_1_body_content_2_insert_filelist_struct; } struct RawMarkupContent { final sourceContent(in string fn_src) { @@ -100,43 +113,53 @@ template spineRawMarkupContent() { = raw.markupSourceReadIn(fn_src); return source_txt_str; } - final auto sourceContentSplitIntoHeaderAndBody(O)( + final ST_doc_parts sourceContentSplitIntoHeaderAndBody(O)( O _opt_action, in string source_txt_str, in string fn_src="" ) { auto raw = MarkupRawUnit(); - string[] insert_file_list; - string[] images_list; - HeaderContentInsertsImages t - = raw.markupSourceHeaderContentRawLineTupleArray(source_txt_str); - char[] header_raw = t.header; - char[][] sourcefile_body_content = t.src_txt; + string[] insert_file_list_get; + string[] images_list_get; + ST_header_content_inserts_images st + = raw.markupSourceHeaderContentRawLineStructArray(source_txt_str); + char[] header_raw = st.header; + char[][] sourcefile_body_content = st.src_txt; if (fn_src.match(rgx_files.src_fn_master)) { // filename with path needed if master file (.ssm) not otherwise auto ins = Inserts(); - ContentsInsertsImages tu + ST_contents_inserts_images _cii = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src); - sourcefile_body_content = tu.contents; - insert_file_list = tu.insert_files.dup; - images_list = tu.images.dup; + sourcefile_body_content = _cii.contents; + insert_file_list_get = _cii.insert_files.dup; + images_list_get = _cii.images.dup; } else if (_opt_action.source || _opt_action.pod) { auto ins = Inserts(); - ContentsInsertsImages tu + ST_contents_inserts_images _cii = ins.scan_master_src_for_insert_files_and_import_content(_opt_action, sourcefile_body_content, fn_src); - images_list = tu.images.dup; - } + images_list_get = _cii.images.dup; + } // image_list, if path could take sha256 digests already here? string header_type = ""; - t = tuple( - header_raw, - sourcefile_body_content, - insert_file_list, - images_list - ); - return t; + ST_doc_digest dig; + { + dig.markup_doc = source_txt_str.sha256Of; + dig.header = st.header.sha256Of; + dig.text = sourcefile_body_content.sha256Of; + } + ST_doc_parts ret; + { + ret.header_raw = st.header; + ret.sourcefile_body_content = sourcefile_body_content; + ret.insert_file_list = insert_file_list_get; + ret.images_list = images_list_get; + ret.doc_digest = dig; + } + return ret; } } struct MarkupRawUnit { - import std.file; + import + std.digest.sha, + std.file; final private string readInMarkupSource(in char[] fn_src) { enforce( exists(fn_src) != 0, @@ -188,20 +211,21 @@ template spineRawMarkupContent() { string source_txt_str = readInMarkupSource(fn_src); return source_txt_str; } - HeaderContentInsertsImages markupSourceHeaderContentRawLineTupleArray(in string source_txt_str) { + ST_header_content_inserts_images markupSourceHeaderContentRawLineStructArray(in string source_txt_str) { string[] file_insert_list = []; string[] images_list = []; char[][] hc = header0Content1(source_txt_str); char[] header = hc[0]; char[] source_txt = hc[1]; char[][] source_line_arr = markupSourceLineArray(source_txt); - HeaderContentInsertsImages t = tuple( - header, - source_line_arr, - file_insert_list, - images_list - ); - return t; + ST_header_content_inserts_images ret; + { + ret.header = header; + ret.src_txt = source_line_arr; + ret.insert_files = file_insert_list; + ret.images = images_list; + } + return ret; } final char[][] getInsertMarkupSourceContentRawLineArray( in char[] fn_src_insert, @@ -218,11 +242,11 @@ template spineRawMarkupContent() { } } struct Inserts { - alias ContentsAndImages = Tuple!( - char[][], "insert_contents", - string[], "images" - ); - ContentsAndImages scan_subdoc_source(O)( + struct ST_contents_and_images { + char[][] insert_contents; + string[] images; + } + ST_contents_and_images scan_subdoc_source(O)( O _opt_action, char[][] markup_sourcefile_insert_content, string fn_src @@ -289,13 +313,14 @@ template spineRawMarkupContent() { } } } // end src subdoc (inserts) loop - ContentsAndImages t = tuple( - contents_insert, - _images - ); - return t; + ST_contents_and_images ret; + { + ret.insert_contents = contents_insert; + ret.images = _images; + } + return ret; } - ContentsInsertsImages scan_master_src_for_insert_files_and_import_content(O)( + ST_contents_inserts_images scan_master_src_for_insert_files_and_import_content(O)( O _opt_action, char[][] sourcefile_body_content, string fn_src @@ -345,14 +370,14 @@ template spineRawMarkupContent() { ); } auto ins = Inserts(); - ContentsAndImages contents_insert_tu = ins.scan_subdoc_source( + ST_contents_and_images contents_insert_st = ins.scan_subdoc_source( _opt_action, markup_sourcefile_insert_content, fn_src_insert.to!string ); - contents ~= contents_insert_tu.insert_contents; + contents ~= contents_insert_st.insert_contents; if (_opt_action.source || _opt_action.pod) { - string[] _image_linelist = _extract_images(contents_insert_tu.images); + string[] _image_linelist = _extract_images(contents_insert_st.images); if (_image_linelist.length > 0) { _images ~= _image_linelist; } @@ -385,12 +410,13 @@ template spineRawMarkupContent() { writeln(__LINE__); writeln(contents.length); } - ContentsInsertsImages t = tuple( - contents, - insert_file_list, - images - ); - return t; + ST_contents_inserts_images ret; + { + ret.contents = contents; + ret.insert_files = insert_file_list; + ret.images = images; + } + return ret; } } } diff --git a/src/sisudoc/io_out/hub.d b/src/sisudoc/io_out/hub.d index b68eb0d..0b7fe8c 100644 --- a/src/sisudoc/io_out/hub.d +++ b/src/sisudoc/io_out/hub.d @@ -70,17 +70,11 @@ template outputHub() { auto msg = Msg!()(doc_matters); if (sched == outTask.source_or_pod) { msg.v("spine (doc reform) source processing... "); - if (doc_matters.opt.action.pod) { - msg.v("spine (doc reform) source pod processing... "); - } + if (doc_matters.opt.action.pod) { msg.v("spine (doc reform) source pod processing... "); } import sisudoc.io_out.source_pod; spinePod!()(doc_matters); - if (doc_matters.opt.action.source) { - msg.vv("spine (doc reform) source done"); - } - if (doc_matters.opt.action.pod) { - msg.vv("spine (doc reform) source pod done"); - } + if (doc_matters.opt.action.source) { msg.vv("spine (doc reform) source done"); } + if (doc_matters.opt.action.pod) { msg.vv("spine (doc reform) source pod done"); } } if (sched == outTask.epub) { msg.v("epub3 processing... "); @@ -140,9 +134,7 @@ template outputHub() { msg.vv("sqlite done"); } } - if (doc_matters.opt.action.vox_gt0) { - writeln(" ", doc_matters.src.filename_base); - } + if (doc_matters.opt.action.vox_gt0) { writeln(doc_matters.src.filename_base); } if (!(doc_matters.opt.action.parallelise_subprocesses)) { foreach(schedule; doc_matters.opt.action.output_task_scheduler) { Scheduled!()(schedule, doc_abstraction, doc_matters); diff --git a/src/sisudoc/io_out/latex.d b/src/sisudoc/io_out/latex.d index 771bc57..e1b5731 100644 --- a/src/sisudoc/io_out/latex.d +++ b/src/sisudoc/io_out/latex.d @@ -320,7 +320,6 @@ template paperLaTeX() { } template outputLaTeX() { import - std.digest.sha, std.file, std.outbuffer, std.uri, diff --git a/src/sisudoc/io_out/metadata.d b/src/sisudoc/io_out/metadata.d index 0210212..0917969 100644 --- a/src/sisudoc/io_out/metadata.d +++ b/src/sisudoc/io_out/metadata.d @@ -48,9 +48,9 @@ +/ module sisudoc.io_out.metadata; -@safe: +// @safe: template outputMetadata() { - void outputMetadata(T)( T doc_matters) { + void outputMetadata(T)(T doc_matters) { string inline_search_form(M)( M doc_matters, ) { @@ -110,11 +110,13 @@ template outputMetadata() { return o; } import + std.digest.crc, + std.digest.sha, std.file, std.format; import sisudoc.io_out; mixin InternalMarkup; - string[] metadata_; + char[] metadata_; string theme_dark_0 = format(q"┃ body { color : #CCCCCC; @@ -364,7 +366,7 @@ string theme_light_1 = format(q"┃ doc_matters.opt.action.css_theme_default ? theme_light_0 : theme_dark_0, doc_matters.opt.action.css_theme_default ? theme_light_1 : theme_dark_1, ) ~ "\n"; - void metadata_write_output(M)(M doc_matters, string[] metadata_) { + void metadata_write_output(M)(M doc_matters, char[] metadata_) { auto pth_html = spinePathsHTML!()(doc_matters.output_path, doc_matters.src.language); try { if (!exists(pth_html.base)) { @@ -373,7 +375,7 @@ string theme_light_1 = format(q"┃ { auto f = File(pth_html.fn_scroll("metadata." ~ doc_matters.src.filename), "w"); foreach (o; metadata_) { - f.writeln(o); + f.write(o); } } if (!exists(pth_html.base ~ "/index.html")) { @@ -391,9 +393,7 @@ string theme_light_1 = format(q"┃ } catch (ErrnoException ex) { // Handle error } - if (doc_matters.opt.action.vox_gt0) { - writeln(" ", pth_html.fn_scroll("metadata." ~ doc_matters.src.filename)); - } + if (doc_matters.opt.action.vox_gt0) { writeln(" ", pth_html.fn_scroll("metadata." ~ doc_matters.src.filename)); } } static auto mkup = InlineMarkup(); import sisudoc.io_out.html_snippet; @@ -473,13 +473,6 @@ string theme_light_1 = format(q"┃ } else if (doc_matters.opt.action.debug_do) { writeln("WARNING no summary of text provided in document header ", doc_matters.src.filename_base); } - metadata_ ~= "<hr /><p class=\"lev1\">source: " ~ doc_matters.src.filename_base ~ "</p>"; - if (doc_matters.opt.action.html_link_markup_source) { - metadata_ ~= "<p class=\"lev1\">● markup source: the pod [<a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ ".zip\" class=\"lnkicon\">" - ~ " 🫛 zipped </a>| " - ~ "<a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ "/\" class=\"lnkicon\">" - ~ " 🫛 tree </a>] "; - } metadata_ ~= "<p class=\"lev1\">● outputs: [ html: <a href=\"" ~ doc_matters.src.filename_base ~ ".html\" class=\"lnkicon\">" ~ " ▤ scroll </a> " ~ "|<a href=\"" ~ doc_matters.src.filename_base ~ "/toc.html\" class=\"lnkicon\">" @@ -507,6 +500,28 @@ string theme_light_1 = format(q"┃ ~ " □ pdf (U.S. letter) </a>] "; } metadata_ ~= "</p>"; + if (doc_matters.opt.action.html_link_markup_source) { + metadata_ ~= "<hr /><p class=\"lev1\">source: " ~ doc_matters.src.filename_base ~ "</p>"; + metadata_ ~= "<p class=\"lev1\">● markup source: the pod [<a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ ".zip\" class=\"lnkicon\">" + ~ " 🫛 zipped </a>| " + ~ "<a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ "/\" class=\"lnkicon\">" + ~ " 🫛 tree </a>] "; + metadata_ ~= "<p class=\"lev1\">● source digests:" + ~ " [ <a href=\"../../" ~ pth_pod.internal_base ~ "/" ~ doc_matters.src.filename_base ~ ".digests.txt\" class=\"lnkizipcon\">" + ~ " # digests </a>]</p>"; + auto pths_pod = spinePathsPods!()(doc_matters); + auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod; + if (doc_matters.opt.action.pod) { + try { // get sha digest for pod + metadata_ ~= "<p class=\"lev2\">"; + auto data = (cast(byte[]) (fn_pod).read); // prevents code from being safe + metadata_ ~= "<tt>" ~ data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ "</tt> - " ~ doc_matters.src.filename_base ~ ".zip"; + metadata_ ~= "</p>"; + } catch (Exception ex) { + writeln("WARNING, source doc_matters.src.filename_base not found: ", doc_matters.src.filename_base, ".zip\n ", fn_pod); + } + } + } if (doc_matters.conf_make_meta.meta.classify_topic_register_arr.length > 0) { metadata_ ~= "<hr /><p class=\"lev0\">Topics:</p>"; string[] _top = ["", "", "", "", ""]; diff --git a/src/sisudoc/io_out/odt.d b/src/sisudoc/io_out/odt.d index d6ac27d..0450509 100644 --- a/src/sisudoc/io_out/odt.d +++ b/src/sisudoc/io_out/odt.d @@ -55,7 +55,6 @@ template formatODT() { sisudoc.io_out.rgx, sisudoc.io_out.rgx_xhtml; import - std.digest.sha, std.file, std.outbuffer, std.uri, @@ -651,7 +650,6 @@ template outputODT() { sisudoc.io_out.rgx, sisudoc.io_out.rgx_xhtml; import - std.digest.sha, std.file, std.outbuffer, std.uri, diff --git a/src/sisudoc/io_out/source_pod.d b/src/sisudoc/io_out/source_pod.d index 97e31af..2b9953f 100644 --- a/src/sisudoc/io_out/source_pod.d +++ b/src/sisudoc/io_out/source_pod.d @@ -68,355 +68,421 @@ template spinePod() { } mixin spineRgxFiles; string pwd = doc_matters.env.pwd; - auto src_path_info = doc_matters.src_path_info; - auto pth_dr_doc_src = doc_matters.src_path_info; auto pths_pod = spinePathsPods!()(doc_matters); mixin spineLanguageCodes; auto lang = Lang(); static auto rgx_files = RgxFiles(); assert (doc_matters.src.filename.match(rgx_files.src_fn)); - @system 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); + if (doc_matters.opt.action.pod) { + try { + { + podArchive_directory_tree(doc_matters, pths_pod); + } + { + struct STsrcDigests { + std.zip.ZipArchive zip; + string fn_pod; + string[string][string] digests; + } + STsrcDigests _st; + _st = pod_zipMakeReady(doc_matters, pths_pod, _st); + { + zipArchive(doc_matters, _st.fn_pod, _st.zip); + if (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { + zipArchiveDigest(doc_matters, _st.fn_pod, _st.digests); + } + } + } + } catch (ErrnoException ex) { + // Handle error } - return zip; } - try { - /+ create directory structure +/ - if (!exists(pths_pod.pod_dir_())) { - // used both by pod zipped (& pod filesystem (unzipped) which makes its own recursive dirs) - pths_pod.pod_dir_().mkdirRecurse; + } + void podArchive_directory_tree(M,P)(M doc_matters, P pths_pod) { // create directory structure + if (!exists(pths_pod.pod_dir_())) { + // used both by pod zipped (& pod filesystem (unzipped) which makes its own recursive dirs) + pths_pod.pod_dir_().mkdirRecurse; + } + if (doc_matters.opt.action.source_or_pod) { + // if (doc_matters.opt.action.vox_gt0) { writeln(" ", pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod); } + if (!exists(pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod)) { + pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; } - if (doc_matters.opt.action.source_or_pod) { - if (doc_matters.opt.action.vox_gt0) { - writeln(" ", pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod); - } - if (!exists(pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod)) { - pths_pod.text_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; - } - if (!exists(pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod)) { - pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; - } - if (!exists(pths_pod.media_root(doc_matters.src.filename).filesystem_open_zpod)) { - pths_pod.media_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; - } - if (!exists(pths_pod.css(doc_matters.src.filename).filesystem_open_zpod)) { - pths_pod.css(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; - } - if (!exists(pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod)) { - pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; - } - if (!exists(pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod)) { - pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.mkdirRecurse; - } + if (!exists(pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod)) { + pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; } - if (!exists(pths_pod.pod_dir_() ~ "/index.html")) { - import sisudoc.io_out.html_snippet; - mixin htmlSnippet; - auto f = File(pths_pod.pod_dir_() ~"/index.html", "w"); - f.writeln(format_html_blank_page_guide_home( - "../../css/html_scroll.css", - (doc_matters.opt.action.webserver_url_doc_root.length > 0) - ? doc_matters.opt.action.webserver_url_doc_root - : doc_matters.conf_make_meta.conf.w_srv_data_root_url, - "../../index.html", - )); + if (!exists(pths_pod.media_root(doc_matters.src.filename).filesystem_open_zpod)) { + pths_pod.media_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; } - if (doc_matters.opt.action.debug_do_pod - && doc_matters.opt.action.vox_gt1) { - writeln(__LINE__, ": ", - doc_matters.src.filename, " -> ", - pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod - ); + if (!exists(pths_pod.css(doc_matters.src.filename).filesystem_open_zpod)) { + pths_pod.css(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; } - auto zip = new ZipArchive(); - auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod; - { /+ bundle images +/ - foreach (image; doc_matters.srcs.image_list) { - debug(podimages) { - writeln( - pth_dr_doc_src.image_root.to!string, "/", image, " -> ", - pths_pod.image_root(doc_matters.src.filename).zpod, "/", image - ); - } - auto fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; - auto fn_src_out_pod_zip_base - = pths_pod.image_root(doc_matters.src.filename).zpod.to!string - ~ "/" ~ image; - auto fn_src_out_filesystem - = pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod.to!string - ~ "/" ~ image; - if (exists(fn_src_in)) { - debug(io) { - writeln("(io debug) src out found: ", fn_src_in); - } - if (doc_matters.opt.action.source_or_pod) { - fn_src_in.copy(fn_src_out_filesystem); - } - if (doc_matters.opt.action.pod) { - zip = pod_archive("file_path_bin", fn_src_in, fn_src_out_pod_zip_base, zip); - } - } else { - if (doc_matters.opt.action.debug_do_pod - && doc_matters.opt.action.vox_gt1) { - writeln("WARNING (io) src out NOT found (image): ", fn_src_in); - } - } + if (!exists(pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod)) { + pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod.mkdirRecurse; + } + if (!exists(pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod)) { + pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.mkdirRecurse; + } + } + if (!exists(pths_pod.pod_dir_() ~ "/index.html")) { + import sisudoc.io_out.html_snippet; + mixin htmlSnippet; + auto f = File(pths_pod.pod_dir_() ~"/index.html", "w"); + f.writeln(format_html_blank_page_guide_home( + "../../css/html_scroll.css", + (doc_matters.opt.action.webserver_url_doc_root.length > 0) + ? doc_matters.opt.action.webserver_url_doc_root + : doc_matters.conf_make_meta.conf.w_srv_data_root_url, + "../../index.html", + )); + } + } + auto pod_zipMakeReady(M,P,S)(M doc_matters, P pths_pod, S _st) { + auto pth_dr_doc_src = doc_matters.src_path_info; + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + writeln(__LINE__, ": ", + doc_matters.src.filename, " -> ", + pths_pod.fn_doc(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod + ); + } + auto zip = new ZipArchive(); // needed + auto fn_pod = pths_pod.pod_filename(doc_matters.src.filename).zpod; + string[string][string] _digests; + { // bundle images - get digest + foreach (image; doc_matters.srcs.image_list) { + debug(podimages) { + writeln( + pth_dr_doc_src.image_root.to!string, "/", image, " -> ", + pths_pod.image_root(doc_matters.src.filename).zpod, "/", image + ); } - } { /+ bundle dr_document_make +/ - auto fn_src_in = ((doc_matters.src.is_pod) - ? doc_matters.src.conf_dir_path - : pth_dr_doc_src.conf_root).to!string - ~ "/" ~ "dr_document_make"; + auto fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; auto fn_src_out_pod_zip_base - = pths_pod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "dr_document_make"; + = pths_pod.image_root(doc_matters.src.filename).zpod.to!string + ~ "/" ~ image; auto fn_src_out_filesystem - = pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod.to!string - ~ "/" ~ "dr_document_make"; + = pths_pod.image_root(doc_matters.src.filename).filesystem_open_zpod.to!string + ~ "/" ~ image; if (exists(fn_src_in)) { - debug(io) { - writeln("(io debug) src out found: ", fn_src_in); + debug(io) { writeln("(io debug) src out found: ", fn_src_in); } + { // take DIGEST write to pod file digests.txt + auto data = (cast(byte[]) (fn_src_in).read); + _digests["shared"]["images"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ image ~ "\n"; + // writeln(data.sha256Of.toHexString, "::", data.length, " - ", image); } if (doc_matters.opt.action.source_or_pod) { 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); + zip = podArchive("file_path_bin", fn_src_in, fn_src_out_pod_zip_base, zip); } } else { - if (doc_matters.opt.action.debug_do_pod - && doc_matters.opt.action.vox_gt1) { - writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (image): ", fn_src_in); } } - } { /+ pod manifest +/ - auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string; - auto fn_src_out_pod_zip_base - = pths_pod.pod_manifest(doc_matters.src.filename).zpod.to!string; - auto fn_src_out_filesystem - = 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.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)) { - debug(io) { - writeln("(io debug) src in found: ", fn_src_in); + } + } { // bundle dr_document_make + auto fn_src_in = ((doc_matters.src.is_pod) + ? doc_matters.src.conf_dir_path + : pth_dr_doc_src.conf_root).to!string + ~ "/" ~ "dr_document_make"; + auto fn_src_out_pod_zip_base + = pths_pod.conf_root(doc_matters.src.filename).zpod.to!string ~ "/" ~ "dr_document_make"; + auto fn_src_out_filesystem + = pths_pod.conf_root(doc_matters.src.filename).filesystem_open_zpod.to!string + ~ "/" ~ "dr_document_make"; + if (exists(fn_src_in)) { + debug(io) { writeln("(io debug) src out found: ", fn_src_in); } + if (doc_matters.opt.action.source_or_pod) { + fn_src_in.copy(fn_src_out_filesystem); + } + if (doc_matters.opt.action.pod) { + zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); + } + } else { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (document make): ", fn_src_in); + } + } + } { // pod manifest + auto fn_src_in = doc_matters.src.file_with_absolute_path.to!string; + auto fn_src_out_pod_zip_base + = pths_pod.pod_manifest(doc_matters.src.filename).zpod.to!string; + auto fn_src_out_filesystem + = 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.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)) { + 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; + { + import dyaml; + auto pod_filelist_yaml_string + = File(pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod, "w"); + 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_pod && doc_matters.opt.action.vox_gt1) { + try { + _pmy = Loader.fromString(_pm).load(); + } catch (ErrnoException ex) { + } catch (Throwable) { + writeln("ERROR failed to read config file content, not parsed as yaml"); + } + 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); + // } } - filelist_src_out_pod_arr ~= fn_src_out_pod_zip_base; - filelist_src_zpod_arr ~= fn_src_out_inside_pod; - { - import dyaml; - auto pod_filelist_yaml_string - = File(pths_pod.fn_pod_filelist(doc_matters.src.filename).filesystem_open_zpod, "w"); - 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_pod - && doc_matters.opt.action.vox_gt1) { - try { - _pmy = Loader.fromString(_pm).load(); - } catch (ErrnoException ex) { - } catch (Throwable) { - writeln("ERROR failed to read config file content, not parsed as yaml"); - } - 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); - // } + if (doc_matters.opt.action.source_or_pod) { + pod_filelist_yaml_string.writeln(_pm); + } + if (doc_matters.opt.action.pod) { + zip = podArchive("string", _pm, fn_src_out_pod_zip_base, zip); + } + } + } + } { // bundle primary file (.ssm/.sst) - get digest + 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 (doc_matters.src.language == doc_matters.pod.manifest_list_of_languages[$-1]) { // wait until all language versions of .ssm parsed + foreach (_lang; doc_matters.pod.manifest_list_of_languages) { // do for all language versions + string fn_src_out_filesystem_lng + = pths_pod.fn_doc(doc_matters.src.filename, _lang).filesystem_open_zpod.to!string; + string _sstm = (doc_matters.pod.manifest_path ~ "/media/text/" ~ _lang ~ "/" ~ doc_matters.src.filename); + // writeln(_sstm); + if (exists(_sstm)) { // what of language? + debug(io) { writeln("(io debug) src in found: ", _sstm); } + { // take DIGEST write to pod file digests.txt + auto data = (cast(byte[]) (_sstm).read); + _digests[_lang]["sstm"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename ~ " - [" ~ _lang ~ "]"; + // writeln(data.sha256Of.toHexString, "::", data.length, " - ", doc_matters.src.filename); } + 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/" ~ _lang ~ "/" ~ doc_matters.src.filename; if (doc_matters.opt.action.source_or_pod) { - pod_filelist_yaml_string.writeln(_pm); + _sstm.copy(fn_src_out_filesystem_lng); } if (doc_matters.opt.action.pod) { - zip = pod_archive("string", _pm, fn_src_out_pod_zip_base, zip); + auto _rgx_sstm = 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 = _sstm.match(_rgx_sstm)){ + if (doc_matters.src.lng == doc_matters.pod.manifest_list_of_languages[$-1]) { // again wait until all language versions of .ssm parsed + 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"]; // .ssi inserts expected to have same name across languages + string _filename = _x.captures["filename"]; + foreach (_lang1; doc_matters.pod.manifest_list_of_languages) { // do for all language versions + string _pth_mkup_src_in = _path_to_pod ~ _podname ~ "/" ~ _root_to_lang ~ _lang1 ~ "/" ~ _filename; + string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang1 ~ "/" ~ _filename; + // writeln("\nin: ", _pth_mkup_src_in, "\nout: ", _pth_mkup_src_out); // DEBUG, REMOVE + zip = podArchive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip); + } + } + } else { + zip = podArchive("file_path_text", _sstm, fn_src_out_pod_zip_base, zip); + } + } + } else { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src in NOT found (markup source): ", _sstm); } } } - } { /+ 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; - 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_or_pod) { - fn_src_in.copy(fn_src_out_filesystem); + } + } { // bundle insert files (.ssi) - get digest + if (doc_matters.srcs.file_insert_list.length > 0) { + auto _rgx_ssi = 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( + insert_file, " -> ", + pths_pod.fn_doc_insert( + doc_matters.src.filename, + insert_file, + doc_matters.src.language, + ).zpod + ); } - if (doc_matters.opt.action.pod) { - 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); + if (auto _x = insert_file.match(_rgx_ssi)){ + 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; + { // take DIGEST write to pod file digests.txt + auto data = (cast(byte[]) (_pth_mkup_src_in).read); + _digests[_language]["ssi"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ _filename ~ " - [" ~ _lang ~ "]" ~ "\n"; + // writeln(data.sha256Of.toHexString, "::", data.length, " - ", _filename, " - [", _lang, "]"); + } + string _pth_mkup_src_out = "pod/" ~ _root_to_lang ~ _lang ~ "/" ~ _filename; + if (exists(_pth_mkup_src_in)) { + if (doc_matters.opt.action.source_or_pod) { + 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 = podArchive("file_path_text", _pth_mkup_src_in, _pth_mkup_src_out, zip); + } + } else { + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (insert file): ", _pth_mkup_src_in); + } } } - } 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_pod - && doc_matters.opt.action.vox_gt1) { - writeln("WARNING (io) src in NOT found (markup source): ", fn_src_in); - } - } - } { /+ 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( - insert_file, " -> ", - pths_pod.fn_doc_insert( - doc_matters.src.filename, - insert_file, - doc_matters.src.language, - ).zpod - ); + } else { + auto fn_src_in = insert_file; + { // take DIGEST write to pod file digests.txt // FIX likely bug insert_file includes path, not what you wish to write + auto data = (cast(byte[]) (fn_src_in).read); + _digests["en"]["ssi"] ~= data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ insert_file ~ "\n"; + // writeln(data.sha256Of.toHexString, "::", data.length, " - ", insert_file); } - 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_or_pod) { - 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_pod - && doc_matters.opt.action.vox_gt1) { - writeln("WARNING (io) src out NOT found (insert file): ", _pth_mkup_src_in); - } - } - } + 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_or_pod) { + fn_src_in.copy(fn_src_out_filesystem); + } + if (doc_matters.opt.action.pod) { + zip = podArchive("file_path_text", fn_src_in, fn_src_out_pod_zip_base, zip); } } else { - 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_or_pod) { - 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_pod - && doc_matters.opt.action.vox_gt1) { - writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); - } + if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { + writeln("WARNING (io) src out NOT found (insert file): ", fn_src_in); } } } } - } { - auto fn_src_in = doc_matters.src.filename; - if (doc_matters.opt.action.pod) { - if (exists(doc_matters.src.file_with_absolute_path)) { - createZipFile!()(fn_pod, zip.build()); - } else { - writeln("WARNING check missing source file(s): ", doc_matters.opt.action.pod); - } - if (!(exists(fn_pod))) { - writeln("WARNING failed to create pod zip archive: ", fn_pod); - } + } + } + { + _st.zip = zip; + _st.fn_pod = fn_pod; + _st.digests = _digests; + } + return _st; + } + @system auto podArchive(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; + } + void zipArchive(M,F,Z)(M doc_matters, F fn_pod, Z zip) { + auto fn_src_in = doc_matters.src.filename; + if (doc_matters.opt.action.pod) { + if (exists(doc_matters.src.file_with_absolute_path)) { + try { + createZipFile!()(fn_pod, zip.build()); + } catch (ErrnoException ex) { + // Handle errors } + } else { writeln("WARNING check missing source file(s): ", doc_matters.opt.action.pod); } + if (!(exists(fn_pod))) { writeln("WARNING failed to create pod zip archive: ", fn_pod); } + } + } + void zipArchiveDigest(M,F,D)(M doc_matters, F fn_pod, D _digests) { + import sisudoc.io_out.paths_output; + auto pths_pod = spinePathsPods!()(doc_matters); + char[] _zip_digest; + try { + if (!exists(pths_pod.pod_dir_())) { + // used both by pod zipped (& pod filesystem (unzipped) which makes its own recursive dirs) + pths_pod.pod_dir_().mkdirRecurse; } + } catch (ErrnoException ex) { + // Handle error + } + try { + // if (doc_matters.opt.action.vox_gt1) { writeln(" ", pths_pod.pod_dir_(), "/", doc_matters.src.filename_base, ".digests.txt"); } + string _digest_fn = pths_pod.pod_dir_() ~ "/" ~ doc_matters.src.filename_base ~ ".digests.txt"; + // if (doc_matters.opt.action.vox_gt1) { writeln(_digest_fn); } + auto f = File(_digest_fn, "w"); if (exists(fn_pod)) { try { - if (doc_matters.opt.action.vox_gt0 - && doc_matters.opt.action.pod) { - auto data = (cast(byte[]) (fn_pod).read); - if (doc_matters.opt.action.vox_gt1) { - writeln(" ", doc_matters.src.filename, " > "); - } - if (doc_matters.opt.action.pod) { - writefln("%s\n. %-(%02x%)::%s . %s.zip", fn_pod, data.sha256Of, data.length, doc_matters.src.filename_base); - } - } - if (doc_matters.opt.action.debug_do_pod) { - try { - auto zipped = new ZipArchive((fn_pod).read); - foreach (filename, member; zipped.directory) { - auto data = zipped.expand(member); - writeln(". ", ((data).sha256Of).toHexString, "::", data.length, " . ", filename); - } - } catch (ZipException ex) { - // Handle errors - } + auto data = (cast(byte[]) (fn_pod).read); + // if (doc_matters.opt.action.vox_gt1) { writeln(" ", doc_matters.src.filename, " > ", doc_matters.src.filename_base, ".zip"); } + if (doc_matters.opt.action.pod) { + _zip_digest = (data.sha256Of.toHexString ~ "::" ~ data.length.to!string ~ " - " ~ doc_matters.src.filename_base ~ ".zip"); + if (doc_matters.opt.action.vox_gt0) { writeln(" ", _zip_digest); } + if (doc_matters.opt.action.vox_gt0) { writeln(" ", pths_pod.pod_dir_(), "/", doc_matters.src.filename_base, "/"); } + if (doc_matters.opt.action.vox_gt0) { writeln(" ", _digest_fn); } + f.writeln(_zip_digest); } } catch (ErrnoException ex) { // Handle errors } } - // source pod zip + foreach (_lang; doc_matters.pod.manifest_list_of_languages) { + if (_lang in _digests) { + if (("sstm" in _digests[_lang]) && (_digests[_lang]["sstm"].length > 0)) { + // if (doc_matters.opt.action.vox_gt1) { writeln(_digests[_lang]["sstm"]); } + f.writeln(_digests[_lang]["sstm"]); + } + if (("ssi" in _digests[_lang]) && (_digests[_lang]["ssi"].length > 0)) { + // if (doc_matters.opt.action.vox_gt1) { writeln(_digests[_lang]["ssi"]); } + f.writeln(_digests[_lang]["ssi"]); + } + } + } + if ("shared" in _digests) { + if (("images" in _digests["shared"]) && (_digests["shared"]["images"].length > 0)) { + // if (doc_matters.opt.action.vox_gt1) { writeln(_digests["shared"]["images"]); } + f.writeln(_digests["shared"]["images"]); + } + } } catch (ErrnoException ex) { // Handle error } diff --git a/src/sisudoc/meta/metadoc.d b/src/sisudoc/meta/metadoc.d index a1899da..25f28b6 100644 --- a/src/sisudoc/meta/metadoc.d +++ b/src/sisudoc/meta/metadoc.d @@ -51,7 +51,9 @@ module sisudoc.meta.metadoc; @safe: template spineAbstraction() { import - std.datetime; + std.datetime, + std.digest.crc, + std.digest.sha; import sisudoc.meta, sisudoc.meta.metadoc_from_src, @@ -64,7 +66,6 @@ template spineAbstraction() { sisudoc.io_out.hub; mixin spineBiblio; mixin outputHub; - enum headBody { header, body_content, insert_file_list, image_list } enum makeMeta { make, meta } enum docAbst { doc_abstract_obj, doc_has } @system auto spineAbstraction(E,P,O,Cfg,M,S)( @@ -89,7 +90,7 @@ template spineAbstraction() { } auto _header_body_insertfilelist_imagelist = spineRawMarkupContent!()(_opt_action, _manifest.src.path_and_fn); - static assert(_header_body_insertfilelist_imagelist.length==4); + auto doc_digests = _header_body_insertfilelist_imagelist.doc_digest; // CHECK, REVIEW, discard likely, other route taken if ((_opt_action.debug_do) || (_opt_action.debug_do_stages) ) { @@ -98,7 +99,7 @@ template spineAbstraction() { debug(header_and_body) { writeln(header); writeln(_header_body_insertfilelist_imagelist.length); - writeln(_header_body_insertfilelist_imagelist.length[headBody.body_content][0]); + // writeln(_header_body_insertfilelist_imagelist.length.body_content[0]); } /+ ↓ split header into make and meta +/ if ((_opt_action.debug_do) @@ -109,7 +110,7 @@ template spineAbstraction() { import sisudoc.meta.conf_make_meta_yaml; _make_and_meta_struct = docHeaderMakeAndMetaTupYamlExtractAndConvertToStruct!()( - _header_body_insertfilelist_imagelist[headBody.header], + _header_body_insertfilelist_imagelist.header_raw, _make_and_meta_struct, _manifest, _opt_action, @@ -127,7 +128,7 @@ template spineAbstraction() { writeln("step3 commence → (document abstraction (da); da keys; segnames; doc_matters) [", _manifest.src.filename, "]"); } auto da = docAbstraction!()( - _header_body_insertfilelist_imagelist[headBody.body_content], + _header_body_insertfilelist_imagelist.sourcefile_body_content, _make_and_meta_struct, _opt_action, _manifest, @@ -145,7 +146,7 @@ template spineAbstraction() { ) { writeln("step4 commence → (doc_matters) [", _manifest.src.filename, "]"); } - struct DocumentMatters { + struct ST_DocumentMatters { auto generator_program() { struct Prog_ { string project_name() { @@ -192,6 +193,9 @@ template spineAbstraction() { auto conf_make_meta() { return _make_and_meta_struct; } + auto doc_digest() { + return doc_digests; + } auto has() { return _doc_has_struct; } @@ -275,7 +279,7 @@ template spineAbstraction() { auto srcs() { struct SRC_ { auto file_insert_list() { - return _header_body_insertfilelist_imagelist[headBody.insert_file_list]; + return _header_body_insertfilelist_imagelist.insert_file_list; } auto image_list() { return _doc_has_struct.imagelist; @@ -284,7 +288,7 @@ template spineAbstraction() { return SRC_(); } } - auto doc_matters = DocumentMatters(); + auto doc_matters = ST_DocumentMatters(); if ((_opt_action.debug_do) || (_opt_action.debug_do_stages) ) { diff --git a/src/sisudoc/meta/metadoc_from_src.d b/src/sisudoc/meta/metadoc_from_src.d index 32954f1..70fec62 100644 --- a/src/sisudoc/meta/metadoc_from_src.d +++ b/src/sisudoc/meta/metadoc_from_src.d @@ -57,6 +57,7 @@ template docAbstraction() { import std.algorithm, std.container, + std.digest.sha, std.file, std.json, std.path; @@ -970,8 +971,7 @@ template docAbstraction() { } obj = _links(obj); } - if (the_document_toc_section.length > 1) { - // scroll + if (the_document_toc_section.length > 1) { // writeln("toc"); // scroll dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_document_toc_section) { @@ -997,7 +997,7 @@ template docAbstraction() { // images string[] _images; // multiple 1~ levels, loop through document body - if (the_document_body_section.length > 1) { + if (the_document_body_section.length > 1) { // writeln("body"); foreach (ref obj; the_document_body_section) { if (!(obj.metainfo.identifier.empty)) { if (!(((obj.metainfo.identifier) in tag_assoc) @@ -1033,12 +1033,13 @@ template docAbstraction() { _images ~= extract_images(obj.text); obj = _image_dimensions(obj, manifested); } + obj.metainfo.sha256 = obj.obj_digest; obj = _links(obj); } } auto image_list = (_images.sort()).uniq; // endnotes optional only one 1~ level - if (the_document_endnotes_section.length > 1) { + if (the_document_endnotes_section.length > 1) { // writeln("endnotes"); dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; dom_structure_markedup_tags_status = dom_structure_markedup_tags_status_buffer.dup; @@ -1073,7 +1074,7 @@ template docAbstraction() { } } // glossary optional only one 1~ level - if (the_document_glossary_section.length > 1) { + if (the_document_glossary_section.length > 1) { // writeln("glossary"); foreach (ref obj; the_document_glossary_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); } @@ -1104,11 +1105,12 @@ template docAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; } + obj.metainfo.sha256 = obj.obj_digest; obj = _links(obj); } } // bibliography optional only one 1~ level - if (the_document_bibliography_section.length > 1) { + if (the_document_bibliography_section.length > 1) { // writeln("bibliography"); foreach (ref obj; the_document_bibliography_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); } @@ -1139,6 +1141,7 @@ template docAbstraction() { obj.metainfo.ocn = obj_cite_digits.object_number; obj.metainfo.identifier = obj_cite_digits.identifier; } + obj.metainfo.sha256 = obj.obj_digest; obj = _links(obj); } } @@ -1146,7 +1149,7 @@ template docAbstraction() { int ocn_ = obj_cite_digits.object_number; int ocn_bkidx_ = 0; int ocn_bidx_; - if (the_document_bookindex_section.length > 1) { // scroll + if (the_document_bookindex_section.length > 1) { // writeln("book index"); // scroll dom_structure_markedup_tags_status_buffer = dom_structure_markedup_tags_status.dup; dom_structure_collapsed_tags_status_buffer = dom_structure_collapsed_tags_status.dup; foreach (ref obj; the_document_bookindex_section) { @@ -1183,13 +1186,14 @@ template docAbstraction() { obj.metainfo.o_n_book_index = obj_cite_digits.bkidx; obj.metainfo.object_number_type = OCNtype.bkidx; } + obj.metainfo.sha256 = obj.obj_digest; obj = _links(obj); } // TODO assert failure, reinstate // assert(obj_cite_digit_bkidx == ocn_bidx_ obj_cite_digit_bkidx ~ " == ocn_" ~ ocn_ ~ "?"); } // blurb optional only one 1~ level - if (the_document_blurb_section.length > 1) { + if (the_document_blurb_section.length > 1) { // writeln("blurb"); foreach (ref obj; the_document_blurb_section) { if (obj.metainfo.is_a == "heading") { debug(dom) { writeln(obj.text); } @@ -1220,6 +1224,7 @@ template docAbstraction() { obj.metainfo.object_number_off = obj_cite_digits.off; obj.metainfo.object_number_type = OCNtype.non; } + obj.metainfo.sha256 = obj.obj_digest; obj = _links(obj); } } diff --git a/src/sisudoc/meta/metadoc_from_src_functions.d b/src/sisudoc/meta/metadoc_from_src_functions.d index 29e675c..953e75a 100644 --- a/src/sisudoc/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/meta/metadoc_from_src_functions.d @@ -54,18 +54,6 @@ module sisudoc.meta.metadoc_from_src_functions; @safe: template docAbstractionFunctions() { // ↓ abstraction imports - import - std.algorithm, - std.container, - std.file, - std.json, - std.path; - import - sisudoc.meta, - sisudoc.meta.defaults, - sisudoc.meta.rgx, - sisudoc.meta.metadoc_object_setter, - sisudoc.meta.rgx; // ↓ abstraction mixins mixin ObjectSetter; mixin InternalMarkup; @@ -2998,6 +2986,14 @@ template docAbstractionFunctions() { return obj; } // ↑ - object tags + // ↓ - object digest + pure ubyte[32] obj_digest()( + ObjGenericComposite obj, + ) { + obj.metainfo.sha256 = obj.text.sha256Of; + return obj.metainfo.sha256; + } + // ↑ - object digest // ↓ - table of contents @system ObjGenericComposite[] backmatter_gather_table_of_contents( ObjGenericComposite[] the_document_endnotes_section, diff --git a/src/sisudoc/meta/metadoc_object_setter.d b/src/sisudoc/meta/metadoc_object_setter.d index a2ceff6..8b2daf0 100644 --- a/src/sisudoc/meta/metadoc_object_setter.d +++ b/src/sisudoc/meta/metadoc_object_setter.d @@ -173,6 +173,7 @@ template ObjectSetter() { int parent_lev_markup = 0; int parent_ocn = 0; int last_descendant_ocn = 0; + ubyte[32] sha256; } struct ObjGenericComposite { string text = ""; diff --git a/src/sisudoc/meta/metadoc_show_config.d b/src/sisudoc/meta/metadoc_show_config.d index 8a6af5d..76a0394 100644 --- a/src/sisudoc/meta/metadoc_show_config.d +++ b/src/sisudoc/meta/metadoc_show_config.d @@ -59,6 +59,8 @@ template spineShowSiteConfig() { sisudoc.meta.rgx; import std.array, + std.digest.crc, + std.digest.sha, std.exception, std.regex, std.stdio, @@ -145,6 +147,8 @@ template spineShowConfig() { sisudoc.meta.rgx; import std.array, + std.digest.crc, + std.digest.sha, std.exception, std.regex, std.stdio, diff --git a/src/sisudoc/meta/metadoc_show_make.d b/src/sisudoc/meta/metadoc_show_make.d index 817f5dc..ddbb687 100644 --- a/src/sisudoc/meta/metadoc_show_make.d +++ b/src/sisudoc/meta/metadoc_show_make.d @@ -58,6 +58,8 @@ template spineShowMake() { sisudoc.meta.rgx; import std.array, + std.digest.crc, + std.digest.sha, std.exception, std.regex, std.stdio, diff --git a/src/sisudoc/meta/metadoc_show_metadata.d b/src/sisudoc/meta/metadoc_show_metadata.d index 320f28b..31ff1ea 100644 --- a/src/sisudoc/meta/metadoc_show_metadata.d +++ b/src/sisudoc/meta/metadoc_show_metadata.d @@ -58,6 +58,8 @@ template spineShowMetaData() { sisudoc.meta.rgx; import std.array, + std.digest.crc, + std.digest.sha, std.exception, std.regex, std.stdio, diff --git a/src/sisudoc/meta/metadoc_show_summary.d b/src/sisudoc/meta/metadoc_show_summary.d index 379a1a7..92d476c 100644 --- a/src/sisudoc/meta/metadoc_show_summary.d +++ b/src/sisudoc/meta/metadoc_show_summary.d @@ -59,6 +59,8 @@ template spineMetaDocSummary() { sisudoc.meta.rgx; import std.array, + std.digest.crc, + std.digest.sha, std.exception, std.regex, std.stdio, @@ -102,13 +104,17 @@ template spineMetaDocSummary() { } } writefln( - "%s\n\"%s\", %s\n%s [%s]\n%s\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%s", + "%s\n\"%s\", %s\n%s [%s]\n%s \n%s - %s [%s]\n%s\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%40-s%10-d\n%s", markup.repeat_character_by_number_provided("-", char_repeat_number), doc_matters.conf_make_meta.meta.title_full, doc_matters.conf_make_meta.meta.creator_author, doc_matters.src.filename, doc_matters.src.language, markup.repeat_character_by_number_provided("-", char_repeat_number), + doc_matters.doc_digest.markup_doc.toHexString, + doc_matters.src.filename, + doc_matters.src.language, + markup.repeat_character_by_number_provided("-", char_repeat_number), "- toc arr length:", to!int(doc_abstraction["toc"].length), "- doc_abstraction arr length:", diff --git a/src/sisudoc/spine.d b/src/sisudoc/spine.d index b79bc54..39563fb 100755 --- a/src/sisudoc/spine.d +++ b/src/sisudoc/spine.d @@ -656,11 +656,19 @@ string program_name = "spine"; bool _is; if (opts["serial"] == true) { _is = false; - } else if (sqlite_shared_db_action) { + } else if ( + sqlite_shared_db_action + || source_or_pod + ) { _is = false; } else if (opts["parallel"] == true) { _is = true; - if (sqlite_shared_db_action) { _is = false; } + if ( + sqlite_shared_db_action + || source_or_pod + ) { + _is = false; + } } else if ( opts["abstraction"] || concordance @@ -670,7 +678,6 @@ string program_name = "spine"; || odt || latex || manifest - || source_or_pod || sqlite_discrete ) { _is = true; @@ -1030,12 +1037,7 @@ string program_name = "spine"; foreach(manifest; parallel(_manifests[1..$])) { if (!empty(manifest.src.filename)) { scope(success) { - if (_opt_action.vox_gt0) { - writefln( - "%s", - "-- ~ document complete, ok ~ ------------------------------------", - ); - } + if (_opt_action.vox_gt0) { writeln("-- ~ document complete, ok ~ ------------------------------------"); } } scope(failure) { debug(checkdoc) { @@ -1138,17 +1140,10 @@ string program_name = "spine"; } } else { // note cannot parallelise sqlite shared db foreach(manifest; _manifests[1..$]) { - if (_opt_action.vox_gt2) { - writeln("parallelisation off: actions include sqlite shared db"); - } + if (_opt_action.vox_gt2) { writeln("parallelisation off: actions include sqlite shared db"); } if (!empty(manifest.src.filename)) { scope(success) { - if (_opt_action.vox_gt0) { - writefln( - "%s", - "-- ~ document complete, ok ~ ------------------------------------", - ); - } + if (_opt_action.vox_gt0) { writeln("-- ~ document complete, ok ~ ------------------------------------"); } } scope(failure) { debug(checkdoc) { |