« get me outta code hell

data steps: content function evaluation essentials - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/content/dependencies/generateAlbumInfoPageContent.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-23 15:00:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-03-23 15:01:16 -0300
commit8ab00d99fa2f14ac983f0693552b26e4050a939c (patch)
tree1d75c569eec9472c95b24f5072d8d145bf709ee3 /src/content/dependencies/generateAlbumInfoPageContent.js
parent95465bae3aaa92cb617c873bcbbfe8906bea7506 (diff)
data steps: content function evaluation essentials
Also some more actual content in generateAlbumInfoPageContent,
which is in fact fully working as-is(!!).
Diffstat (limited to 'src/content/dependencies/generateAlbumInfoPageContent.js')
-rw-r--r--src/content/dependencies/generateAlbumInfoPageContent.js96
1 files changed, 46 insertions, 50 deletions
diff --git a/src/content/dependencies/generateAlbumInfoPageContent.js b/src/content/dependencies/generateAlbumInfoPageContent.js
index 013ab3f4..236e550e 100644
--- a/src/content/dependencies/generateAlbumInfoPageContent.js
+++ b/src/content/dependencies/generateAlbumInfoPageContent.js
@@ -2,9 +2,12 @@ import {accumulateSum, empty} from '../../util/sugar.js';
 
 export default {
   contentDependencies: [
+    'generateAdditionalFilesShortcut',
     'generateAlbumAdditionalFilesList',
     'generateContributionLinks',
     'generateContentHeading',
+    'linkAlbumCommentary',
+    'linkAlbumGallery',
   ],
 
   extraDependencies: [
@@ -18,9 +21,9 @@ export default {
 
     const contributionLinksRelation = contribs =>
       relation('generateContributionLinks', contribs, {
-        showContrib: true,
+        showContribution: true,
         showIcons: true,
-      })
+      });
 
     relations.artistLinks =
       contributionLinksRelation(album.artistContribs);
@@ -37,7 +40,20 @@ export default {
     const contentHeadingRelation = () =>
       relation('generateContentHeading');
 
+    if (album.tracks.some(t => t.hasUniqueCoverArt)) {
+      relations.galleryLink =
+        relation('linkAlbumGallery', album);
+    }
+
+    if (album.commentary || album.tracks.some(t => t.commentary)) {
+      relations.commentaryLink =
+        relation('linkAlbumCommentary', album);
+    }
+
     if (!empty(album.additionalFiles)) {
+      relations.additionalFilesShortcut =
+        relation('generateAdditionalFilesShortcut', album.additionalFiles);
+
       relations.additionalFilesHeading =
         contentHeadingRelation();
 
@@ -84,29 +100,29 @@ export default {
 
     content.main = {
       headingMode: 'sticky',
-      content: [
+      content: html.tag(null, [
         html.tag('p',
           {
             [html.onlyIfContent]: true,
             [html.joinChildren]: '<br>',
           },
           [
-            !empty(relations.artistLinks) &&
+            relations.artistLinks &&
               language.$('releaseInfo.by', {
                 artists: relations.artistLinks,
               }),
 
-            !empty(relations.coverArtistLinks) &&
+            relations.coverArtistLinks &&
               language.$('releaseInfo.coverArtBy', {
                 artists: relations.coverArtistLinks,
               }),
 
-            !empty(relations.wallpaperArtistLinks) &&
+            relations.wallpaperArtistLinks &&
               language.$('releaseInfo.wallpaperArtBy', {
                 artists: relations.wallpaperArtistLinks,
               }),
 
-            !empty(relations.bannerArtistLinks) &&
+            relations.bannerArtistLinks &&
               language.$('releaseInfo.bannerArtBy', {
                 artists: relations.bannerArtistLinks,
               }),
@@ -130,31 +146,30 @@ export default {
               }),
           ]),
 
-        /*
-          html.tag('p',
-            {
-              [html.onlyIfContent]: true,
-              [html.joinChildren]: '<br>',
-            },
-            [
-              hasAdditionalFiles &&
-                generateAdditionalFilesShortcut(album.additionalFiles),
+        html.tag('p',
+          {
+            [html.onlyIfContent]: true,
+            [html.joinChildren]: html.tag('br'),
+          },
+          [
+            relations.additionalFilesShortcut,
 
-              checkGalleryPage(album) &&
-                language.$('releaseInfo.viewGallery', {
-                  link: link.albumGallery(album, {
-                    text: language.$('releaseInfo.viewGallery.link'),
-                  }),
-                }),
+            relations.galleryLink &&
+              language.$('releaseInfo.viewGallery', {
+                link:
+                  relations.galleryLink
+                    .slot('text', language.$('releaseInfo.viewGallery.link')),
+              }),
 
-              checkCommentaryPage(album) &&
-                language.$('releaseInfo.viewCommentary', {
-                  link: link.albumCommentary(album, {
-                    text: language.$('releaseInfo.viewCommentary.link'),
-                  }),
-                }),
-            ]),
+            relations.commentaryLink &&
+              language.$('releaseInfo.viewCommentary', {
+                link:
+                  relations.commentaryLink
+                    .slot('text', language.$('releaseInfo.viewCommentary.link')),
+              }),
+          ]),
 
+        /*
           !empty(album.urls) &&
             html.tag('p',
               language.$('releaseInfo.listenOn', {
@@ -204,25 +219,6 @@ export default {
                   ),
                 })
             ]),
-
-          ...html.fragment(
-            hasAdditionalFiles && [
-              generateContentHeading({
-                id: 'additional-files',
-                title: language.$('releaseInfo.additionalFiles.heading', {
-                  additionalFiles: language.countAdditionalFiles(numAdditionalFiles, {
-                    unit: true,
-                  }),
-                }),
-              }),
-
-              generateAlbumAdditionalFilesList(album, album.additionalFiles, {
-                generateAdditionalFilesList,
-                getSizeOfAdditionalFile,
-                link,
-                urls,
-              }),
-            ]),
         */
 
         relations.additionalFilesList && [
@@ -240,12 +236,12 @@ export default {
         data.artistCommentary && [
           relations.artistCommentaryHeading
             .slot('id', 'artist-commentary')
-            .slot('title', language.$('releaseDate.artistCommentary')),
+            .slot('title', language.$('releaseInfo.artistCommentary')),
 
           html.tag('blockquote',
             transformMultiline(data.artistCommentary)),
         ],
-      ]
+      ]),
     };
 
     return content;