« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/page
diff options
context:
space:
mode:
Diffstat (limited to 'src/page')
-rw-r--r--src/page/album.js72
-rw-r--r--src/page/flash.js8
-rw-r--r--src/page/group.js14
-rw-r--r--src/page/news.js8
-rw-r--r--src/page/track.js5
5 files changed, 58 insertions, 49 deletions
diff --git a/src/page/album.js b/src/page/album.js
index 11c6da29..1cceead9 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -102,6 +102,7 @@ export function write(album, {wikiData}) {
       generateAdditionalFilesList,
       generateChronologyLinks,
       generateCoverLink,
+      generateNavigationLinks,
       getAlbumCover,
       getAlbumStylesheet,
       getArtistString,
@@ -277,18 +278,19 @@ export function write(album, {wikiData}) {
                   })
               ]),
 
-            hasAdditionalFiles &&
-              generateAdditionalFilesList(album.additionalFiles, {
-                // TODO: Kinda near the metal here...
-                getFileSize: (file) =>
-                  getSizeOfAdditionalFile(
-                    urls.from('media.root').to(
-                      'media.albumAdditionalFile',
-                      album.directory,
-                      file)),
-                linkFile: (file) =>
-                  link.albumAdditionalFile({album, file}),
-              }),
+            ...html.fragment(
+              hasAdditionalFiles &&
+                generateAdditionalFilesList(album.additionalFiles, {
+                  // TODO: Kinda near the metal here...
+                  getFileSize: (file) =>
+                    getSizeOfAdditionalFile(
+                      urls.from('media.root').to(
+                        'media.albumAdditionalFile',
+                        album.directory,
+                        file)),
+                  linkFile: (file) =>
+                    link.albumAdditionalFile({album, file}),
+                })),
 
             ...album.commentary ? [
               html.tag('p', language.$('releaseInfo.artistCommentary')),
@@ -317,7 +319,11 @@ export function write(album, {wikiData}) {
               }),
             },
           ],
