« get me outta code hell

new All Sheet Music listing - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/listing-spec.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-03-03 10:11:44 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-03-03 10:11:44 -0400
commit64990187b7a35b3c1db8e169f83591b557bb9121 (patch)
tree9a883ae4aff13e889ccab88d179e752eae40f9c3 /src/listing-spec.js
parente1db565e4059a2e26e2c0e56a6f3f3ae738ea2b7 (diff)
new All Sheet Music listing
Diffstat (limited to 'src/listing-spec.js')
-rw-r--r--src/listing-spec.js59
1 files changed, 56 insertions, 3 deletions
diff --git a/src/listing-spec.js b/src/listing-spec.js
index 29b7645..e86fb40 100644
--- a/src/listing-spec.js
+++ b/src/listing-spec.js
@@ -944,10 +944,63 @@ const listingSpec = [
   },
 
   {
-    // Holy beans the spaghetti LOL
+    directory: 'all-sheet-music',
+    stringsKey: 'other.allSheetMusic',
+    groupUnderOther: true,
 
+    data: ({wikiData: {albumData}}) =>
+      albumData
+        .map(album => ({
+          album,
+          tracks: album.tracks.filter(t => !empty(t.sheetMusicFiles)),
+        }))
+        .filter(({tracks}) => !empty(tracks)),
+
+    html: (data, {
+      html,
+      language,
+      link,
+    }) =>
+      data.flatMap(({album, tracks}) => [
+        html.tag('h3', link.album(album)),
+
+        html.tag('dl', tracks.flatMap(track => [
+          // No hash here since the full list of sheet music is already visible below.
+          // The track link serves more as a quick way to recall which track it is or
+          // visit listening links, all of which is positioned at the top of the page.
+          html.tag('dt', link.track(track)),
+          html.tag('dd',
+            // This page doesn't really look better with color-coded sheet music links.
+            // Track links are still colored.
+            /* {style: getLinkThemeString(track.color)}, */
+            html.tag('ul', track.sheetMusicFiles.map(({title, files}) =>
+              html.tag('li',
+                {class: [files.length > 1 && 'has-details']},
+                (files.length === 1
+                  ? link.albumAdditionalFile(
+                      {album, file: files[0]},
+                      {
+                        text: language.$('listingPage.other.allSheetMusic.sheetMusicLink', {title}),
+                      })
+                  : html.tag('details', [
+                      html.tag('summary',
+                        html.tag('span',
+                          language.$('listingPage.other.allSheetMusic.sheetMusicLink.withMultipleFiles', {
+                            title: html.tag('span', {class: 'group-name'}, title),
+                            files: language.countAdditionalFiles(files.length, {unit: true}),
+                          }))),
+                      html.tag('ul', files.map(file =>
+                        html.tag('li',
+                          link.albumAdditionalFile({album, file})))),
+                    ])))))),
+        ])),
+      ]),
+  },
+
+  {
     directory: 'random',
     stringsKey: 'other.randomPages',
+    groupUnderOther: true,
 
     data: ({wikiData: {albumData}}) => [
       {
@@ -1040,7 +1093,7 @@ const listingSpec = [
 ];
 
 const filterListings = (directoryPrefix) =>
-  listingSpec.filter((l) => l.directory.startsWith(directoryPrefix));
+  listingSpec.filter(l => l.directory.startsWith(directoryPrefix));
 
 const listingTargetSpec = [
   {
@@ -1065,7 +1118,7 @@ const listingTargetSpec = [
   },
   {
     title: ({language}) => language.$('listingPage.target.other'),
-    listings: [listingSpec.find((l) => l.directory === 'random')],
+    listings: listingSpec.filter(l => l.groupUnderOther),
   },
 ];