« get me outta code hell

content, data: Track.excludingURLs - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-05-11 21:23:46 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-05-11 21:23:46 -0300
commitb68e658e27ae3c6e799342e69dfe3ee45cd53d7b (patch)
tree86f176400b4974df10f59989b6f3bc6b5ee3926e
parenteec8c7dfed1bf98607d94160a735132f98b13270 (diff)
content, data: Track.excludingURLs preview
-rw-r--r--src/content/dependencies/generateListenLineOrList.js63
-rw-r--r--src/data/things/Track.js35
-rw-r--r--src/strings-default.yaml12
3 files changed, 96 insertions, 14 deletions
diff --git a/src/content/dependencies/generateListenLineOrList.js b/src/content/dependencies/generateListenLineOrList.js
index 0c39a092..558062f9 100644
--- a/src/content/dependencies/generateListenLineOrList.js
+++ b/src/content/dependencies/generateListenLineOrList.js
@@ -71,7 +71,9 @@ export default {
     const data = {};
 
     data.name = thing.name;
+    data.albumName = (thing.album ? thing.album.name : null);
 
+    data.excludingLinks = thing.excludingURLs;
     data.noLinks = empty(query.urls);
 
     const artistURLs =
@@ -130,16 +132,53 @@ export default {
   },
 
   generate: (data, relations, slots, {html, language}) =>
-    language.encapsulate('releaseInfo.listenOn', capsule =>
-      (data.noLinks && slots.visibleWithoutLinks
-        ? language.$(capsule, 'noLinks', {
-            name:
-              html.tag('i', data.name),
-          })
-
-        : relations.externalLinksLineOrList.slots({
-            string: capsule,
-            context: slots.context,
-            contexts: data.releaseContexts,
-          }))),
+    language.encapsulate('releaseInfo.listenOn', capsule => {
+      const trackPart =
+        html.tag('i', data.name);
+
+      const albumPart =
+        (data.albumName
+          ? html.tag('i', data.albumName)
+          : null);
+
+      if (data.excludingLinks) {
+        const exclude = (name, options) =>
+          (name
+            ? language.$(capsule, 'excludingLinks', name, options)
+            : language.$(capsule, 'excludingLinks', options));
+
+        switch (data.excludingLinks) {
+          case 'quietly':
+            return html.blank();
+
+          case 'not clearly public':
+            return exclude('notClearlyPublic', {
+              track: trackPart,
+            });
+
+          case 'paid bonus track':
+            return exclude('paidBonusTrack', {
+              track: trackPart,
+              album: albumPart,
+            });
+
+          default:
+            return exclude(null, {track: trackPart});
+        }
+      }
+
+      if (data.noLinks) {
+        if (slots.visibleWithoutLinks) {
+          return language.$(capsule, 'noLinks', {track: trackPart});
+        } else {
+          return html.blank();
+        }
+      }
+
+      return relations.externalLinksLineOrList.slots({
+        string: capsule,
+        context: slots.context,
+        contexts: data.releaseContexts,
+      });
+    }),
 };
diff --git a/src/data/things/Track.js b/src/data/things/Track.js
index 6a31cfe6..b0c8d955 100644
--- a/src/data/things/Track.js
+++ b/src/data/things/Track.js
@@ -383,7 +383,31 @@ export class Track extends Thing {
       },
     ],
 
-    urls: urls(),
+    excludingURLs: {
+      flags: {update: true, expose: true},
+
+      update: {
+        validate:
+          is(...[
+            'quietly',
+            'generic',
+            'not clearly public',
+            'paid bonus track',
+          ]),
+      },
+    },
+
+    urls: [
+      {
+        dependencies: ['excludingURLs'],
+        compute: (continuation, {excludingURLs}) =>
+          (excludingURLs
+            ? continuation.exit([])
+            : continuation()),
+      },
+
+      urls(),
+    ],
 
     // > Update & expose - Artworks
 
@@ -1034,6 +1058,10 @@ export class Track extends Thing {
         property: 'needsLyrics',
       },
 
+      'Excluding URLs': {
+        property: 'excludingURLs',
+      },
+
       'URLs': {
         property: 'urls',
         transform: parseURLs,
@@ -1165,6 +1193,11 @@ export class Track extends Thing {
           'Cover Artists',
         ],
       },
+
+      {message: `Don't include URLs alongside Excluding URLs`, fields: [
+        'URLs',
+        'Excluding URLs',
+      ]},
     ],
   };
 
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index a493c696..4e88ea90 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -384,8 +384,18 @@ releaseInfo:
 
   listenOn: "Listen on {LINKS}."
   listenOn.title: "Listen on:"
+
   listenOn.noLinks: >-
-    This wiki doesn't have any listening links for {NAME}.
+    This wiki doesn't have any listening links for {TRACK}.
+
+  listenOn.excludingLinks: >-
+    This wiki is excluding listening links for {TRACK}.
+
+  listenOn.excludingLinks.notClearlyPublic: >-
+    !! string pending - "not clearly public" {TRACK} !!
+
+  listenOn.excludingLinks.paidBonusTrack: >-
+    On {ALBUM}, the bonus track {TRACK} is only available with the album purchase, so this wiki is excluding listening links here.
 
   visitOn: "Visit on {LINKS}."
   visitOn.title: "Visit on:"