« get me outta code hell

support & enable Sampled Tracks - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-11-27 02:00:30 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-11-27 02:00:30 -0400
commit903e21d8afa9b3262194f641f8bee0955289bf21 (patch)
tree7e12050d9baa1992ed9532ac40b93f6b4f890f98 /src
parent398e8c25073a88cbf7e9861445c87dc9e995978a (diff)
support & enable Sampled Tracks
Diffstat (limited to 'src')
-rw-r--r--src/data/things.js23
-rw-r--r--src/data/yaml.js4
-rw-r--r--src/page/track.js31
-rw-r--r--src/strings-default.json2
4 files changed, 55 insertions, 5 deletions
diff --git a/src/data/things.js b/src/data/things.js
index ee458006..2037faca 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -718,6 +718,7 @@ Track.propertyDescriptors = {
   coverArtistContribsByRef: Thing.common.contribsByRef(),
 
   referencedTracksByRef: Thing.common.referenceList(Track),
+  sampledTracksByRef: Thing.common.referenceList(Track),
   artTagsByRef: Thing.common.referenceList(ArtTag),
 
   hasCoverArt: {
@@ -914,6 +915,12 @@ Track.propertyDescriptors = {
     find.track
   ),
 
+  sampledTracks: Thing.common.dynamicThingsFromReferenceList(
+    'sampledTracksByRef',
+    'trackData',
+    find.track
+  ),
+
   // Specifically exclude re-releases from this list - while it's useful to
   // get from a re-release to the tracks it references, re-releases aren't
   // generally relevant from the perspective of the tracks being referenced.
@@ -937,6 +944,22 @@ Track.propertyDescriptors = {
     },
   },
 
+  // For the same reasoning, exclude re-releases from sampled tracks too.
+  sampledByTracks: {
+    flags: {expose: true},
+
+    expose: {
+      dependencies: ['trackData'],
+
+      compute: ({trackData, [Track.instance]: track}) =>
+        trackData
+          ? trackData
+              .filter((t) => !t.originalReleaseTrack)
+              .filter((t) => t.sampledTracks?.includes(track))
+          : [],
+    },
+  },
+
   // Previously known as: (track).flashes
   featuredInFlashes: Thing.common.reverseReferenceList(
     'flashData',
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 2adce50b..6ba19c06 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -278,6 +278,7 @@ export const processTrackDocument = makeProcessDocument(Track, {
     hasURLs: 'Has URLs',
 
     referencedTracksByRef: 'Referenced Tracks',
+    sampledTracksByRef: 'Sampled Tracks',
     artistContribsByRef: 'Artists',
     contributorContribsByRef: 'Contributors',
     coverArtistContribsByRef: 'Cover Artists',
@@ -289,8 +290,6 @@ export const processTrackDocument = makeProcessDocument(Track, {
 
     additionalFiles: 'Additional Files',
   },
-
-  ignoredFields: ['Sampled Tracks'],
 });
 
 export const processArtistDocument = makeProcessDocument(Artist, {
@@ -1264,6 +1263,7 @@ export function filterReferenceErrors(wikiData) {
       contributorContribsByRef: '_contrib',
       coverArtistContribsByRef: '_contrib',
       referencedTracksByRef: 'track',
+      sampledTracksByRef: 'track',
       artTagsByRef: 'artTag',
       originalReleaseTrackByRef: 'track',
     }],
diff --git a/src/page/track.js b/src/page/track.js
index b61defe2..4095f75a 100644
--- a/src/page/track.js
+++ b/src/page/track.js
@@ -24,7 +24,16 @@ export function targets({wikiData}) {
 
 export function write(track, {wikiData}) {
   const {wikiInfo} = wikiData;
-  const {album, referencedByTracks, referencedTracks, otherReleases} = track;
+
+  const {
+    album,
+    contributorContribs,
+    referencedByTracks,
+    referencedTracks,
+    sampledByTracks,
+    sampledTracks,
+    otherReleases,
+  } = track;
 
   const listTag = getAlbumListTag(album);
 
@@ -277,9 +286,9 @@ export function write(track, {wikiData}) {
               ]),
 
             ...html.fragment(
-              !empty(track.contributorContribs) && [
+              !empty(contributorContribs) && [
                 html.tag('p', language.$('releaseInfo.contributors')),
-                html.tag('ul', track.contributorContribs.map(contrib =>
+                html.tag('ul', contributorContribs.map(contrib =>
                   html.tag('li', getArtistString([contrib], {
                     showContrib: true,
                     showIcons: true,
@@ -306,6 +315,22 @@ export function write(track, {wikiData}) {
               ]),
 
             ...html.fragment(
+              !empty(sampledTracks) && [
+                html.tag('p', language.$('releaseInfo.tracksSampled', {
+                  track: html.tag('i', track.name),
+                })),
+                html.tag('ul', sampledTracks.map(getTrackItem)),
+              ]),
+
+            ...html.fragment(
+              !empty(sampledByTracks) && [
+                html.tag('p', language.$('releaseInfo.tracksThatSample', {
+                  track: html.tag('i', track.name),
+                })),
+                html.tag('ul', sampledByTracks.map(getTrackItem)),
+              ]),
+
+            ...html.fragment(
               wikiInfo.enableFlashesAndGames &&
               !empty(flashesThatFeature) && [
                 html.tag('p', language.$('releaseInfo.flashesThatFeature', {
diff --git a/src/strings-default.json b/src/strings-default.json
index b751a80a..d24f04a1 100644
--- a/src/strings-default.json
+++ b/src/strings-default.json
@@ -103,6 +103,8 @@
   "releaseInfo.contributors": "Contributors:",
   "releaseInfo.tracksReferenced": "Tracks that {TRACK} references:",
   "releaseInfo.tracksThatReference": "Tracks that reference {TRACK}:",
+  "releaseInfo.tracksSampled": "Tracks that {TRACK} samples:",
+  "releaseInfo.tracksThatSample": "Tracks that sample {TRACK}:",
   "releaseInfo.flashesThatFeature": "Flashes & games that feature {TRACK}:",
   "releaseInfo.flashesThatFeature.item": "{FLASH}",
   "releaseInfo.flashesThatFeature.item.asDifferentRelease": "{FLASH} (as {TRACK})",