-          bottomRowContent: generateAlbumNavLinks(album, null, {language}),
+          bottomRowContent: generateAlbumNavLinks(album, null, {
+            generateNavigationLinks,
+            html,
+            language,
+          }),
           content: generateAlbumChronologyLinks(album, null, {
             generateChronologyLinks,
             html,
@@ -526,33 +532,35 @@ export function generateAlbumSecondaryNav(album, currentTrack, {
   };
 }
 
-export function generateAlbumNavLinks(
-  album,
-  currentTrack,
-  {generatePreviousNextLinks, language}
-) {
+export function generateAlbumNavLinks(album, currentTrack, {
+  generateNavigationLinks,
+  html,
+  language,
+}) {
   const isTrackPage = !!currentTrack;
 
   if (album.tracks.length <= 1) {
     return '';
   }
 
-  const previousNextLinks =
-    isTrackPage &&
-      generatePreviousNextLinks(currentTrack, {
-        data: album.tracks,
-        linkKey: 'track',
-      });
-
-  const randomLink = `<a href="#" data-random="track-in-album" id="random-button">${
-    isTrackPage
+  const randomLink = html.tag('a',
+    {
+      href: '#',
+      dataRandom: 'track-in-album',
+      id: 'random-button'
+    },
+    (isTrackPage
       ? language.$('trackPage.nav.random')
-      : language.$('albumPage.nav.randomTrack')
-  }</a>`;
+      : language.$('albumPage.nav.randomTrack')));
+
+  const navigationLinks =
+    generateNavigationLinks(currentTrack, {
+      additionalLinks: [randomLink],
+      data: album.tracks,
+      linkKey: 'track',
+    });
 
-  return previousNextLinks
-    ? `(${previousNextLinks}<span class="js-hide-until-data">, ${randomLink}</span>)`
-    : `<span class="js-hide-until-data">(${randomLink})</span>`;
+  return `(${navigationLinks})`;
 }
 
 export function generateAlbumChronologyLinks(album, currentTrack, {
diff --git a/src/page/flash.js b/src/page/flash.js
index 3ce7646c..c123c1be 100644
--- a/src/page/flash.js
+++ b/src/page/flash.js
@@ -20,7 +20,7 @@ export function write(flash, {wikiData}) {
       fancifyFlashURL,
       generateChronologyLinks,
       generateCoverLink,
-      generatePreviousNextLinks,
+      generateNavigationLinks,
       getArtistString,
       getFlashCover,
       getThemeString,
@@ -106,7 +106,7 @@ export function write(flash, {wikiData}) {
 
       nav: generateNavForFlash(flash, {
         generateChronologyLinks,
-        generatePreviousNextLinks,
+        generateNavigationLinks,
         html,
         link,
         language,
@@ -195,7 +195,7 @@ export function writeTargetless({
 
 function generateNavForFlash(flash, {
   generateChronologyLinks,
-  generatePreviousNextLinks,
+  generateNavigationLinks,
   html,
   language,
   link,
@@ -203,7 +203,7 @@ function generateNavForFlash(flash, {
 }) {
   const {flashData} = wikiData;
 
-  const previousNextLinks = generatePreviousNextLinks(flash, {
+  const previousNextLinks = generateNavigationLinks(flash, {
     data: flashData,
     linkKey: 'flash',
   });
diff --git a/src/page/group.js b/src/page/group.js
index 9959ec29..ef3813f5 100644
--- a/src/page/group.js
+++ b/src/page/group.js
@@ -26,7 +26,7 @@ export function write(group, {wikiData}) {
     page: ({
       fancifyURL,
       generateInfoGalleryLinks,
-      generatePreviousNextLinks,
+      generateNavigationLinks,
       getLinkThemeString,
       getThemeString,
       html,
@@ -104,7 +104,7 @@ export function write(group, {wikiData}) {
 
       nav: generateGroupNav(group, false, {
         generateInfoGalleryLinks,
-        generatePreviousNextLinks,
+        generateNavigationLinks,
         language,
         link,
         wikiData,
@@ -117,7 +117,7 @@ export function write(group, {wikiData}) {
     path: ['groupGallery', group.directory],
     page: ({
       generateInfoGalleryLinks,
-      generatePreviousNextLinks,
+      generateNavigationLinks,
       getAlbumGridHTML,
       getLinkThemeString,
       getThemeString,
@@ -151,7 +151,7 @@ export function write(group, {wikiData}) {
                 language.formatDuration(totalDuration, {
                   unit: true,
                 })),
-              })),
+            })),
 
           wikiInfo.enableGroupUI &&
           wikiInfo.enableListings &&
@@ -191,7 +191,7 @@ export function write(group, {wikiData}) {
 
       nav: generateGroupNav(group, true, {
         generateInfoGalleryLinks,
-        generatePreviousNextLinks,
+        generateNavigationLinks,
         language,
         link,
         wikiData,
@@ -253,7 +253,7 @@ function generateGroupSidebar(currentGroup, isGallery, {
 
 function generateGroupNav(currentGroup, isGallery, {
   generateInfoGalleryLinks,
-  generatePreviousNextLinks,
+  generateNavigationLinks,
   link,
   language,
   wikiData,
@@ -271,7 +271,7 @@ function generateGroupNav(currentGroup, isGallery, {
     linkKeyInfo: 'groupInfo',
   });
 
-  const previousNextLinks = generatePreviousNextLinks(currentGroup, {
+  const previousNextLinks = generateNavigationLinks(currentGroup, {
     data: groupData,
     linkKey,
   });
diff --git a/src/page/news.js b/src/page/news.js
index 49cee7b9..62f94fb9 100644
--- a/src/page/news.js
+++ b/src/page/news.js
@@ -13,7 +13,7 @@ export function write(entry, {wikiData}) {
     type: 'page',
     path: ['newsEntry', entry.directory],
     page: ({
-      generatePreviousNextLinks,
+      generateNavigationLinks,
       html,
       language,
       link,
@@ -39,7 +39,7 @@ export function write(entry, {wikiData}) {
       },
 
       nav: generateNewsEntryNav(entry, {
-        generatePreviousNextLinks,
+        generateNavigationLinks,
         html,
         language,
         link,
@@ -104,7 +104,7 @@ export function writeTargetless({wikiData}) {
 }
 
 function generateNewsEntryNav(entry, {
-  generatePreviousNextLinks,
+  generateNavigationLinks,
   html,
   language,
   link,
@@ -112,7 +112,7 @@ function generateNewsEntryNav(entry, {
 }) {
   // The newsData list is sorted reverse chronologically (newest ones first),
   // so the way we find next/previous entries is flipped from normal.
-  const previousNextLinks = generatePreviousNextLinks(entry, {
+  const previousNextLinks = generateNavigationLinks(entry, {
     data: newsData.slice().reverse(),
     linkKey: 'newsEntry',
 
diff --git a/src/page/track.js b/src/page/track.js
index 258e11d3..514f2cb0 100644
--- a/src/page/track.js
+++ b/src/page/track.js
@@ -151,7 +151,7 @@ export function write(track, {wikiData}) {
       fancifyURL,
       generateChronologyLinks,
       generateCoverLink,
-      generatePreviousNextLinks,
+      generateNavigationLinks,
       generateTrackListDividedByGroups,
       getAlbumStylesheet,
       getArtistString,
@@ -377,7 +377,8 @@ export function write(track, {wikiData}) {
           bottomRowContent:
             album.tracks.length > 1 &&
               generateAlbumNavLinks(album, track, {
-                generatePreviousNextLinks,
+                generateNavigationLinks,
+                html,
                 language,
               }),
         },