« get me outta code hell

content: generateFlashInfoPage - 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:
author(quasar) nebula <qznebula@protonmail.com>2023-08-10 11:01:25 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-08-10 11:01:25 -0300
commit178397c9af193b2cebd3f8552b1e725a7b432b48 (patch)
treef32f55db95dfedd74b0098be1c4b310fe1e5c567 /src/content/dependencies/generateFlashInfoPage.js
parent84757d1e54f9cb8825b041368b55e01ba0d4b17b (diff)
content: generateFlashInfoPage
...Except the sidebar, which will be some shenanigans.
Diffstat (limited to 'src/content/dependencies/generateFlashInfoPage.js')
-rw-r--r--src/content/dependencies/generateFlashInfoPage.js148
1 files changed, 141 insertions, 7 deletions
diff --git a/src/content/dependencies/generateFlashInfoPage.js b/src/content/dependencies/generateFlashInfoPage.js
index 4316d7c1..af92ddff 100644
--- a/src/content/dependencies/generateFlashInfoPage.js
+++ b/src/content/dependencies/generateFlashInfoPage.js
@@ -1,38 +1,172 @@
+import {empty} from '../../util/sugar.js';
+
 export default {
-  contentDependencies: ['generatePageLayout'],
+  contentDependencies: [
+    'generateContentHeading',
+    'generateContributionList',
+    'generateFlashCoverArtwork',
+    'generateFlashNavAccent',
+    'generatePageLayout',
+    'generateTrackList',
+    'linkExternal',
+    'linkFlashIndex',
+  ],
+
   extraDependencies: ['html', 'language'],
 
-  relations(relation) {
+  query(flash) {
+    const query = {};
+
+    if (flash.page || !empty(flash.urls)) {
+      query.urls = [];
+
+      if (flash.page) {
+        query.urls.push(`https://homestuck.com/story/${flash.page}`);
+      }
+
+      if (!empty(flash.urls)) {
+        query.urls.push(...flash.urls);
+      }
+    }
+
+    return query;
+  },
+
+  relations(relation, query, flash) {
     const relations = {};
+    const sections = relations.sections = {};
 
     relations.layout =
       relation('generatePageLayout');
 
+    if (query.urls) {
+      relations.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.flashIndexLink =
+      relation('linkFlashIndex');
+
+    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);
+    }
+
     return relations;
   },
 
-  data(flash) {
-    return {
-      name: flash.name,
-    };
+  data(query, flash) {
+    const data = {};
+
+    data.name = flash.name;
+    data.color = flash.color;
+    data.date = flash.date;
+
+    return data;
   },
 
   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', `Alright alright, this is a stub page! Coming soon!`),
+        html.tag('p',
+          language.$('releaseInfo.released', {
+            date: language.formatDate(data.date),
+          })),
+
+        relations.externalLinks &&
+          html.tag('p',
+            language.$('releaseInfo.playOn', {
+              links:
+                language.formatDisjunctionList(
+                  relations.externalLinks
+                    .map(link => link.slot('mode', 'flash'))),
+            })),
+
+        sec.featuredTracks && [
+          sec.featuredTracks.heading
+            .slots({
+              id: 'features',
+              title:
+                language.$('releaseInfo.tracksFeatured', {
+                  flash: html.tag('i', data.name),
+                }),
+            }),
+
+          sec.featuredTracks.list,
+        ],
+
+        sec.contributors && [
+          sec.contributors.heading
+            .slots({
+              id: 'contributors',
+              title: language.$('releaseInfo.contributors'),
+            }),
+
+          sec.contributors.list,
+        ],
       ],
 
       navLinkStyle: 'hierarchical',
       navLinks: [
         {auto: 'home'},
+        {html: sec.nav.flashIndexLink},
         {auto: 'current'},
       ],
+
+      navBottomRowContent:
+        sec.nav.flashNavAccent.slots({
+          showFlashNavigation: true,
+        }),
     });
   },
 };