diff options
| author | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-25 22:56:24 -0400 |
|---|---|---|
| committer | Ralph Amissah <ralph.amissah@gmail.com> | 2026-08-26 15:40:12 -0400 |
| commit | 5d9750a5651cdb230e7b781336958a7620c73dfd (patch) | |
| tree | 5a4b3494dc9f417ffbed954627c427d2cf98d45c /src/sisudoc | |
| parent | ldc-v1.43.0-beta1 ok (diff) | |
sha summary, mostly cosmetic, some work on images
Diffstat (limited to 'src/sisudoc')
| -rw-r--r-- | src/sisudoc/ocda/abstraction/ssp.d | 2 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src.d | 11 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_from_src_functions.d | 26 | ||||
| -rw-r--r-- | src/sisudoc/ocda/meta/metadoc_object_setter.d | 7 |
4 files changed, 34 insertions, 12 deletions
diff --git a/src/sisudoc/ocda/abstraction/ssp.d b/src/sisudoc/ocda/abstraction/ssp.d index a2135df..4f9dd45 100644 --- a/src/sisudoc/ocda/abstraction/ssp.d +++ b/src/sisudoc/ocda/abstraction/ssp.d @@ -295,7 +295,7 @@ template spineAbstractionTxt() { if (b != 0) { has_sha = true; break; } } if (has_sha) { - if (doc_matters.opt.action.vox_gt_2) { + if (doc_matters.opt.action.vox_gt_3) { writeln(obj.metainfo.sha256.summary); // USE check } output ~= ".sha256: " ~ obj.metainfo.sha256.text.toHexString.to!string; diff --git a/src/sisudoc/ocda/meta/metadoc_from_src.d b/src/sisudoc/ocda/meta/metadoc_from_src.d index d41701c..dcdc239 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src.d @@ -1352,6 +1352,17 @@ template docAbstraction() { obj.metainfo.children_headings = heading_children[obj.metainfo.ocn]; } } + // if (opt_action.vox_gt_2) { + // foreach (section; [the_document_head_section, the_document_body_section, the_document_bookindex_section, the_document_bibliography_section, the_document_glossary_section, the_document_blurb_section]) { + // foreach (obj; section) { + // if (section.length > 0) { + // if (obj.metainfo.sha256.summary.length > 0) { + // writeln(obj.metainfo.sha256.summary); + // } + // } + // } + // } + // } } // TODO // - note create/insert heading object sole purpose eof close all open tags diff --git a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d index 3bd9292..791c002 100644 --- a/src/sisudoc/ocda/meta/metadoc_from_src_functions.d +++ b/src/sisudoc/ocda/meta/metadoc_from_src_functions.d @@ -112,7 +112,7 @@ template docAbstractionFunctions() { ocn_is_off = false; switch(ocn_status_flag) with (eN.ocn) { case reset: - ocn_digit = ocn_on_ = 1; + ocn_digit = ocn_on_ = 1; object_identifier = "1"; ocn_is_off = false; ocn_off_ = ocn_bkidx_ = 0; @@ -3189,10 +3189,16 @@ template docAbstractionFunctions() { ObjGenericComposite obj, M manifested, ) { - ubyte[32] safeComputeHash(H)(H file_with_path) @trusted { + ST_file_name_hash_size_ safeComputeHashAndSize(N,P)(N filename, P file_path) @trusted { + auto file_with_path = file_path ~ filename; auto file_read = File(file_with_path, "r"); ubyte[32] file_sha256 = digest!SHA256(file_read.byChunk(4096 * 1024)); - return file_sha256; + ulong fileSize = file_read.size; + ST_file_name_hash_size_ _file_info; + _file_info.fileHash_sha256 = file_sha256; + _file_info.fileSize = fileSize; + _file_info.fileName = filename; + return _file_info; } obj.metainfo.sha256.text = obj.text.sha256Of; string image_with_path; @@ -3201,7 +3207,7 @@ template docAbstractionFunctions() { int n = 0; if (obj.metainfo.is_a == "heading") { obj.metainfo.sha256.summary ~= - obj.metainfo.sha256.text.toHexString ~ " " + "• - " ~ obj.metainfo.sha256.text.toHexString ~ " " ~ obj.metainfo.ocn.to!string ~ " " ~ obj.metainfo.is_a ~ " " ~ obj.metainfo.marked_up_level ~ "~ " @@ -3211,23 +3217,23 @@ template docAbstractionFunctions() { if ((obj.text).match(rgx.inline_image)) { foreach (m; (obj.text).matchAll(rgx.inline_image)) { image_with_path = image_path ~ m["img"]; - ubyte[32] image_sha256 = safeComputeHash(image_with_path); - obj.metainfo.sha256.images = [ m["img"] : image_sha256 ]; + ST_file_name_hash_size_ _file_info = safeComputeHashAndSize(m["img"], image_path); + obj.metainfo.sha256.images ~= [_file_info]; } } char[] image_summary; if (obj.metainfo.sha256.images.length > 0) { - foreach (i,h; obj.metainfo.sha256.images) { - // writeln(h.toHexString.to!string, " - ", i); - image_summary ~= "\n" ~ h.toHexString.to!string ~ " - " ~ i; + foreach (i; obj.metainfo.sha256.images) { + image_summary ~= "\n - " ~ i.fileHash_sha256.toHexString ~ "::" ~ i.fileSize.to!string ~ " - " ~ i.fileName; } } obj.metainfo.sha256.summary ~= - obj.metainfo.sha256.text.toHexString + " - " ~ obj.metainfo.sha256.text.toHexString ~ " " ~ obj.metainfo.ocn.to!string ~ " " ~ obj.metainfo.is_a ~ image_summary; } + // writeln(obj.metainfo.sha256.summary); // WRONG DEBUG REMOVE return obj.metainfo.sha256; } // ↑ - object digest diff --git a/src/sisudoc/ocda/meta/metadoc_object_setter.d b/src/sisudoc/ocda/meta/metadoc_object_setter.d index 718ce55..7abde64 100644 --- a/src/sisudoc/ocda/meta/metadoc_object_setter.d +++ b/src/sisudoc/ocda/meta/metadoc_object_setter.d @@ -101,10 +101,15 @@ template ObjectSetter() { string[] lev4_subtoc = []; string[] anchor_tags = []; } + struct ST_file_name_hash_size_ { + string fileName; + ubyte[32] fileHash_sha256; + ulong fileSize; + } struct SHA_256_Hashes_ { char[] summary; ubyte[32] text; // both text and inline footnotes; consider additionally separating text and footnotes - ubyte[32][string] images; + ST_file_name_hash_size_[] images; // filename, filesize } struct DocObj_MetaInfo_ { string is_of_part = ""; // frontmatter, body, backmatter |
