« get me outta code hell

content: "read artist and wiki commentary", etc - 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>2025-07-12 17:14:47 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-07-12 17:14:47 -0300
commit837b1d1bb09986e4a5634d52acf61c8c748ba88b (patch)
treebfb69d117bf5fa79ec6fa866be04029c47b66bb0
parentc6bdd7a09b3968de3b0ebb19a129d081efc7c09a (diff)
content: "read artist and wiki commentary", etc
-rw-r--r--src/content/dependencies/generateCommentaryContentHeading.js33
-rw-r--r--src/content/dependencies/generateReadCommentaryLine.js47
-rw-r--r--src/content/dependencies/generateTrackArtistCommentarySection.js12
-rw-r--r--src/content/dependencies/generateTrackInfoPage.js13
-rw-r--r--src/strings-default.yaml14
5 files changed, 102 insertions, 17 deletions
diff --git a/src/content/dependencies/generateCommentaryContentHeading.js b/src/content/dependencies/generateCommentaryContentHeading.js
new file mode 100644
index 00000000..92405010
--- /dev/null
+++ b/src/content/dependencies/generateCommentaryContentHeading.js
@@ -0,0 +1,33 @@
+export default {
+  contentDependencies: ['generateContentContentHeading'],
+  extraDependencies: ['language'],
+
+  relations: (relation, thing) => ({
+    contentContentHeading:
+      relation('generateContentContentHeading', thing),
+  }),
+
+  data: (thing) => ({
+    hasWikiEditorCommentary:
+      thing.commentary
+        .some(entry => entry.isWikiEditorCommentary),
+
+    onlyWikiEditorCommentary:
+      thing.commentary
+        .every(entry => entry.isWikiEditorCommentary),
+  }),
+
+  generate: (data, relations, {language}) =>
+    relations.contentContentHeading.slots({
+      // It's #artist-commentary for legacy reasons... Sorry...
+      attributes: {id: 'artist-commentary'},
+
+      string:
+        language.encapsulate('misc.artistCommentary', capsule =>
+          (data.onlyWikiEditorCommentary
+            ? language.encapsulate(capsule, 'onlyWikiCommentary')
+         : data.hasWikiEditorCommentary
+            ? language.encapsulate(capsule, 'withWikiCommentary')
+            : capsule)),
+    }),
+};
diff --git a/src/content/dependencies/generateReadCommentaryLine.js b/src/content/dependencies/generateReadCommentaryLine.js
new file mode 100644
index 00000000..a7a7a4da
--- /dev/null
+++ b/src/content/dependencies/generateReadCommentaryLine.js
@@ -0,0 +1,47 @@
+import {empty} from '#sugar';
+
+export default {
+  extraDependencies: ['html', 'language'],
+
+  query: (thing) => ({
+    entries:
+      (thing.isTrack
+        ? [...thing.commentary, ...thing.commentaryFromMainRelease]
+        : thing.commentary),
+  }),
+
+  data: (query, _thing) => ({
+    hasWikiEditorCommentary:
+      query.entries
+        .some(entry => entry.isWikiEditorCommentary),
+
+    onlyWikiEditorCommentary:
+      !empty(query.entries) &&
+      query.entries
+        .every(entry => entry.isWikiEditorCommentary),
+
+    hasAnyCommentary:
+      !empty(query.entries),
+  }),
+
+  generate: (data, {html, language}) =>
+    language.encapsulate('releaseInfo.readCommentary', capsule =>
+      language.$(capsule, {
+        [language.onlyIfOptions]: ['link'],
+
+        link:
+          html.tag('a',
+            {[html.onlyIfContent]: true},
+
+            {href: '#artist-commentary'},
+
+            language.encapsulate(capsule, 'link', capsule =>
+              (data.onlyWikiEditorCommentary
+                ? language.$(capsule, 'onlyWikiCommentary')
+             : data.hasWikiEditorCommentary
+                ? language.$(capsule, 'withWikiCommentary')
+             : data.hasAnyCommentary
+                ? language.$(capsule)
+                : html.blank()))),
+      })),
+};
diff --git a/src/content/dependencies/generateTrackArtistCommentarySection.js b/src/content/dependencies/generateTrackArtistCommentarySection.js
index 50565bce..5ed24d6c 100644
--- a/src/content/dependencies/generateTrackArtistCommentarySection.js
+++ b/src/content/dependencies/generateTrackArtistCommentarySection.js
@@ -2,7 +2,7 @@ import {empty, stitchArrays} from '#sugar';
 
 export default {
   contentDependencies: [
-    'generateContentContentHeading',
+    'generateCommentaryContentHeading',
     'generateCommentaryEntry',
     'linkAlbum',
     'linkTrack',
@@ -18,8 +18,8 @@ export default {
   }),
 
   relations: (relation, query, track) => ({
-    contentContentHeading:
-      relation('generateContentContentHeading', track),
+    commentaryContentHeading:
+      relation('generateCommentaryContentHeading', track),
 
     mainReleaseTrackLink:
       (track.isSecondaryRelease
@@ -78,11 +78,7 @@ export default {
   generate: (data, relations, {html, language}) =>
     language.encapsulate('misc.artistCommentary', capsule =>
       html.tags([
-        relations.contentContentHeading.slots({
-          attributes: {id: 'artist-commentary'},
-          string: 'misc.artistCommentary',
-        }),
-
+        relations.commentaryContentHeading,
         relations.artistCommentaryEntries,
 
         data.isSecondaryRelease &&
diff --git a/src/content/dependencies/generateTrackInfoPage.js b/src/content/dependencies/generateTrackInfoPage.js
index b37da199..1f6205d8 100644
--- a/src/content/dependencies/generateTrackInfoPage.js
+++ b/src/content/dependencies/generateTrackInfoPage.js
@@ -13,6 +13,7 @@ export default {
     'generateContributionList',
     'generateLyricsSection',
     'generatePageLayout',
+    'generateReadCommentaryLine',
     'generateTrackArtistCommentarySection',
     'generateTrackArtworkColumn',
     'generateTrackInfoPageFeaturedByFlashesList',
@@ -86,6 +87,9 @@ export default {
     releaseInfo:
       relation('generateTrackReleaseInfo', track),
 
+    readCommentaryLine:
+      relation('generateReadCommentaryLine', track),
+
     otherReleasesList:
       relation('generateTrackInfoPageOtherReleasesList', track),
 
@@ -205,14 +209,7 @@ export default {
                         language.$(capsule, 'link')),
                   })),
 
-              !html.isBlank(relations.artistCommentarySection) &&
-                language.encapsulate(capsule, 'readCommentary', capsule =>
-                  language.$(capsule, {
-                    link:
-                      html.tag('a',
-                        {href: '#artist-commentary'},
-                        language.$(capsule, 'link')),
-                  })),
+              relations.readCommentaryLine,
 
               !html.isBlank(relations.creditingSourceEntries) &&
                 language.encapsulate(capsule, 'readCreditingSources', capsule =>
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index a56956f9..c43e757e 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -368,7 +368,11 @@ releaseInfo:
 
   readCommentary:
     _: "Read {LINK}."
-    link: "artist commentary"
+
+    link:
+      _: "artist commentary"
+      withWikiCommentary: "artist and wiki commentary"
+      onlyWikiCommentary: "wiki commentary"
 
   readCreditingSources:
     _: "Read {LINK}."
@@ -495,6 +499,14 @@ misc:
     _: "Artist commentary for {THING}:"
     sticky: "Artist commentary:"
 
+    withWikiCommentary:
+      _: "Artist and wiki commentary for {THING}:"
+      sticky: "Artist and wiki commentary:"
+
+    onlyWikiCommentary:
+      _: "Wiki commentary for {THING}:"
+      sticky: "Wiki commentary:"
+
     entry:
       title:
         _: "{ARTISTS}:"