From fb319c8e0bf69d9925389edf674de938ea489e25 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 30 Oct 2024 15:45:13 -0300 Subject: data, content: remove shared and inferred additional names Removes: - inferredAdditionalNameList (#composite/things/track) etc - sharedAdditionalNameList (#composite/things/track) etc - "specificAlbumExclusive" / "This Album Only" field - "from" property / "on {ALBUMS}" accent (content) - generateTrackAdditionalNamesBox (no leftover dynamics) - related snapshot test --- .../dependencies/generateAdditionalNamesBoxItem.js | 30 +----- .../generateTrackAdditionalNamesBox.js | 53 ---------- src/content/dependencies/generateTrackInfoPage.js | 4 +- src/data/composite/things/track/index.js | 2 - .../things/track/inferredAdditionalNameList.js | 67 ------------- .../things/track/sharedAdditionalNameList.js | 58 ----------- src/data/things/track.js | 4 - src/data/validators.js | 15 --- src/data/yaml.js | 2 - src/strings-default.yaml | 2 - .../generateTrackAdditionalNamesBox.js.test.cjs | 99 ------------------- test/snapshot/generateTrackAdditionalNamesBox.js | 107 --------------------- 12 files changed, 4 insertions(+), 439 deletions(-) delete mode 100644 src/content/dependencies/generateTrackAdditionalNamesBox.js delete mode 100644 src/data/composite/things/track/inferredAdditionalNameList.js delete mode 100644 src/data/composite/things/track/sharedAdditionalNameList.js delete mode 100644 tap-snapshots/test/snapshot/generateTrackAdditionalNamesBox.js.test.cjs delete mode 100644 test/snapshot/generateTrackAdditionalNamesBox.js diff --git a/src/content/dependencies/generateAdditionalNamesBoxItem.js b/src/content/dependencies/generateAdditionalNamesBoxItem.js index 34c91661..e3e59a34 100644 --- a/src/content/dependencies/generateAdditionalNamesBoxItem.js +++ b/src/content/dependencies/generateAdditionalNamesBoxItem.js @@ -1,7 +1,5 @@ -import {stitchArrays} from '#sugar'; - export default { - contentDependencies: ['linkTrack', 'transformContent'], + contentDependencies: ['transformContent'], extraDependencies: ['html', 'language'], relations: (relation, entry) => ({ @@ -12,21 +10,9 @@ export default { (entry.annotation ? relation('transformContent', entry.annotation) : null), - - trackLinks: - (entry.from - ? entry.from.map(track => relation('linkTrack', track)) - : null), - }), - - data: (entry) => ({ - albumNames: - (entry.from - ? entry.from.map(track => track.album.name) - : null), }), - generate: (data, relations, {html, language}) => { + generate: (relations, {html, language}) => { const prefix = 'misc.additionalNames.item'; const itemParts = [prefix]; @@ -48,18 +34,6 @@ export default { }); } - if (relations.trackLinks) { - accentParts.push('withAlbums'); - accentOptions.albums = - language.formatConjunctionList( - stitchArrays({ - trackLink: relations.trackLinks, - albumName: data.albumNames, - }).map(({trackLink, albumName}) => - trackLink.slot('content', - language.sanitize(albumName)))); - } - if (accentParts.length > 2) { itemParts.push('withAccent'); itemOptions.accent = diff --git a/src/content/dependencies/generateTrackAdditionalNamesBox.js b/src/content/dependencies/generateTrackAdditionalNamesBox.js deleted file mode 100644 index bad04b74..00000000 --- a/src/content/dependencies/generateTrackAdditionalNamesBox.js +++ /dev/null @@ -1,53 +0,0 @@ -import {empty} from '#sugar'; - -export default { - contentDependencies: ['generateAdditionalNamesBox'], - extraDependencies: ['html'], - - query: (track) => { - const { - additionalNames: own, - sharedAdditionalNames: shared, - inferredAdditionalNames: inferred, - } = track; - - if (empty(own) && empty(shared) && empty(inferred)) { - return {combinedList: []}; - } - - const firstFilter = - (empty(own) - ? new Set() - : new Set(own.map(({name}) => name))); - - const sharedFiltered = - shared.filter(({name}) => !firstFilter.has(name)) - - const secondFilter = - new Set([ - ...firstFilter, - ...sharedFiltered.map(({name}) => name), - ]); - - const inferredFiltered = - inferred.filter(({name}) => !secondFilter.has(name)); - - return { - combinedList: [ - ...own, - ...sharedFiltered, - ...inferredFiltered, - ], - }; - }, - - relations: (relation, query) => ({ - box: - (empty(query.combinedList) - ? null - : relation('generateAdditionalNamesBox', query.combinedList)), - }), - - generate: (relations, {html}) => - relations.box ?? html.blank(), -}; diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js index 9e4a4059..c3faef20 100644 --- a/src/content/dependencies/generateTrackInfoPage.js +++ b/src/content/dependencies/generateTrackInfoPage.js @@ -1,5 +1,6 @@ export default { contentDependencies: [ + 'generateAdditionalNamesBox', 'generateAlbumAdditionalFilesList', 'generateAlbumNavAccent', 'generateAlbumSecondaryNav', @@ -9,7 +10,6 @@ export default { 'generateContentHeading', 'generateContributionList', 'generatePageLayout', - 'generateTrackAdditionalNamesBox', 'generateTrackCoverArtwork', 'generateTrackInfoPageFeaturedByFlashesList', 'generateTrackInfoPageOtherReleasesList', @@ -55,7 +55,7 @@ export default { relation('generateAlbumSidebar', track.album, track), additionalNamesBox: - relation('generateTrackAdditionalNamesBox', track), + relation('generateAdditionalNamesBox', track.additionalNames), cover: (track.hasUniqueCoverArt || track.album.hasCoverArt diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js index 714858a0..63ede4cf 100644 --- a/src/data/composite/things/track/index.js +++ b/src/data/composite/things/track/index.js @@ -1,8 +1,6 @@ export {default as exitWithoutUniqueCoverArt} from './exitWithoutUniqueCoverArt.js'; -export {default as inferredAdditionalNameList} from './inferredAdditionalNameList.js'; export {default as inheritContributionListFromOriginalRelease} from './inheritContributionListFromOriginalRelease.js'; export {default as inheritFromOriginalRelease} from './inheritFromOriginalRelease.js'; -export {default as sharedAdditionalNameList} from './sharedAdditionalNameList.js'; export {default as trackReverseReferenceList} from './trackReverseReferenceList.js'; export {default as withAlbum} from './withAlbum.js'; export {default as withAlwaysReferenceByDirectory} from './withAlwaysReferenceByDirectory.js'; diff --git a/src/data/composite/things/track/inferredAdditionalNameList.js b/src/data/composite/things/track/inferredAdditionalNameList.js deleted file mode 100644 index 58e8d2a1..00000000 --- a/src/data/composite/things/track/inferredAdditionalNameList.js +++ /dev/null @@ -1,67 +0,0 @@ -// Infers additional name entries from other releases that were titled -// differently; the corresponding releases are stored in eacn entry's "from" -// array, which will include multiple items, if more than one other release -// shares the same name differing from this one's. - -import {input, templateCompositeFrom} from '#composite'; -import {chunkByProperties} from '#sugar'; - -import {exitWithoutDependency} from '#composite/control-flow'; -import {withFilteredList, withPropertyFromList} from '#composite/data'; -import {withThingsSortedAlphabetically} from '#composite/wiki-data'; - -import withOtherReleases from './withOtherReleases.js'; - -export default templateCompositeFrom({ - annotation: `inferredAdditionalNameList`, - - compose: false, - - steps: () => [ - withOtherReleases(), - - exitWithoutDependency({ - dependency: '#otherReleases', - mode: input.value('empty'), - value: input.value([]), - }), - - withPropertyFromList({ - list: '#otherReleases', - property: input.value('name'), - }), - - { - dependencies: ['#otherReleases.name', 'name'], - compute: (continuation, { - ['#otherReleases.name']: releaseNames, - ['name']: ownName, - }) => continuation({ - ['#nameFilter']: - releaseNames.map(name => name !== ownName), - }), - }, - - withFilteredList({ - list: '#otherReleases', - filter: '#nameFilter', - }).outputs({ - '#filteredList': '#differentlyNamedReleases', - }), - - withThingsSortedAlphabetically({ - things: '#differentlyNamedReleases', - }).outputs({ - '#sortedThings': '#differentlyNamedReleases', - }), - - { - dependencies: ['#differentlyNamedReleases'], - compute: ({ - ['#differentlyNamedReleases']: releases, - }) => - chunkByProperties(releases, ['name']) - .map(({name, chunk}) => ({name, from: chunk})), - }, - ], -}); diff --git a/src/data/composite/things/track/sharedAdditionalNameList.js b/src/data/composite/things/track/sharedAdditionalNameList.js deleted file mode 100644 index 28c04101..00000000 --- a/src/data/composite/things/track/sharedAdditionalNameList.js +++ /dev/null @@ -1,58 +0,0 @@ -// Compiles additional names directly provided by other releases. - -import {input, templateCompositeFrom} from '#composite'; - -import {exitWithoutDependency, exposeDependency} - from '#composite/control-flow'; - -import { - withFilteredList, - withFlattenedList, - withPropertyFromList, -} from '#composite/data'; - -import withOtherReleases from './withOtherReleases.js'; - -export default templateCompositeFrom({ - annotation: `sharedAdditionalNameList`, - - compose: false, - - steps: () => [ - withOtherReleases(), - - exitWithoutDependency({ - dependency: '#otherReleases', - mode: input.value('empty'), - value: input.value([]), - }), - - withPropertyFromList({ - list: '#otherReleases', - property: input.value('additionalNames'), - }), - - withFlattenedList({ - list: '#otherReleases.additionalNames', - }).outputs({ - ['#flattenedList']: '#otherReleaseEntries', - }), - - withPropertyFromList({ - list: '#otherReleaseEntries', - property: input.value('specificAlbumExclusive'), - }), - - // Filter out entries that have been marked as exclusive to the containing - // album. - withFilteredList({ - list: '#otherReleaseEntries', - filter: '#otherReleaseEntries.specificAlbumExclusive', - flip: input.value(true), - }), - - exposeDependency({ - dependency: '#filteredList', - }), - ], -}); diff --git a/src/data/things/track.js b/src/data/things/track.js index faa5d7ef..e3526f1c 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -58,10 +58,8 @@ import { import { exitWithoutUniqueCoverArt, - inferredAdditionalNameList, inheritContributionListFromOriginalRelease, inheritFromOriginalRelease, - sharedAdditionalNameList, trackReverseReferenceList, withAlbum, withAlwaysReferenceByDirectory, @@ -91,8 +89,6 @@ export class Track extends Thing { directory: directory(), additionalNames: additionalNameList(), - sharedAdditionalNames: sharedAdditionalNameList(), - inferredAdditionalNames: inferredAdditionalNameList(), bandcampTrackIdentifier: simpleString(), bandcampArtworkIdentifier: simpleString(), diff --git a/src/data/validators.js b/src/data/validators.js index 22dc160c..31c7025a 100644 --- a/src/data/validators.js +++ b/src/data/validators.js @@ -920,21 +920,6 @@ export function validateWikiData({ export const isAdditionalName = validateProperties({ name: isContentString, annotation: optional(isContentString), - - // TODO: This only applies for tracks, not additional names - // in general. - specificAlbumExclusive: optional(isBoolean), - - // TODO: This only allows indicating sourcing from a track. - // That's okay for the current limited use of "from", but - // could be expanded later. - from: - // Double TODO: Explicitly allowing both references and - // live objects to co-exist is definitely weird, and - // altogether questions the way we define validators... - optional(anyOf( - validateReferenceList('track'), - validateWikiData({referenceType: 'track'}))), }); export const isAdditionalNameList = validateArrayItems(isAdditionalName); diff --git a/src/data/yaml.js b/src/data/yaml.js index e473790a..be59080e 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -451,7 +451,6 @@ export function parseAdditionalNames(entries) { return { name: item['Name'], annotation: item['Annotation'] ?? null, - specificAlbumExclusive: item['This Album Only'] ?? null, }; if (typeof item !== 'string') return item; @@ -462,7 +461,6 @@ export function parseAdditionalNames(entries) { return { name: match.groups.main, annotation: match.groups.accent ?? null, - specificAlbumExclusive: null, }; }); } diff --git a/src/strings-default.yaml b/src/strings-default.yaml index f298be86..ffd094a9 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -450,8 +450,6 @@ misc: accent: withAnnotation: "({ANNOTATION})" - withAlbums: "(on {ALBUMS})" - withAnnotations.withAlbums: "({ANNOTATION}; on {ALBUMS})" # alt: # Fallback text for the alt text of images and artworks - these diff --git a/tap-snapshots/test/snapshot/generateTrackAdditionalNamesBox.js.test.cjs b/tap-snapshots/test/snapshot/generateTrackAdditionalNamesBox.js.test.cjs deleted file mode 100644 index 3a22266e..00000000 --- a/tap-snapshots/test/snapshot/generateTrackAdditionalNamesBox.js.test.cjs +++ /dev/null @@ -1,99 +0,0 @@ -/* IMPORTANT - * This snapshot file is auto-generated, but designed for humans. - * It should be checked into source control and tracked carefully. - * Re-generate by setting TAP_SNAPSHOT=1 and running tests. - * Make sure to inspect the output below. Do not ignore changes! - */ -'use strict' -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > inferred additional names only 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ - [ - { name: 'Baz Baz', from: [ { directory: 'the-pyrenees' } ] } - ] - ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > multiple own 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ - [ - { name: 'Apple Time!' }, - { name: 'Pterodactyl Time!' }, - { name: 'Banana Time!' } - ] - ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > no additional names 1`] = ` - -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > own additional names only 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ [ { name: 'Foo Bar', annotation: 'the Alps' } ] ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > own and inferred, some overlap 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ - [ - { name: 'Ke$halo Strike Back', annotation: 'own annotation' }, - { name: 'Ironic Mania', annotation: 'own annotation' }, - { - name: 'ANARCHY::MEGASTRIFE', - from: [ { directory: 'inferred-from' } ] - } - ] - ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > own and shared and inferred, various overlap 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ - [ - { name: 'Own!', annotation: 'own annotation' }, - { name: 'Own! Shared!', annotation: 'own annotation' }, - { name: 'Own! Inferred!', annotation: 'own annotation' }, - { name: 'Own! Shared! Inferred!', annotation: 'own annotation' }, - { name: 'Shared!', annotation: 'shared annotation' }, - { name: 'Shared! Inferred!', annotation: 'shared annotation' }, - { name: 'Inferred!', from: [ { directory: 'inferred-from' } ] } - ] - ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > own and shared, some overlap 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ - [ - { name: 'weed dreams..', annotation: 'own annotation' }, - { name: '夜間のMOON汗', annotation: 'own annotation' }, - { name: 'GAMINGブラザー96', annotation: 'shared annotation' } - ] - ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > shared additional names only 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ [ { name: 'Bar Foo', annotation: 'the Rockies' } ] ] - slots: {}] -` - -exports[`test/snapshot/generateTrackAdditionalNamesBox.js > TAP > generateTrackAdditionalNamesBox (snapshot) > shared and inferred, some overlap 1`] = ` -[mocked: generateAdditionalNamesBox - args: [ - [ - { name: 'Coruscate', annotation: 'shared annotation' }, - { name: 'Arbroath', annotation: 'shared annotation' }, - { name: 'Prana Ferox', from: [ { directory: 'inferred-from' } ] } - ] - ] - slots: {}] -` diff --git a/test/snapshot/generateTrackAdditionalNamesBox.js b/test/snapshot/generateTrackAdditionalNamesBox.js deleted file mode 100644 index 9c1e3598..00000000 --- a/test/snapshot/generateTrackAdditionalNamesBox.js +++ /dev/null @@ -1,107 +0,0 @@ -import t from 'tap'; - -import contentFunction from '#content-function'; -import {testContentFunctions} from '#test-lib'; - -testContentFunctions(t, 'generateTrackAdditionalNamesBox (snapshot)', async (t, evaluate) => { - await evaluate.load({ - mock: { - generateAdditionalNamesBox: - evaluate.stubContentFunction('generateAdditionalNamesBox'), - }, - }); - - const stubTrack = { - additionalNames: [], - sharedAdditionalNames: [], - inferredAdditionalNames: [], - }; - - const quickSnapshot = (message, trackProperties) => - evaluate.snapshot(message, { - name: 'generateTrackAdditionalNamesBox', - args: [{...stubTrack, ...trackProperties}], - }); - - quickSnapshot(`no additional names`, {}); - - quickSnapshot(`own additional names only`, { - additionalNames: [ - {name: `Foo Bar`, annotation: `the Alps`}, - ], - }); - - quickSnapshot(`shared additional names only`, { - sharedAdditionalNames: [ - {name: `Bar Foo`, annotation: `the Rockies`}, - ], - }); - - quickSnapshot(`inferred additional names only`, { - inferredAdditionalNames: [ - {name: `Baz Baz`, from: [{directory: `the-pyrenees`}]}, - ], - }); - - quickSnapshot(`multiple own`, { - additionalNames: [ - {name: `Apple Time!`}, - {name: `Pterodactyl Time!`}, - {name: `Banana Time!`}, - ], - }); - - quickSnapshot(`own and shared, some overlap`, { - additionalNames: [ - {name: `weed dreams..`, annotation: `own annotation`}, - {name: `夜間のMOON汗`, annotation: `own annotation`}, - ], - sharedAdditionalNames: [ - {name: `weed dreams..`, annotation: `shared annotation`}, - {name: `GAMINGブラザー96`, annotation: `shared annotation`}, - ], - }); - - quickSnapshot(`shared and inferred, some overlap`, { - sharedAdditionalNames: [ - {name: `Coruscate`, annotation: `shared annotation`}, - {name: `Arbroath`, annotation: `shared annotation`}, - ], - inferredAdditionalNames: [ - {name: `Arbroath`, from: [{directory: `inferred-from`}]}, - {name: `Prana Ferox`, from: [{directory: `inferred-from`}]}, - ], - }); - - quickSnapshot(`own and inferred, some overlap`, { - additionalNames: [ - {name: `Ke$halo Strike Back`, annotation: `own annotation`}, - {name: `Ironic Mania`, annotation: `own annotation`}, - ], - inferredAdditionalNames: [ - {name: `Ironic Mania`, from: [{directory: `inferred-from`}]}, - {name: `ANARCHY::MEGASTRIFE`, from: [{directory: `inferred-from`}]}, - ], - }); - - quickSnapshot(`own and shared and inferred, various overlap`, { - additionalNames: [ - {name: `Own!`, annotation: `own annotation`}, - {name: `Own! Shared!`, annotation: `own annotation`}, - {name: `Own! Inferred!`, annotation: `own annotation`}, - {name: `Own! Shared! Inferred!`, annotation: `own annotation`}, - ], - sharedAdditionalNames: [ - {name: `Shared!`, annotation: `shared annotation`}, - {name: `Own! Shared!`, annotation: `shared annotation`}, - {name: `Shared! Inferred!`, annotation: `shared annotation`}, - {name: `Own! Shared! Inferred!`, annotation: `shared annotation`}, - ], - inferredAdditionalNames: [ - {name: `Inferred!`, from: [{directory: `inferred-from`}]}, - {name: `Own! Inferred!`, from: [{directory: `inferred-from`}]}, - {name: `Shared! Inferred!`, from: [{directory: `inferred-from`}]}, - {name: `Own! Shared! Inferred!`, from: [{directory: `inferred-from`}]}, - ], - }); -}); -- cgit 1.3.0-6-gf8a5