« 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.js9
-rw-r--r--src/page/artist.js56
-rw-r--r--src/page/group.js26
-rw-r--r--src/page/track.js5
4 files changed, 42 insertions, 54 deletions
diff --git a/src/page/album.js b/src/page/album.js
index eac0a9f3..66d4bfae 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -168,7 +168,7 @@ export function write(album, {wikiData}) {
                                         showIcons: true
                                     })
                                 }),
-                                strings('releaseInfo.released', {
+                                album.date && strings('releaseInfo.released', {
                                     date: strings.count.date(album.date)
                                 }),
                                 (album.coverArtDate &&
@@ -328,9 +328,10 @@ export function generateAlbumSidebar(album, currentTrack, {
     const { groups } = album;
 
     const groupParts = groups.map(group => {
-        const index = group.albums.indexOf(album);
-        const next = group.albums[index + 1];
-        const previous = group.albums[index - 1];
+        const albums = group.albums.filter(album => album.date);
+        const index = albums.indexOf(album);
+        const next = index >= 0 && albums[index + 1];
+        const previous = index > 0 && albums[index - 1];
         return {group, next, previous};
     }).map(({group, next, previous}) => fixWS`
         <h1>${
diff --git a/src/page/artist.js b/src/page/artist.js
index 38ca76d6..146b75a5 100644
--- a/src/page/artist.js
+++ b/src/page/artist.js
@@ -9,10 +9,6 @@ import fixWS from 'fix-whitespace';
 import * as html from '../util/html.js';
 
 import {
-    UNRELEASED_TRACKS_DIRECTORY
-} from '../util/magic-constants.js';
-
-import {
     bindOpts,
     unique
 } from '../util/sugar.js';
@@ -82,9 +78,6 @@ export function write(artist, {wikiData}) {
         ...artist.tracksAsContributor ?? []
     ]));
 
-    const unreleasedTracks = allTracks.filter(track => track.album.directory === UNRELEASED_TRACKS_DIRECTORY);
-    const releasedTracks = allTracks.filter(track => track.album.directory !== UNRELEASED_TRACKS_DIRECTORY);
-
     const chunkTracks = tracks => (
         chunkByProperties(tracks.map(track => ({
             track,
@@ -107,10 +100,8 @@ export function write(artist, {wikiData}) {
             duration: getTotalDuration(chunk),
         })));
 
-    const unreleasedTrackListChunks = chunkTracks(unreleasedTracks);
-    const releasedTrackListChunks = chunkTracks(releasedTracks);
-
-    const totalReleasedDuration = getTotalDuration(releasedTracks);
+    const trackListChunks = chunkTracks(allTracks);
+    const totalDuration = getTotalDuration(allTracks);
 
     const countGroups = things => {
         const usedGroups = things.flatMap(thing => thing.groups || thing.album?.groups || []);
@@ -123,7 +114,7 @@ export function write(artist, {wikiData}) {
             .sort((a, b) => b.contributions - a.contributions);
     };
 
-    const musicGroups = countGroups(releasedTracks);
+    const musicGroups = countGroups(allTracks);
     const artGroups = countGroups(artThingsAll);
 
     let flashes, flashListChunks;
@@ -176,11 +167,20 @@ export function write(artist, {wikiData}) {
     }) => fixWS`
         <dl>
             ${chunks.map(({date, album, chunk, duration}) => fixWS`
-                <dt>${strings('artistPage.creditList.album.withDate.withDuration', {
-                    album: link.album(album),
-                    date: strings.count.date(date),
-                    duration: strings.count.duration(duration, {approximate: true})
-                })}</dt>
+                <dt>${
+                    (date && duration) ? strings('artistPage.creditList.album.withDate.withDuration', {
+                        album: link.album(album),
+                        date: strings.count.date(date),
+                        duration: strings.count.duration(duration, {approximate: true})
+                    }) : date ? strings('artistPage.creditList.album.withDate', {
+                        album: link.album(album),
+                        date: strings.count.date(date)
+                    }) : duration ? strings('artistPage.creditList.album.withDuration', {
+                        album: link.album(album),
+                        duration: strings.count.duration(duration, {approximate: true})
+                    }) : strings('artistPage.creditList.album', {
+                        album: link.album(album)
+                    })}</dt>
                 <dd><ul>
                     ${(chunk
                         .map(({track, ...props}) => ({
@@ -256,10 +256,7 @@ export function write(artist, {wikiData}) {
                 tracks: {
                     asArtist: artist.tracksAsArtist.map(serializeArtistsAndContrib('artistContribs')),
                     asContributor: artist.tracksAsContributor.map(serializeArtistsAndContrib('contributorContribs')),
-                    chunked: {
-                        released: serializeTrackListChunks(releasedTrackListChunks),
-                        unreleased: serializeTrackListChunks(unreleasedTrackListChunks)
-                    }
+                    chunked: serializeTrackListChunks(trackListChunks)
                 }
             };
         }
@@ -312,22 +309,17 @@ export function write(artist, {wikiData}) {
                         })}</p>`}
                         <p>${strings('misc.jumpTo.withLinks', {
                             links: strings.list.unit([
-                                [
-                                    [...releasedTracks, ...unreleasedTracks].length && `<a href="#tracks">${strings('artistPage.trackList.title')}</a>`,
-                                    unreleasedTracks.length && `(<a href="#unreleased-tracks">${strings('artistPage.unreleasedTrackList.title')}</a>)`
-                                ].filter(Boolean).join(' '),
+                                allTracks.length && `<a href="#tracks">${strings('artistPage.trackList.title')}</a>`,
                                 artThingsAll.length && `<a href="#art">${strings('artistPage.artList.title')}</a>`,
                                 wikiInfo.enableFlashesAndGames && flashes.length && `<a href="#flashes">${strings('artistPage.flashList.title')}</a>`,
                                 commentaryThings.length && `<a href="#commentary">${strings('artistPage.commentaryList.title')}</a>`
                             ].filter(Boolean))
                         })}</p>
-                        ${(releasedTracks.length || unreleasedTracks.length) && fixWS`
+                        ${allTracks.length && fixWS`
                             <h2 id="tracks">${strings('artistPage.trackList.title')}</h2>
-                        `}
-                        ${releasedTracks.length && fixWS`
                             <p>${strings('artistPage.contributedDurationLine', {
                                 artist: artist.name,
-                                duration: strings.count.duration(totalReleasedDuration, {approximate: true, unit: true})
+                                duration: strings.count.duration(totalDuration, {approximate: true, unit: true})
                             })}</p>
                             <p>${strings('artistPage.musicGroupsLine', {
                                 groups: strings.list.unit(musicGroups
@@ -336,11 +328,7 @@ export function write(artist, {wikiData}) {
                                         contributions: strings.count.contributions(contributions)
                                     })))
                             })}</p>
-                            ${generateTrackList(releasedTrackListChunks)}
-                        `}
-                        ${unreleasedTracks.length && fixWS`
-                            <h3 id="unreleased-tracks">${strings('artistPage.unreleasedTrackList.title')}</h3>
-                            ${generateTrackList(unreleasedTrackListChunks)}
+                            ${generateTrackList(trackListChunks)}
                         `}
                         ${artThingsAll.length && fixWS`
                             <h2 id="art">${strings('artistPage.artList.title')}</h2>
diff --git a/src/page/group.js b/src/page/group.js
index c51f0e38..0a6cee1e 100644
--- a/src/page/group.js
+++ b/src/page/group.js
@@ -4,10 +4,6 @@
 
 import fixWS from 'fix-whitespace';
 
-import {
-    UNRELEASED_TRACKS_DIRECTORY
-} from '../util/magic-constants.js';
-
 import * as html from '../util/html.js';
 
 import {
@@ -24,9 +20,9 @@ export function targets({wikiData}) {
 export function write(group, {wikiData}) {
     const { listingSpec, wikiInfo } = wikiData;
 
-    const releasedAlbums = group.albums.filter(album => album.directory !== UNRELEASED_TRACKS_DIRECTORY);
-    const releasedTracks = releasedAlbums.flatMap(album => album.tracks);
-    const totalDuration = getTotalDuration(releasedTracks);
+    const { albums } = group;
+    const tracks = albums.flatMap(album => album.tracks);
+    const totalDuration = getTotalDuration(tracks);
 
     const albumLines = group.albums.map(album => ({
         album,
@@ -70,10 +66,14 @@ export function write(group, {wikiData}) {
                     }</p>
                     <ul>
                         ${albumLines.map(({ album, otherGroup }) => {
-                            const item = strings('groupInfoPage.albumList.item', {
-                                year: album.date.getFullYear(),
-                                album: link.album(album)
-                            });
+                            const item = (album.date
+                                ? strings('groupInfoPage.albumList.item', {
+                                    year: album.date.getFullYear(),
+                                    album: link.album(album)
+                                })
+                                : strings('groupInfoPage.albumList.item.withoutYear', {
+                                    album: link.album(album)
+                                }));
                             return html.tag('li', (otherGroup
                                 ? strings('groupInfoPage.albumList.item.withAccent', {
                                     item,
@@ -127,8 +127,8 @@ export function write(group, {wikiData}) {
                     <h1>${strings('groupGalleryPage.title', {group: group.name})}</h1>
                     <p class="quick-info">${
                         strings('groupGalleryPage.infoLine', {
-                            tracks: `<b>${strings.count.tracks(releasedTracks.length, {unit: true})}</b>`,
-                            albums: `<b>${strings.count.albums(releasedAlbums.length, {unit: true})}</b>`,
+                            tracks: `<b>${strings.count.tracks(tracks.length, {unit: true})}</b>`,
+                            albums: `<b>${strings.count.albums(albums.length, {unit: true})}</b>`,
                             time: `<b>${strings.count.duration(totalDuration, {unit: true})}</b>`
                         })
                     }</p>
diff --git a/src/page/track.js b/src/page/track.js
index 960f00ce..c27b2b65 100644
--- a/src/page/track.js
+++ b/src/page/track.js
@@ -13,8 +13,7 @@ import {
 import * as html from '../util/html.js';
 
 import {
-    OFFICIAL_GROUP_DIRECTORY,
-    UNRELEASED_TRACKS_DIRECTORY
+    OFFICIAL_GROUP_DIRECTORY
 } from '../util/magic-constants.js';
 
 import {
@@ -181,7 +180,7 @@ export function write(track, {wikiData}) {
                                         showIcons: true
                                     })
                                 }),
-                                album.directory !== UNRELEASED_TRACKS_DIRECTORY && strings('releaseInfo.released', {
+                                track.date && strings('releaseInfo.released', {
                                     date: strings.count.date(track.date)
                                 }),
                                 (track.coverArtDate &&