« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/dependencies/generateAdditionalNamesBoxItem.js30
-rw-r--r--src/content/dependencies/generateTrackAdditionalNamesBox.js53
-rw-r--r--src/content/dependencies/generateTrackInfoPage.js4
-rw-r--r--src/data/composite/things/track/index.js2
-rw-r--r--src/data/composite/things/track/inferredAdditionalNameList.js67
-rw-r--r--src/data/composite/things/track/sharedAdditionalNameList.js58
-rw-r--r--src/data/things/track.js4
-rw-r--r--src/data/validators.js15
-rw-r--r--src/data/yaml.js2
-rw-r--r--src/strings-default.yaml2
10 files changed, 4 insertions, 233 deletions
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