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 /org | |
| parent | ldc-v1.43.0-beta1 ok (diff) | |
sha summary, mostly cosmetic, some work on images
Diffstat (limited to 'org')
| -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 |
4 files changed, 41 insertions, 18 deletions
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; } |
