diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-24 11:14:38 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-01 07:06:04 -0300 |
commit | a6e2493f13636f8586fd177dd493812bbcb09dbd (patch) | |
tree | ab768b6141db5ed40626f9427b378ac03a1cf299 | |
parent | 06fd68f0305c11d450f2c97fddac88056b8bfc6b (diff) |
data, yaml: basic who/what -> artist/annotation
-rw-r--r-- | src/data/composite/wiki-data/withResolvedContribs.js | 22 | ||||
-rw-r--r-- | src/data/composite/wiki-data/withReverseContributionList.js | 4 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/contributionList.js | 10 | ||||
-rw-r--r-- | src/data/validators.js | 4 | ||||
-rw-r--r-- | src/data/yaml.js | 15 |
5 files changed, 33 insertions, 22 deletions
diff --git a/src/data/composite/wiki-data/withResolvedContribs.js b/src/data/composite/wiki-data/withResolvedContribs.js index 77b0f96d..95266382 100644 --- a/src/data/composite/wiki-data/withResolvedContribs.js +++ b/src/data/composite/wiki-data/withResolvedContribs.js @@ -1,7 +1,8 @@ // Resolves the contribsByRef contained in the provided dependency, // providing (named by the second argument) the result. "Resolving" -// means mapping the "who" reference of each contribution to an artist -// object, and filtering out those whose "who" doesn't match any artist. +// means mapping the artist reference of each contribution to an artist +// object, and filtering out those whose artist reference doesn't match +// any artist. import {input, templateCompositeFrom} from '#composite'; import find from '#find'; @@ -46,29 +47,30 @@ export default templateCompositeFrom({ withPropertiesFromList({ list: input('from'), - properties: input.value(['who', 'what']), + properties: input.value(['artist', 'annotation']), prefix: input.value('#contribs'), }), withResolvedReferenceList({ - list: '#contribs.who', + list: '#contribs.artist', data: 'artistData', find: input.value(find.artist), notFoundMode: input('notFoundMode'), }).outputs({ - ['#resolvedReferenceList']: '#contribs.who', + ['#resolvedReferenceList']: '#contribs.artist', }), { - dependencies: ['#contribs.who', '#contribs.what'], + dependencies: ['#contribs.artist', '#contribs.annotation'], compute(continuation, { - ['#contribs.who']: who, - ['#contribs.what']: what, + ['#contribs.artist']: artist, + ['#contribs.annotation']: annotation, }) { - filterMultipleArrays(who, what, (who, _what) => who); + filterMultipleArrays(artist, annotation, (artist, _annotation) => artist); return continuation({ - ['#resolvedContribs']: stitchArrays({who, what}), + ['#resolvedContribs']: + stitchArrays({artist, annotation}), }); }, }, diff --git a/src/data/composite/wiki-data/withReverseContributionList.js b/src/data/composite/wiki-data/withReverseContributionList.js index eccb58b7..c5dcad07 100644 --- a/src/data/composite/wiki-data/withReverseContributionList.js +++ b/src/data/composite/wiki-data/withReverseContributionList.js @@ -58,10 +58,10 @@ export default templateCompositeFrom({ for (const referencingThing of data) { const referenceList = referencingThing[list]; - // Destructuring {who} is the only unique part of the + // Destructuring {artist} is the only unique part of the // withReverseContributionList implementation, compared to // withReverseReferneceList. - for (const {who: referencedThing} of referenceList) { + for (const {artist: referencedThing} of referenceList) { if (cacheRecord.has(referencedThing)) { cacheRecord.get(referencedThing).push(referencingThing); } else { diff --git a/src/data/composite/wiki-properties/contributionList.js b/src/data/composite/wiki-properties/contributionList.js index 8fde2caa..aad12a2d 100644 --- a/src/data/composite/wiki-properties/contributionList.js +++ b/src/data/composite/wiki-properties/contributionList.js @@ -3,15 +3,15 @@ // into one property. Update value will look something like this: // // [ -// {who: 'Artist Name', what: 'Viola'}, -// {who: 'artist:john-cena', what: null}, +// {artist: 'Artist Name', annotation: 'Viola'}, +// {artist: 'artist:john-cena', annotation: null}, // ... // ] // // ...typically as processed from YAML, spreadsheet, or elsewhere. -// Exposes as the same, but with the "who" replaced with matches found in -// artistData - which means this always depends on an `artistData` property -// also existing on this object! +// Exposes as the same, but with the artist property replaced with matches +// found in artistData - which means this always depends on an `artistData` +// property also existing on this object! // import {input, templateCompositeFrom} from '#composite'; diff --git a/src/data/validators.js b/src/data/validators.js index 987f806d..e3e56122 100644 --- a/src/data/validators.js +++ b/src/data/validators.js @@ -614,8 +614,8 @@ export function isThingClass(thingClass) { } export const isContribution = validateProperties({ - who: isArtistRef, - what: optional(isStringNonEmpty), + artist: isArtistRef, + annotation: optional(isStringNonEmpty), }); export const isContributionList = validateArrayItems(isContribution); diff --git a/src/data/yaml.js b/src/data/yaml.js index 86f30143..5026a97e 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -393,7 +393,16 @@ export function parseContributors(contributionStrings) { return contributionStrings.map(item => { if (typeof item === 'object' && item['Who']) - return {who: item['Who'], what: item['What'] ?? null}; + return { + artist: item['Who'], + annotation: item['What'] ?? null, + }; + + if (typeof item === 'object' && item['Artist']) + return { + artist: item['Artist'], + annotation: item['Annotation'] ?? null, + }; if (typeof item !== 'string') return item; @@ -401,8 +410,8 @@ export function parseContributors(contributionStrings) { if (!match) return item; return { - who: match.groups.main, - what: match.groups.accent ?? null, + artist: match.groups.main, + annotation: match.groups.accent ?? null, }; }); } |