From f6bd91ea9beef64e0ff0865560219a64a367bb5b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 22 May 2022 12:00:01 -0300 Subject: divide referenced-by lists by configurable groups ...instead of hard-coding 'em --- src/page/album.js | 2 +- src/page/track.js | 53 +++++++++++++++++++---------------------------------- 2 files changed, 20 insertions(+), 35 deletions(-) (limited to 'src/page') diff --git a/src/page/album.js b/src/page/album.js index ec994ebb..70cb5367 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -205,7 +205,7 @@ export function write(album, {wikiData}) {
${album.trackGroups.map(({ name, color, startIndex, tracks }) => fixWS`
${ - language.$('trackList.group', { + language.$('trackList.section.withDuration', { duration: language.formatDuration(getTotalDuration(tracks), {approximate: tracks.length > 1}), group: name }) diff --git a/src/page/track.js b/src/page/track.js index 3295d48a..22e6c9da 100644 --- a/src/page/track.js +++ b/src/page/track.js @@ -12,10 +12,6 @@ import { import * as html from '../util/html.js'; -import { - OFFICIAL_GROUP_DIRECTORY -} from '../util/magic-constants.js'; - import { bindOpts } from '../util/sugar.js'; @@ -36,12 +32,6 @@ export function write(track, {wikiData}) { const { groupData, wikiInfo } = wikiData; const { album, referencedByTracks, referencedTracks, otherReleases } = track; - const useDividedReferences = groupData.some(group => group.directory === OFFICIAL_GROUP_DIRECTORY); - const rbtFanon = (useDividedReferences && - referencedByTracks.filter(t => t.album.groups.every(group => group.directory !== OFFICIAL_GROUP_DIRECTORY))); - const rbtOfficial = (useDividedReferences && - referencedByTracks.filter(t => t.album.groups.some(group => group.directory === OFFICIAL_GROUP_DIRECTORY))); - const listTag = getAlbumListTag(album); let flashesThatFeature; @@ -50,18 +40,20 @@ export function write(track, {wikiData}) { .flatMap(track => track.featuredInFlashes.map(flash => ({flash, as: track})))); } + const unbound_getTrackItem = (track, {getArtistString, link, language}) => { + const line = language.$('trackList.item.withArtists', { + track: link.track(track), + by: `${language.$('trackList.item.withArtists.by', { + artists: getArtistString(track.artistContribs) + })}` + }); + return (track.aka + ? `
  • ${language.$('trackList.item.rerelease', {track: line})}
  • ` + : `
  • ${line}
  • `); + }; + const unbound_generateTrackList = (tracks, {getArtistString, link, language}) => html.tag('ul', - tracks.map(track => { - const line = language.$('trackList.item.withArtists', { - track: link.track(track), - by: `${language.$('trackList.item.withArtists.by', { - artists: getArtistString(track.artistContribs) - })}` - }); - return (track.aka - ? `
  • ${language.$('trackList.item.rerelease', {track: line})}
  • ` - : `
  • ${line}
  • `); - }) + tracks.map(track => unbound_getTrackItem(track, {getArtistString, link, language})) ); const hasCommentary = track.commentary || otherReleases.some(t => t.commentary); @@ -150,6 +142,7 @@ export function write(track, {wikiData}) { generateChronologyLinks, generateCoverLink, generatePreviousNextLinks, + generateTrackListDividedByGroups, getAlbumStylesheet, getArtistString, getLinkThemeString, @@ -164,6 +157,7 @@ export function write(track, {wikiData}) { urls, }) => { const generateTrackList = bindOpts(unbound_generateTrackList, {getArtistString, link, language}); + const getTrackItem = bindOpts(unbound_getTrackItem, {getArtistString, link, language}); const cover = getTrackCover(track); return { @@ -264,19 +258,10 @@ export function write(track, {wikiData}) { `} ${referencedByTracks.length && fixWS`

    ${language.$('releaseInfo.tracksThatReference', {track: `${track.name}`})}

    - ${useDividedReferences && fixWS` -
    - ${rbtOfficial.length && fixWS` -
    ${language.$('trackPage.referenceList.official')}
    -
    ${generateTrackList(rbtOfficial)}
    - `} - ${rbtFanon.length && fixWS` -
    ${language.$('trackPage.referenceList.fandom')}
    -
    ${generateTrackList(rbtFanon)}
    - `} -
    - `} - ${!useDividedReferences && generateTrackList(referencedByTracks)} + ${generateTrackListDividedByGroups(referencedByTracks, { + getTrackItem, + wikiData, + })} `} ${wikiInfo.enableFlashesAndGames && flashesThatFeature.length && fixWS`

    ${language.$('releaseInfo.flashesThatFeature', {track: `${track.name}`})}

    -- cgit 1.3.0-6-gf8a5