From 789bf78f5c350a98bbf64cb7aa06af6c27aab110 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 27 May 2021 12:18:42 -0300 Subject: fallback "Track list" track group in album sidebar --- src/strings-default.json | 1 + src/upd8.js | 63 ++++++++++++++++++++++++------------------------ 2 files changed, 33 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/strings-default.json b/src/strings-default.json index 031389eb..eac71544 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -150,6 +150,7 @@ "homepage.title": "{TITLE}", "homepage.news.title": "News", "homepage.news.entry.viewRest": "(View rest of entry!)", + "albumSidebar.trackList.fallbackGroupName": "Track list", "albumSidebar.trackList.group": "{GROUP}", "albumSidebar.trackList.group.withRange": "{GROUP} ({RANGE})", "albumSidebar.trackList.item": "{TRACK}", diff --git a/src/upd8.js b/src/upd8.js index 35f7d6ed..5615bb1c 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -5234,6 +5234,13 @@ function generateSidebarForAlbum(album, { }) { const listTag = getAlbumListTag(album); + const trackGroups = album.trackGroups || [{ + name: strings('albumSidebar.trackList.fallbackGroupName'), + color: album.color, + startIndex: 0, + tracks: album.tracks + }]; + const trackToListItem = track => `
  • ${ strings('albumSidebar.trackList.item', { track: link.track(track) @@ -5242,37 +5249,31 @@ function generateSidebarForAlbum(album, { const trackListPart = fixWS`

    ${link.album(album)}

    - ${(album.trackGroups - ? album.trackGroups.map(({ name, color, startIndex, tracks }) => - html.tag('details', { - // Leave side8ar track groups collapsed on al8um homepage, - // since there's already a view of all the groups expanded - // in the main content area. - open: currentTrack && tracks.includes(currentTrack), - class: tracks.includes(currentTrack) && 'current' - }, [ - html.tag('summary', - {style: getLinkThemeString(color)}, - (listTag === 'ol' - ? strings('albumSidebar.trackList.group.withRange', { - group: `${name}`, - range: `${startIndex + 1}–${startIndex + tracks.length}` - }) - : strings('albumSidebar.trackList.group', { - group: `${name}` - })) - ), - fixWS` - <${listTag === 'ol' ? `ol start="${startIndex + 1}"` : listTag}> - ${tracks.map(trackToListItem).join('\n')} - - ` - ])).join('\n') - : fixWS` - <${listTag}> - ${album.tracks.map(trackToListItem).join('\n')} - - `)} + ${trackGroups.map(({ name, color, startIndex, tracks }) => + html.tag('details', { + // Leave side8ar track groups collapsed on al8um homepage, + // since there's already a view of all the groups expanded + // in the main content area. + open: currentTrack && tracks.includes(currentTrack), + class: tracks.includes(currentTrack) && 'current' + }, [ + html.tag('summary', + {style: getLinkThemeString(color)}, + (listTag === 'ol' + ? strings('albumSidebar.trackList.group.withRange', { + group: `${name}`, + range: `${startIndex + 1}–${startIndex + tracks.length}` + }) + : strings('albumSidebar.trackList.group', { + group: `${name}` + })) + ), + fixWS` + <${listTag === 'ol' ? `ol start="${startIndex + 1}"` : listTag}> + ${tracks.map(trackToListItem).join('\n')} + + ` + ])).join('\n')} `; const { groups } = album; -- cgit 1.3.0-6-gf8a5