diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/misc-templates.js | 20 | ||||
-rw-r--r-- | src/page/album.js | 9 | ||||
-rw-r--r-- | src/page/artist.js | 56 | ||||
-rw-r--r-- | src/page/group.js | 26 | ||||
-rw-r--r-- | src/page/track.js | 5 | ||||
-rw-r--r-- | src/strings-default.json | 3 | ||||
-rw-r--r-- | src/util/wiki-data.js | 19 |
7 files changed, 70 insertions, 68 deletions
diff --git a/src/misc-templates.js b/src/misc-templates.js index 995aaa2b..6289a737 100644 --- a/src/misc-templates.js +++ b/src/misc-templates.js @@ -11,10 +11,6 @@ import { } from './util/colors.js'; import { - UNRELEASED_TRACKS_DIRECTORY -} from './util/magic-constants.js'; - -import { unique } from './util/sugar.js'; @@ -75,19 +71,15 @@ export function generateChronologyLinks(currentThing, { } return contributions.map(({ who: artist }) => { - const things = sortByDate(unique(getThings(artist)), dateKey); - const releasedThings = things.filter(thing => { - const album = albumData.includes(thing) ? thing : thing.album; - return !(album && album.directory === UNRELEASED_TRACKS_DIRECTORY); - }); - const index = releasedThings.indexOf(currentThing); + const things = sortByDate(unique(getThings(artist)).filter(t => t[dateKey]), dateKey); + const index = things.indexOf(currentThing); if (index === -1) return ''; // TODO: This can pro8a8ly 8e made to use generatePreviousNextLinks? // We'd need to make generatePreviousNextLinks use toAnythingMan tho. - const previous = releasedThings[index - 1]; - const next = releasedThings[index + 1]; + const previous = things[index - 1]; + const next = things[index + 1]; const parts = [ previous && linkAnythingMan(previous, { color: false, @@ -99,6 +91,10 @@ export function generateChronologyLinks(currentThing, { }) ].filter(Boolean); + if (!parts.length) { + return ''; + } + const stringOpts = { index: strings.count.index(index + 1, {strings}), artist: link.artist(artist) 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 && diff --git a/src/strings-default.json b/src/strings-default.json index 1fc6d8a4..1c5fbc68 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -172,6 +172,7 @@ "artistPage.title": "{ARTIST}", "artistPage.creditList.album": "{ALBUM}", "artistPage.creditList.album.withDate": "{ALBUM} ({DATE})", + "artistPage.creditList.album.withDuration": "{ALBUM} ({DURATION})", "artistPage.creditList.album.withDate.withDuration": "{ALBUM} ({DATE}; {DURATION})", "artistPage.creditList.flashAct": "{ACT}", "artistPage.creditList.flashAct.withDateRange": "{ACT} ({DATE_RANGE})", @@ -191,7 +192,6 @@ "artistPage.artGroupsLine": "Contributed art to groups: {GROUPS}", "artistPage.groupsLine.item": "{GROUP} ({CONTRIBUTIONS})", "artistPage.trackList.title": "Tracks", - "artistPage.unreleasedTrackList.title": "Unreleased Tracks", "artistPage.artList.title": "Art", "artistPage.flashList.title": "Flashes & Games", "artistPage.commentaryList.title": "Commentary", @@ -217,6 +217,7 @@ "groupInfoPage.viewAlbumGallery.link": "album gallery", "groupInfoPage.albumList.title": "Albums", "groupInfoPage.albumList.item": "({YEAR}) {ALBUM}", + "groupInfoPage.albumList.item.withoutYear": "{ALBUM}", "groupInfoPage.albumList.item.withAccent": "{ITEM} {ACCENT}", "groupInfoPage.albumList.item.otherGroupAccent": "(from {GROUP})", "groupGalleryPage.title": "{GROUP} - Gallery", diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index 6891a4c6..6d0db2c7 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -83,7 +83,24 @@ export function sortByDate(data, dateKey = 'date') { // Just to 8e clear: sort is a mutating function! I only return the array // 8ecause then you don't have to define it as a separate varia8le 8efore // passing it into this function. - return data.sort((a, b) => a[dateKey] - b[dateKey]); + return data.sort(({ [dateKey]: a }, { [dateKey]: b }) => { + // It's possible for objects with and without dates to be mixed + // together in the same array. If that's the case, we put all items + // without dates at the end. + if (a && b) { + return a - b; + } else if (a) { + return -1; + } else if (b) { + return 1; + } else { + // If neither of the items being compared have a date, don't move + // them relative to each other. This is basically the same as + // filtering out all non-date items and then pushing them at the + // end after sorting the rest. + return 0; + } + }); } // Same details as the sortByDate, 8ut for covers~ |