From 71de050864a42afcaeb409c11b9c792653cf2f1b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 20 Feb 2022 00:24:56 -0400 Subject: basic page writes --- src/page/album.js | 27 ++++++++++++++++++-------- src/page/track.js | 58 ++++++++++++++++++++++++------------------------------- 2 files changed, 44 insertions(+), 41 deletions(-) (limited to 'src/page') diff --git a/src/page/album.js b/src/page/album.js index 6e8d6dbc..1ebfdecc 100644 --- a/src/page/album.js +++ b/src/page/album.js @@ -164,9 +164,11 @@ export function write(album, {wikiData}) { strings('releaseInfo.released', { date: strings.count.date(album.date) }), - +album.coverArtDate !== +album.date && strings('releaseInfo.artReleased', { - date: strings.count.date(album.coverArtDate) - }), + (album.coverArtDate && + +album.coverArtDate !== +album.date && + strings('releaseInfo.artReleased', { + date: strings.count.date(album.coverArtDate) + })), strings('releaseInfo.duration', { duration: strings.count.duration(albumDuration, {approximate: album.tracks.length > 1}) }) @@ -179,7 +181,7 @@ export function write(album, {wikiData}) { }) }) }

`} - ${album.urls.length && `

${ + ${album.urls?.length && `

${ strings('releaseInfo.listenOn', { links: strings.list.or(album.urls.map(url => fancifyURL(url, {album: true}))) }) @@ -263,12 +265,16 @@ export function generateAlbumSidebar(album, currentTrack, { }) { const listTag = getAlbumListTag(album); + /* const trackGroups = album.trackGroups || [{ name: strings('albumSidebar.trackList.fallbackGroupName'), color: album.color, startIndex: 0, tracks: album.tracks }]; + */ + + const { trackGroups } = album; const trackToListItem = track => html.tag('li', {class: track === currentTrack && 'current'}, @@ -276,9 +282,14 @@ export function generateAlbumSidebar(album, currentTrack, { track: link.track(track) })); + const nameOrDefault = (isDefaultTrackGroup, name) => + (isDefaultTrackGroup + ? strings('albumSidebar.trackList.fallbackGroupName') + : name); + const trackListPart = fixWS`

${link.album(album)}

- ${trackGroups.map(({ name, color, startIndex, tracks }) => + ${trackGroups.map(({ name, color, startIndex, tracks, isDefaultTrackGroup }) => html.tag('details', { // Leave side8ar track groups collapsed on al8um homepage, // since there's already a view of all the groups expanded @@ -290,11 +301,11 @@ export function generateAlbumSidebar(album, currentTrack, { {style: getLinkThemeString(color)}, (listTag === 'ol' ? strings('albumSidebar.trackList.group.withRange', { - group: `${name}`, + group: `${nameOrDefault(isDefaultTrackGroup, name)}`, range: `${startIndex + 1}–${startIndex + tracks.length}` }) : strings('albumSidebar.trackList.group', { - group: `${name}` + group: `${nameOrDefault(isDefaultTrackGroup, name)}` })) ), fixWS` @@ -319,7 +330,7 @@ export function generateAlbumSidebar(album, currentTrack, { }) } ${!currentTrack && transformMultiline(group.descriptionShort)} - ${group.urls.length && `

${ + ${group.urls?.length && `

${ strings('releaseInfo.visitOn', { links: strings.list.or(group.urls.map(url => fancifyURL(url))) }) diff --git a/src/page/track.js b/src/page/track.js index b3cec414..a6ec722e 100644 --- a/src/page/track.js +++ b/src/page/track.js @@ -35,23 +35,20 @@ export function targets({wikiData}) { export function write(track, {wikiData}) { const { groupData, wikiInfo } = wikiData; - const { album } = track; + const { album, referencedByTracks, referencedTracks, otherReleases } = track; - const tracksThatReference = track.referencedBy; const useDividedReferences = groupData.some(group => group.directory === OFFICIAL_GROUP_DIRECTORY); - const ttrFanon = (useDividedReferences && - tracksThatReference.filter(t => t.album.groups.every(group => group.directory !== OFFICIAL_GROUP_DIRECTORY))); - const ttrOfficial = (useDividedReferences && - tracksThatReference.filter(t => t.album.groups.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 tracksReferenced = track.references; - const otherReleases = track.otherReleases; const listTag = getAlbumListTag(album); let flashesThatFeature; if (wikiInfo.enableFlashesAndGames) { flashesThatFeature = sortByDate([track, ...otherReleases] - .flatMap(track => track.flashes.map(flash => ({flash, as: track})))); + .flatMap(track => track.featuredInFlashes.map(flash => ({flash, as: track})))); } const unbound_generateTrackList = (tracks, {getArtistString, link, strings}) => html.tag('ul', @@ -59,7 +56,7 @@ export function write(track, {wikiData}) { const line = strings('trackList.item.withArtists', { track: link.track(track), by: `${strings('trackList.item.withArtists.by', { - artists: getArtistString(track.artists) + artists: getArtistString(track.artistContribs) })}` }); return (track.aka @@ -172,13 +169,13 @@ export function write(track, {wikiData}) {

${[ strings('releaseInfo.by', { - artists: getArtistString(track.artists, { + artists: getArtistString(track.artistContribs, { showContrib: true, showIcons: true }) }), track.coverArtists && strings('releaseInfo.coverArtBy', { - artists: getArtistString(track.coverArtists, { + artists: getArtistString(track.coverArtistContribs, { showContrib: true, showIcons: true }) @@ -186,16 +183,18 @@ export function write(track, {wikiData}) { album.directory !== UNRELEASED_TRACKS_DIRECTORY && strings('releaseInfo.released', { date: strings.count.date(track.date) }), - +track.coverArtDate !== +track.date && strings('releaseInfo.artReleased', { - date: strings.count.date(track.coverArtDate) - }), + (track.coverArtDate && + +track.coverArtDate !== +track.date && + strings('releaseInfo.artReleased', { + date: strings.count.date(track.coverArtDate) + })), track.duration && strings('releaseInfo.duration', { duration: strings.count.duration(track.duration) }) ].filter(Boolean).join('
\n')}

${ - (track.urls.length + (track.urls?.length ? strings('releaseInfo.listenOn', { links: strings.list.or(track.urls.map(url => fancifyURL(url, {strings}))) }) @@ -212,17 +211,10 @@ export function write(track, {wikiData}) { `).join('\n')} `} - ${track.contributors.textContent && fixWS` -

- ${strings('releaseInfo.contributors')} -
- ${transformInline(track.contributors.textContent)} -

- `} - ${track.contributors.length && fixWS` + ${track.contributorContribs.length && fixWS`

${strings('releaseInfo.contributors')}

`} - ${tracksReferenced.length && fixWS` + ${referencedTracks.length && fixWS`

${strings('releaseInfo.tracksReferenced', {track: `${track.name}`})}

- ${generateTrackList(tracksReferenced)} + ${generateTrackList(referencedTracks)} `} - ${tracksThatReference.length && fixWS` + ${referencedByTracks.length && fixWS`

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

${useDividedReferences && fixWS`
- ${ttrOfficial.length && fixWS` + ${rbtOfficial.length && fixWS`
${strings('trackPage.referenceList.official')}
-
${generateTrackList(ttrOfficial)}
+
${generateTrackList(rbtOfficial)}
`} - ${ttrFanon.length && fixWS` + ${rbtFanon.length && fixWS`
${strings('trackPage.referenceList.fandom')}
-
${generateTrackList(ttrFanon)}
+
${generateTrackList(rbtFanon)}
`}
`} - ${!useDividedReferences && generateTrackList(tracksThatReference)} + ${!useDividedReferences && generateTrackList(referencedByTracks)} `} ${wikiInfo.enableFlashesAndGames && flashesThatFeature.length && fixWS`

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

-- cgit 1.3.0-6-gf8a5