« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies')
-rw-r--r--src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js141
-rw-r--r--src/content/dependencies/generateContentEntry.js8
-rw-r--r--src/content/dependencies/generateContentEntryDate.js2
-rw-r--r--src/content/dependencies/generateLyricsEntry.js4
-rw-r--r--src/content/dependencies/generateTrackArtworkColumn.js2
5 files changed, 90 insertions, 67 deletions
diff --git a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
index 572eb982..6b603375 100644
--- a/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
+++ b/src/content/dependencies/generateArtistInfoPageCommentaryChunkedList.js
@@ -30,6 +30,10 @@ export default {
         flashAct,
         flash,
 
+        quoted:
+         !entry.headingArtists.includes(artist) &&
+          entry.quotedArtists.includes(artist),
+
         annotation: entry.annotation,
         annotationParts: entry.annotationParts,
       },
@@ -191,6 +195,11 @@ export default {
       query.chunks
         .map(({chunk}) => chunk
           .map(({itemType}) => itemType)),
+
+    itemQuoted:
+      query.chunks
+        .map(({chunk}) => chunk
+          .map(({quoted}) => quoted)),
   }),
 
   generate: (data, relations, {html, language}) =>
@@ -206,6 +215,7 @@ export default {
         itemLinks: relations.itemLinks,
         itemAnnotations: relations.itemAnnotations,
         itemTypes: data.itemTypes,
+        itemQuoted: data.itemQuoted,
       }).map(({
           chunk,
           chunkLink,
@@ -215,64 +225,77 @@ export default {
           itemLinks,
           itemAnnotations,
           itemTypes,
+          itemQuoted,
         }) =>
-          language.encapsulate('artistPage.creditList.entry', capsule =>
-            (chunkType === 'album'
-              ? chunk.slots({
-                  mode: 'album',
-                  link: chunkLink,
-
-                  list:
-                    html.tag('ul',
-                      stitchArrays({
-                        item: items,
-                        link: itemLinks,
-                        annotation: itemAnnotations,
-                        type: itemTypes,
-                      }).map(({item, link, annotation, type}) =>
-                        item.slots({
-                          // The citation slot, instead of annotation, gives commentary
-                          // a specially custom look.
-                          citation:
-                            annotation.slots({
-                              mode: 'inline',
-                              absorbPunctuationFollowingExternalLinks: false,
-                            }),
-
-                          content:
-                            (type === 'album'
-                              ? html.tag('i',
-                                  language.$(capsule, 'album.commentary'))
-                              : language.$(capsule, 'track', {track: link})),
-                        }))),
-                })
-
-             : chunkType === 'flash-act'
-              ? chunk.slots({
-                  mode: 'flash',
-                  link: chunkLink,
-
-                  list:
-                    html.tag('ul',
-                      stitchArrays({
-                        item: items,
-                        link: itemLinks,
-                        annotation: itemAnnotations,
-                      }).map(({item, link, annotation}) =>
-                        item.slots({
-                          annotation:
-                            (annotation
-                              ? annotation.slots({
-                                  mode: 'inline',
-                                  absorbPunctuationFollowingExternalLinks: false,
-                                })
-                              : null),
-
-                          content:
-                            language.$(capsule, 'flash', {
-                              flash: link,
-                            }),
-                        }))),
-                })
-              : null)))),
+          language.encapsulate('artistPage.creditList.entry', capsule => {
+            // The citation slot, instead of annotation, gives commentary
+            // a specially custom look.
+            const citations =
+              stitchArrays({annotation: itemAnnotations, quoted: itemQuoted})
+                .map(({annotation, quoted}) =>
+                  language.encapsulate(capsule, workingCapsule => {
+                    const workingOptions = {};
+
+                    let any = false;
+
+                    annotation.setSlots({
+                      mode: 'inline',
+                      absorbPunctuationFollowingExternalLinks: false,
+                    });
+
+                    if (!html.isBlank(annotation)) {
+                      workingCapsule += '.citation';
+                      workingOptions.citation = annotation;
+                      any = true;
+                    }
+
+                    if (quoted) {
+                      workingCapsule += '.quoted';
+                      any = true;
+                    }
+
+                    if (any) {
+                      return language.$(workingCapsule, workingOptions);
+                    } else {
+                      return html.blank();
+                    }
+                  }));
+
+            let contents;
+
+            if (chunkType === 'album') {
+              chunk.setSlot('mode', 'album');
+              contents =
+                stitchArrays({link: itemLinks, type: itemTypes})
+                  .map(({link, type}) =>
+                    (type === 'album'
+                      ? html.tag('i',
+                          language.$(capsule, 'album.commentary'))
+                      : language.$(capsule, 'track', {track: link})));
+
+            } else if (chunkType === 'flash-act') {
+              chunk.setSlot('mode', 'flash');
+              contents =
+                itemLinks.map(link =>
+                  language.$(capsule, 'flash', {flash: link}));
+
+            } else {
+              throw new Error(`Gyeep!!`);
+            }
+
+            chunk.setSlots({
+              link: chunkLink,
+
+              list:
+                html.tag('ul',
+                  stitchArrays({
+                    item: items,
+                    citation: citations,
+                    content: contents,
+                  }).map(({item, citation, content}) =>
+                      item.slots({citation, content}))),
+            });
+
+            return chunk;
+          }))),
 };
