« get me outta code hell

data: CommentaryEntry - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/yaml.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-04-14 20:59:17 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-14 21:35:13 -0300
commit7342b35d0da518fa5559dadc3239fd574a105432 (patch)
treea17ec409c03b6ab1a01c2f4cc2ec8ef2f8f85d4b /src/data/yaml.js
parent6d811c36d2b9795ad58fd0bf11f6033d93863fed (diff)
data: CommentaryEntry
Fully integrated, all in one commit! Wow!
Diffstat (limited to 'src/data/yaml.js')
-rw-r--r--src/data/yaml.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 50317238..e6b3fa71 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -11,6 +11,7 @@ import {colors, ENABLE_COLOR, logInfo, logWarn} from '#cli';
 import {sortByName} from '#sort';
 import Thing from '#thing';
 import thingConstructors from '#things';
+import {matchCommentaryEntries} from '#wiki-data';
 
 import {
   aggregateThrows,
@@ -824,6 +825,55 @@ export function parseArtwork({
   return transform;
 }
 
+export function parseCommentary(sourceText, {subdoc, CommentaryEntry}) {
+  const map = matchEntry => ({
+    'Artists':
+      matchEntry.artistReferences
+        .split(',')
+        .map(ref => ref.trim()),
+
+    'Artist Text':
+      matchEntry.artistDisplayText,
+
+    'Annotation':
+      matchEntry.annotation,
+
+    'Date':
+      matchEntry.date,
+
+    'Second Date':
+      matchEntry.secondDate,
+
+    'Date Kind':
+      matchEntry.dateKind,
+
+    'Access Date':
+      matchEntry.accessDate,
+
+    'Access Kind':
+      matchEntry.accessKind,
+
+    'Body':
+      matchEntry.body,
+  });
+
+  const documents =
+    matchCommentaryEntries(sourceText)
+      .map(matchEntry =>
+        withEntries(
+          map(matchEntry),
+          entries => entries
+            .filter(([key, value]) =>
+              value !== undefined &&
+              value !== null)));
+
+  const subdocs =
+    documents.map(document =>
+      subdoc(CommentaryEntry, document, {bindInto: 'thing'}));
+
+  return subdocs;
+}
+
 // documentModes: Symbols indicating sets of behavior for loading and processing
 // data files.
 export const documentModes = {
@@ -1499,6 +1549,10 @@ export function linkWikiDataArrays(wikiData, {bindFind, bindReverse}) {
 
     ['artworkData', ['artworkData']],
 
+    ['commentaryData', [/* find */]],
+
+    ['creditingSourceData', [/* find */]],
+
     ['flashData', [
       'wikiInfo',
     ]],