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 | |
| parent | ldc-v1.43.0-beta1 ok (diff) | |
sha summary, mostly cosmetic, some work on images
| -rw-r--r-- | flake.lock | 6 | ||||
| -rw-r--r-- | org/ocda.org | 11 | ||||
| -rw-r--r-- | org/ocda_functions.org | 37 | ||||
| -rw-r--r-- | org/ocda_obj_setter.org | 7 | ||||
| -rw-r--r-- | org/out_src_abstraction_ocda_ssp.org | 4 | ||||
| -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 |
9 files changed, 78 insertions, 33 deletions
@@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1785301185, - "narHash": "sha256-eoS3KQTO0aPWXZvIaRbRAzSSHW3l5wdMFXtT1ISfoKA=", + "lastModified": 1787631388, + "narHash": "sha256-vMiXptXarfSdJb1Gkc+FYVOAibuBRj7qxGa8z68q1Uw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9bc02893134c733dd85de46ee4fb2fac696b5529", + "rev": "ac6b2166e7a9375683b8e98f860f273222337b16", "type": "github" }, "original": { diff --git a/org/ocda.org b/org/ocda.org index 5fb42bc..0ae0309 100644 --- a/org/ocda.org +++ b/org/ocda.org @@ -1458,6 +1458,17 @@ if (the_document_body_section.length > 1) { 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/org/ocda_functions.org b/org/ocda_functions.org index 70c688a..37a4f6f 100644 --- a/org/ocda_functions.org +++ b/org/ocda_functions.org @@ -147,7 +147,7 @@ pure struct OCNemitter { 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; @@ -3401,13 +3401,14 @@ pure ObjGenericComposite obj_dom_set_collapsed_tags()( - body text digests - extract image digests - - text body digest - - image digest 1 - - image digest 2 + - object digest (program generated abstract object text body digest) + (programs object hash stamp, abstract source verification available to associate with other generated formats) + - image/filename digest [filesize] 1 - (verification of content of associated external file, document resiliance) + - image/filename digest [filesize] 2 - (verification of content of associated external file, document resiliance) - you may want a "has_images" (do first) - CONSIDER having text body separate from (foot|end)notes - - text body digest + - object digest (program generated abstract object text body digest) - note digest 1 - note digest 2 - currently text body includes inline notes @@ -3415,7 +3416,7 @@ pure ObjGenericComposite obj_dom_set_collapsed_tags()( - notes then could be altered independently of the text, - and it gives a little more insight into document structure, which notes belong to which objects - - but if going this route, some solution related to external links which + - but if going this route, some solution related to external links which may change might be more significant, consider, i think for now keep as is. @@ -3428,10 +3429,16 @@ SHA_256_Hashes_ obj_digest(M)( 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; @@ -3440,7 +3447,7 @@ SHA_256_Hashes_ obj_digest(M)( 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 ~ "~ " @@ -3450,23 +3457,23 @@ SHA_256_Hashes_ obj_digest(M)( 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/org/ocda_obj_setter.org b/org/ocda_obj_setter.org index d26ed4c..f419954 100644 --- a/org/ocda_obj_setter.org +++ b/org/ocda_obj_setter.org @@ -49,10 +49,15 @@ template ObjectSetter() { #+NAME: meta_structs_docObjectMeta #+BEGIN_SRC d +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 diff --git a/org/out_src_abstraction_ocda_ssp.org b/org/out_src_abstraction_ocda_ssp.org index 1683393..32ffdab 100644 --- a/org/out_src_abstraction_ocda_ssp.org +++ b/org/out_src_abstraction_ocda_ssp.org @@ -277,8 +277,8 @@ template spineAbstractionTxt() { if (b != 0) { has_sha = true; break; } } if (has_sha) { - if (doc_matters.opt.action.vox_gt_2) { - writeln(obj.metainfo.sha256.summary); // USE check + if (doc_matters.opt.action.vox_gt_3) { + writeln(obj.metainfo.sha256.summary); } output ~= ".sha256: " ~ obj.metainfo.sha256.text.toHexString.to!string; } 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 |