diff --git a/src/content/dependencies/generateContentEntry.js b/src/content/dependencies/generateContentEntry.js
index c77f744a..40c637a3 100644
--- a/src/content/dependencies/generateContentEntry.js
+++ b/src/content/dependencies/generateContentEntry.js
@@ -3,14 +3,14 @@ import {empty} from '#sugar';
 export default {
   relations: (relation, entry) => ({
     artistLinks:
-      (!empty(entry.artists) && !entry.artistText
-        ? entry.artists
+      (!empty(entry.headingArtists) && !entry.headingArtistText
+        ? entry.headingArtists
             .map(artist => relation('linkArtist', artist))
         : null),
 
     artistsContent:
-      (entry.artistText
-        ? relation('transformContent', entry.artistText)
+      (entry.headingArtistText
+        ? relation('transformContent', entry.headingArtistText)
         : null),
 
     annotationContent:
diff --git a/src/content/dependencies/generateContentEntryDate.js b/src/content/dependencies/generateContentEntryDate.js
index 845cb5ed..5255c7ea 100644
--- a/src/content/dependencies/generateContentEntryDate.js
+++ b/src/content/dependencies/generateContentEntryDate.js
@@ -35,7 +35,7 @@ export default {
 
      : entry.thing.isTrack &&
        entry.thing.date === entry.thing.album.date &&
-       entry.thing.style === 'single'
+       entry.thing.album.style === 'single'
         ? 'single'
 
      : entry.thing.isTrack &&
diff --git a/src/content/dependencies/generateLyricsEntry.js b/src/content/dependencies/generateLyricsEntry.js
index 15f84b27..0ecf319f 100644
--- a/src/content/dependencies/generateLyricsEntry.js
+++ b/src/content/dependencies/generateLyricsEntry.js
@@ -4,10 +4,10 @@ export default {
       relation('transformContent', entry.body),
 
     artistText:
-      relation('transformContent', entry.artistText),
+      relation('transformContent', entry.headingArtistText),
 
     artistLinks:
-      entry.artists
+      entry.headingArtists
         .filter(artist => artist.name !== 'HSMusic Wiki') // smh
         .map(artist => relation('linkArtist', artist)),
 
diff --git a/src/content/dependencies/generateTrackArtworkColumn.js b/src/content/dependencies/generateTrackArtworkColumn.js
index feaed604..77ce0071 100644
--- a/src/content/dependencies/generateTrackArtworkColumn.js
+++ b/src/content/dependencies/generateTrackArtworkColumn.js
@@ -21,7 +21,7 @@ export default {
       relations.albumCover?.slots({
         showOriginDetails: true,
         showArtTagDetails: true,
-        showReferenceDetails: true,
+        showReferenceDetails: false,
       }),
 
       relations.trackCovers.map(cover =>