aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sisudoc/ocda
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2026-09-08 16:09:44 -0400
committerRalph Amissah <ralph.amissah@gmail.com>2026-09-09 18:28:25 -0400
commitc16ada7749d842fa868b7b8b25a1ff17ffdf7b40 (patch)
tree8a4d4460d4572af5590302d5c927e8ed66b689ae /src/sisudoc/ocda
parentocda loader: one way in whatever the source (diff)
output: the abstraction artefacts live with the pod
pod/ holds all document source representations: pod/<doc>/ source tree pod/<doc>/media/abstraction/<uid>.ssp abstraction, as text pod/<doc>.zip tree, zipped, .ssp included pod/<doc>.digests.txt sha256s of what is in them pod/<uid>.ocda.db abstraction, as sqlite db <lang>/abstraction/ is gone. pod/<doc>/media/abstraction/<uid>.ssp preferred as having the images (found within the pod tree) which .ssp needs to reproduce a document but does not carry on its own. The .ocda.db sits carries the images as well and (like the pod.zip) can be used to reproduce a document directly. digests.txt now covers the database as well as the zip, the source and the .ssp; (as does the metadata html page). Two ordering issues addressed: - the pod builder clean-slates pod/<doc>/ before regenerating it, and the .ssp is now written before that runs. The clean slate now leaves media/abstraction/ alone, and the .ssp writer clears that directory itself on the first language of a run, so a .ssp for a language the document no longer is removed and cannot be bundled. - for a multi-language document the .ssp files accumulate one language at a time and are bundled on the last, which is why the directory cannot simply be emptied by whichever (language) gets there first. (assisted by Claude-Code)
Diffstat (limited to 'src/sisudoc/ocda')
-rw-r--r--src/sisudoc/ocda/abstraction/ssp.d33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/sisudoc/ocda/abstraction/ssp.d b/src/sisudoc/ocda/abstraction/ssp.d
index 3e80956..2501add 100644
--- a/src/sisudoc/ocda/abstraction/ssp.d
+++ b/src/sisudoc/ocda/abstraction/ssp.d
@@ -102,6 +102,7 @@ template sspObjectRecord() {
import std.stdio;
import std.string;
import std.array;
+ import sisudoc.ocda.io_in.paths_source;
mixin sspEscape;
string[] sspObjectRecord(O)(O obj, string section, bool _vox = false) {
string[] output;
@@ -413,6 +414,7 @@ template spineAbstractionTxt() {
import std.stdio;
import std.string;
import std.array;
+ import sisudoc.ocda.io_in.paths_source;
mixin sspObjectRecord;
/+ ↓ the whole .ssp for a document, as lines. the file writer below emits
these, and the abstraction db is built by reading them back, so the
@@ -562,19 +564,34 @@ template spineAbstractionTxt() {
}
return output;
}
- void spineAbstractionTxt(D)(D doc) {
+ @trusted void spineAbstractionTxt(D)(D doc) {
auto doc_matters = doc.matters;
string[] output = sspDocumentLines(doc);
- /+ ↓ write to file +/
- /+ path: <output_path>/<language>/abstraction/<doc_uid_out>.ssp +/
- string out_root = (doc_matters.output_path.length > 0)
- ? doc_matters.output_path : "";
- string base_pth = (out_root
- .chainPath(doc_matters.src.language, "abstraction")
- .asNormalizedPath).array;
+ /+ ↓ write to file, into the pod's own tree:
+ pod/<doc>/media/abstraction/<doc_uid_out>.ssp
+ .
+ where it sits beside pod/<doc>/media/image/, which is what a .ssp
+ needs to be a document source: the file describes its images by
+ name, size, pixels and digest, and they have to be findable. Written
+ here once; --pod2 then digests and zips it where it stands rather
+ than copying it in from an output directory of its own.
+ +/
+ auto pths_pod = spinePathsPods!()(doc_matters);
+ string base_pth
+ = pths_pod.abstraction_root(doc_matters.src.filename).filesystem_open_zpod.to!string;
try {
if (!exists(base_pth)) {
base_pth.mkdirRecurse;
+ } else if (doc_matters.src.language
+ == doc_matters.pod.manifest_list_of_languages[0]
+ ) {
+ /+ ↓ this directory is the one part of the pod written before the pod
+ is built, so the pod builder leaves it alone. It therefore clears
+ itself here, on the first language of a run, or a .ssp for a
+ language the document no longer has would linger and be bundled +/
+ foreach (string _f; dirEntries(base_pth, "*.ssp", SpanMode.shallow)) {
+ _f.remove;
+ }
}
} catch (Exception ex) {
}