« get me outta code hell

basic page writes - 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:
author(quasar) nebula <qznebula@protonmail.com>2022-02-20 00:24:56 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-02-20 00:24:56 -0400
commit71de050864a42afcaeb409c11b9c792653cf2f1b (patch)
tree63e8b1d3d03db4f3504b9c3a65d57223c61b39e2 /src/page
parentf26ad2e27e9c7ca61b6ae5e9b3587786d911a2df (diff)
basic page writes
Diffstat (limited to 'src/page')
-rw-r--r--src/page/album.js27
-rw-r--r--src/page/track.js58
2 files changed, 44 insertions, 41 deletions
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}) {
                                 })
                             })
                         }</p>`}
-                        ${album.urls.length && `<p>${
+                        ${album.urls?.length && `<p>${
                             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`
         <h1>${link.album(album)}</h1>
-        ${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: `<span class="group-name">${name}</span>`,
+                            group: `<span class="group-name">${nameOrDefault(isDefaultTrackGroup, name)}</span>`,
                             range: `${startIndex + 1}&ndash;${startIndex + tracks.length}`
                         })
                         : strings('albumSidebar.trackList.group', {
-                            group: `<span class="group-name">${name}</span>`
+                            group: `<span class="group-name">${nameOrDefault(isDefaultTrackGroup, name)}</span>`
                         }))
                 ),
                 fixWS`
@@ -319,7 +330,7 @@ export function generateAlbumSidebar(album, currentTrack, {
             })
         }</h1>
         ${!currentTrack && transformMultiline(group.descriptionShort)}
-        ${group.urls.length && `<p>${
+        ${group.urls?.length && `<p>${
             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: `<span class="by">${strings('trackList.item.withArtists.by', {
-                    artists: getArtistString(track.artists)
+                    artists: getArtistString(track.artistContribs)
                 })}</span>`
             });
             return (track.aka
@@ -172,13 +169,13 @@ export function write(track, {wikiData}) {
                         <p>
                             ${[
                                 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('<br>\n')}
                         </p>
                         <p>${
-                            (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')}
                             </ul>
                         `}
-                        ${track.contributors.textContent && fixWS`
-                            <p>
-                                ${strings('releaseInfo.contributors')}
-                                <br>
-                                ${transformInline(track.contributors.textContent)}
-                            </p>
-                        `}
-                        ${track.contributors.length && fixWS`
+                        ${track.contributorContribs.length && fixWS`
                             <p>${strings('releaseInfo.contributors')}</p>
                             <ul>
-                                ${(track.contributors
+                                ${(track.contributorContribs
                                     .map(contrib => `<li>${getArtistString([contrib], {
                                         showContrib: true,
                                         showIcons: true
@@ -230,25 +222,25 @@ export function write(track, {wikiData}) {
                                     .join('\n'))}
                             </ul>
                         `}
-                        ${tracksReferenced.length && fixWS`
+                        ${referencedTracks.length && fixWS`
                             <p>${strings('releaseInfo.tracksReferenced', {track: `<i>${track.name}</i>`})}</p>
-                            ${generateTrackList(tracksReferenced)}
+                            ${generateTrackList(referencedTracks)}
                         `}
-                        ${tracksThatReference.length && fixWS`
+                        ${referencedByTracks.length && fixWS`
                             <p>${strings('releaseInfo.tracksThatReference', {track: `<i>${track.name}</i>`})}</p>
                             ${useDividedReferences && fixWS`
                                 <dl>
-                                    ${ttrOfficial.length && fixWS`
+                                    ${rbtOfficial.length && fixWS`
                                         <dt>${strings('trackPage.referenceList.official')}</dt>
-                                        <dd>${generateTrackList(ttrOfficial)}</dd>
+                                        <dd>${generateTrackList(rbtOfficial)}</dd>
                                     `}
-                                    ${ttrFanon.length && fixWS`
+                                    ${rbtFanon.length && fixWS`
                                         <dt>${strings('trackPage.referenceList.fandom')}</dt>
-                                        <dd>${generateTrackList(ttrFanon)}</dd>
+                                        <dd>${generateTrackList(rbtFanon)}</dd>
                                     `}
                                 </dl>
                             `}
-                            ${!useDividedReferences && generateTrackList(tracksThatReference)}
+                            ${!useDividedReferences && generateTrackList(referencedByTracks)}
                         `}
                         ${wikiInfo.enableFlashesAndGames && flashesThatFeature.length && fixWS`
                             <p>${strings('releaseInfo.flashesThatFeature', {track: `<i>${track.name}</i>`})}</p>