« 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/generateFlashInfoPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/dependencies/generateFlashInfoPage.js')
-rw-r--r--src/content/dependencies/generateFlashInfoPage.js298
1 files changed, 152 insertions, 146 deletions
diff --git a/src/content/dependencies/generateFlashInfoPage.js b/src/content/dependencies/generateFlashInfoPage.js
index eec32157..095e43c4 100644
--- a/src/content/dependencies/generateFlashInfoPage.js
+++ b/src/content/dependencies/generateFlashInfoPage.js
@@ -2,11 +2,12 @@ import {empty} from '#sugar';
 
 export default {
   contentDependencies: [
-    'generateCommentarySection',
+    'generateAdditionalNamesBox',
+    'generateCommentaryEntry',
     'generateContentHeading',
     'generateContributionList',
     'generateFlashActSidebar',
-    'generateFlashCoverArtwork',
+    'generateFlashArtworkColumn',
     'generateFlashNavAccent',
     'generatePageLayout',
     'generateTrackList',
@@ -32,165 +33,170 @@ export default {
     return query;
   },
 
-  relations(relation, query, flash) {
-    const relations = {};
-    const sections = relations.sections = {};
+  relations: (relation, query, flash) => ({
+    layout:
+      relation('generatePageLayout'),
 
-    relations.layout =
-      relation('generatePageLayout');
+    sidebar:
+      relation('generateFlashActSidebar', flash.act, flash),
 
-    relations.sidebar =
-      relation('generateFlashActSidebar', flash.act, flash);
+    additionalNamesBox:
+      relation('generateAdditionalNamesBox', flash.additionalNames),
 
-    relations.externalLinks =
+    externalLinks:
       query.urls
-        .map(url => relation('linkExternal', url));
-
-    // TODO: Flashes always have cover art (#175)
-    /* eslint-disable-next-line no-constant-condition */
-    if (true) {
-      relations.cover =
-        relation('generateFlashCoverArtwork', flash);
-    }
-
-    // Section: navigation bar
-
-    const nav = sections.nav = {};
-
-    nav.flashActLink =
-      relation('linkFlashAct', flash.act);
-
-    nav.flashNavAccent =
-      relation('generateFlashNavAccent', flash);
-
-    // Section: Featured tracks
-
-    if (!empty(flash.featuredTracks)) {
-      const featuredTracks = sections.featuredTracks = {};
-
-      featuredTracks.heading =
-        relation('generateContentHeading');
-
-      featuredTracks.list =
-        relation('generateTrackList', flash.featuredTracks);
-    }
-
-    // Section: Contributors
-
-    if (!empty(flash.contributorContribs)) {
-      const contributors = sections.contributors = {};
-
-      contributors.heading =
-        relation('generateContentHeading');
-
-      contributors.list =
-        relation('generateContributionList', flash.contributorContribs);
-    }
-
-    // Section: Artist commentary
-
-    if (flash.commentary) {
-      sections.artistCommentary =
-        relation('generateCommentarySection', flash.commentary);
-    }
-
-    return relations;
-  },
+        .map(url => relation('linkExternal', url)),
+
+    artworkColumn:
+      relation('generateFlashArtworkColumn', flash),
+
+    contentHeading:
+      relation('generateContentHeading'),
+
+    flashActLink:
+      relation('linkFlashAct', flash.act),
+
+    flashNavAccent:
+      relation('generateFlashNavAccent', flash),
+
+    featuredTracksList:
+      relation('generateTrackList', flash.featuredTracks),
+
+    contributorContributionList:
+      relation('generateContributionList', flash.contributorContribs),
+
+    artistCommentaryEntries:
+      flash.commentary
+        .map(entry => relation('generateCommentaryEntry', entry)),
+
+    creditSourceEntries:
+      flash.commentary
+        .map(entry => relation('generateCommentaryEntry', entry)),
+  }),
+
+  data: (_query, flash) => ({
+    name:
+      flash.name,
+
+    color:
+      flash.color,
+
+    date:
+      flash.date,
+  }),
+
+  generate: (data, relations, {html, language}) =>
+    language.encapsulate('flashPage', pageCapsule =>
+      relations.layout.slots({
+        title:
+          language.$(pageCapsule, 'title', {
+            flash: data.name,
+          }),
+
+        color: data.color,
+        headingMode: 'sticky',
+
+        additionalNames: relations.additionalNamesBox,
+
+        artworkColumnContent: relations.artworkColumn,
+
+        mainContent: [
+          html.tag('p',
+            language.$('releaseInfo.released', {
+              date: language.formatDate(data.date),
+            })),
+
+          html.tag('p',
+            {[html.onlyIfContent]: true},
+
+            language.$('releaseInfo.playOn', {
+              [language.onlyIfOptions]: ['links'],
+
+              links:
+                language.formatDisjunctionList(
+                  relations.externalLinks
+                    .map(link => link.slot('context', 'flash'))),
+            })),
+
+          html.tag('p',
+            {[html.onlyIfContent]: true},
+            {[html.joinChildren]: html.tag('br')},
+
+            language.encapsulate('releaseInfo', capsule => [
+              !html.isBlank(relations.artistCommentaryEntries) &&
+                language.encapsulate(capsule, 'readCommentary', capsule =>
+                  language.$(capsule, {
+                    link:
+                      html.tag('a',
+                        {href: '#artist-commentary'},
+                        language.$(capsule, 'link')),
+                  })),
+
+              !html.isBlank(relations.creditSourceEntries) &&
+                language.encapsulate(capsule, 'readCreditSources', capsule =>
+                  language.$(capsule, {
+                    link:
+                      html.tag('a',
+                        {href: '#credit-sources'},
+                        language.$(capsule, 'link')),
+                  })),
+            ])),
+
+          html.tags([
+            relations.contentHeading.clone()
+              .slots({
+                attributes: {id: 'features'},
+                title:
+                  language.$('releaseInfo.tracksFeatured', {
+                    flash: html.tag('i', data.name),
+                  }),
+              }),
 
-  data(query, flash) {
-    const data = {};
+            relations.featuredTracksList,
+          ]),
 
-    data.name = flash.name;
-    data.color = flash.color;
-    data.date = flash.date;
+          html.tags([
+            relations.contentHeading.clone()
+              .slots({
+                attributes: {id: 'contributors'},
+                title: language.$('releaseInfo.contributors'),
+              }),
 
-    return data;
-  },
+            relations.contributorContributionList.slots({
+              chronologyKind: 'flash',
+            }),
+          ]),
 
-  generate(data, relations, {html, language}) {
-    const {sections: sec} = relations;
-
-    return relations.layout.slots({
-      title:
-        language.$('flashPage.title', {
-          flash: data.name,
-        }),
-
-      color: data.color,
-      headingMode: 'sticky',
-
-      cover:
-        (relations.cover
-          ? relations.cover.slots({
-              alt: language.$('misc.alt.flashArt'),
-            })
-          : null),
-
-      mainContent: [
-        html.tag('p',
-          language.$('releaseInfo.released', {
-            date: language.formatDate(data.date),
-          })),
-
-        html.tag('p',
-          {[html.onlyIfContent]: true},
-          language.$('releaseInfo.playOn', {
-            [language.onlyIfOptions]: ['links'],
-            links:
-              language.formatDisjunctionList(
-                relations.externalLinks
-                  .map(link => link.slot('context', 'flash'))),
-          })),
-
-        html.tag('p',
-          {[html.onlyIfContent]: true},
-          {[html.joinChildren]: html.tag('br')},
-
-          [
-            sec.artistCommentary &&
-              language.$('releaseInfo.readCommentary', {
-                link: html.tag('a',
-                  {href: '#artist-commentary'},
-                  language.$('releaseInfo.readCommentary.link')),
+          html.tags([
+            relations.contentHeading.clone()
+              .slots({
+                attributes: {id: 'artist-commentary'},
+                title: language.$('misc.artistCommentary'),
               }),
+
+            relations.artistCommentaryEntries,
           ]),
 
-        sec.featuredTracks && [
-          sec.featuredTracks.heading
-            .slots({
-              attributes: {id: 'features'},
-              title:
-                language.$('releaseInfo.tracksFeatured', {
-                  flash: html.tag('i', data.name),
-                }),
-            }),
+          html.tags([
+            relations.contentHeading.clone()
+              .slots({
+                attributes: {id: 'credit-sources'},
+                title: language.$('misc.creditSources'),
+              }),
 
-          sec.featuredTracks.list,
+            relations.creditSourceEntries,
+          ]),
         ],
 
-        sec.contributors && [
-          sec.contributors.heading
-            .slots({
-              attributes: {id: 'contributors'},
-              title: language.$('releaseInfo.contributors'),
-            }),
-
-          sec.contributors.list,
+        navLinkStyle: 'hierarchical',
+        navLinks: [
+          {auto: 'home'},
+          {html: relations.flashActLink.slot('color', false)},
+          {auto: 'current'},
         ],
 
-        sec.artistCommentary,
-      ],
-
-      navLinkStyle: 'hierarchical',
-      navLinks: [
-        {auto: 'home'},
-        {html: sec.nav.flashActLink.slot('color', false)},
-        {auto: 'current'},
-      ],
+        navBottomRowContent: relations.flashNavAccent,
 
-      navBottomRowContent: sec.nav.flashNavAccent,
-
-      leftSidebar: relations.sidebar,
-    });
-  },
+        leftSidebar: relations.sidebar,
+      })),
 };