« get me outta code hell

data, content: LyricsEntry.hasSquareBracketAnnotations - 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-05-06 13:37:11 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-05-06 13:37:11 -0300
commita68d55771317f131217a79b505523758999d8811 (patch)
tree8c0f79cac22b3ae36200eaae564376a37f531a72
parentaf1db3b02a4e5791aeb46c1f253989a3b10815ac (diff)
data, content: LyricsEntry.hasSquareBracketAnnotations
-rw-r--r--src/content/dependencies/generateLyricsEntry.js10
-rw-r--r--src/data/things/content.js25
-rw-r--r--src/strings-default.yaml3
3 files changed, 38 insertions, 0 deletions
diff --git a/src/content/dependencies/generateLyricsEntry.js b/src/content/dependencies/generateLyricsEntry.js
index fb8e71cc..02fd3634 100644
--- a/src/content/dependencies/generateLyricsEntry.js
+++ b/src/content/dependencies/generateLyricsEntry.js
@@ -22,6 +22,9 @@ export default {
   data: (entry) => ({
     isWikiLyrics:
       entry.isWikiLyrics,
+
+    hasSquareBracketAnnotations:
+      entry.hasSquareBracketAnnotations,
   }),
 
   slots: {
@@ -63,6 +66,13 @@ export default {
                       ? language.formatUnitList(relations.artistLinks)
                       : relations.artistText.slot('mode', 'inline')),
                 }),
+
+              // This check is doubled up only for clarity: entries are coded
+              // in data so that `hasSquareBracketAnnotations` is only true
+              // if `isWikiLyrics` is also true.
+              data.isWikiLyrics &&
+              data.hasSquareBracketAnnotations &&
+                language.$(capsule, 'squareBracketAnnotations'),
             ]),
 
           relations.content.slot('mode', 'lyrics'),
diff --git a/src/data/things/content.js b/src/data/things/content.js
index 60b2c8e0..cf8fa1f4 100644
--- a/src/data/things/content.js
+++ b/src/data/things/content.js
@@ -8,6 +8,7 @@ import {contentString, referenceList, simpleDate, soupyFind, thing}
   from '#composite/wiki-properties';
 
 import {
+  exitWithoutDependency,
   exposeConstant,
   exposeDependency,
   exposeDependencyOrContinue,
@@ -19,6 +20,7 @@ import {
   contentArtists,
   hasAnnotationPart,
   withAnnotationParts,
+  withHasAnnotationPart,
   withSourceText,
   withSourceURLs,
   withWebArchiveDate,
@@ -159,6 +161,29 @@ export class LyricsEntry extends ContentEntry {
     isWikiLyrics: hasAnnotationPart({
       part: input.value('wiki lyrics'),
     }),
+
+    hasSquareBracketAnnotations: [
+      withHasAnnotationPart({
+        part: input.value('wiki lyrics'),
+      }),
+
+      exitWithoutDependency({
+        dependency: '#hasAnnotationPart',
+        mode: input.value('falsy'),
+        value: input.value(false),
+      }),
+
+      exitWithoutDependency({
+        dependency: 'body',
+        value: input.value(false),
+      }),
+
+      {
+        dependencies: ['body'],
+        compute: ({body}) =>
+          /\[.*\]/m.test(body),
+      },
+    ],
   });
 }
 
diff --git a/src/strings-default.yaml b/src/strings-default.yaml
index 486871ac..16687905 100644
--- a/src/strings-default.yaml
+++ b/src/strings-default.yaml
@@ -720,6 +720,9 @@ misc:
     contributors: >-
       Contributions from {CONTRIBUTORS}
 
+    squareBracketAnnotations: >-
+      Mind parts marked in [square brackets]
+
   # missingImage:
   #   Fallback text displayed in an image when it's sourced to a file
   #   that isn't available under the wiki's media directory. While it