diff options
Diffstat (limited to 'src/content')
| -rw-r--r-- | src/content/dependencies/generateAlbumArtInfoBox.js | 118 | ||||
| -rw-r--r-- | src/content/dependencies/generateArtistGroupContributionsInfo.js | 84 | ||||
| -rw-r--r-- | src/content/dependencies/generateCoverGrid.js | 2 |
3 files changed, 139 insertions, 65 deletions
diff --git a/src/content/dependencies/generateAlbumArtInfoBox.js b/src/content/dependencies/generateAlbumArtInfoBox.js index 5491192a..a3b4c02d 100644 --- a/src/content/dependencies/generateAlbumArtInfoBox.js +++ b/src/content/dependencies/generateAlbumArtInfoBox.js @@ -1,3 +1,7 @@ +import {basename} from 'node:path'; + +import {empty} from '#sugar'; + export default { relations: (relation, album) => ({ wallpaperArtistContributionsLine: @@ -11,26 +15,100 @@ export default { ? relation('generateReleaseInfoContributionsLine', album.bannerArtwork.artistContribs) : null), + + linkTemplate: + relation('linkTemplate'), }), - generate: (relations, {html, language}) => - language.encapsulate('releaseInfo', capsule => - html.tag('div', {class: 'album-art-info'}, - {[html.onlyIfContent]: true}, - - html.tag('p', - {[html.onlyIfContent]: true}, - {[html.joinChildren]: html.tag('br')}, - - [ - relations.wallpaperArtistContributionsLine?.slots({ - stringKey: capsule + '.wallpaperArtBy', - chronologyKind: 'wallpaperArt', - }), - - relations.bannerArtistContributionsLine?.slots({ - stringKey: capsule + '.bannerArtBy', - chronologyKind: 'bannerArt', - }), - ]))), + data: (album) => ({ + wallpaperImagePath: + (album.wallpaperArtwork && empty(album.wallpaperParts) + ? album.wallpaperArtwork.path + : null), + + wallpaperPartPaths: + album.wallpaperParts + .filter(part => part.asset) + .map(part => ['media.albumWallpaperPart', album.directory, part.asset]), + + bannerImagePath: + (album.bannerArtwork + ? album.bannerArtwork.path + : null), + }), + + generate: (data, relations, {html, language}) => + html.tag('div', {class: 'album-art-info'}, + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('hr', {class: 'cute'})}, + + [ + language.encapsulate('releaseInfo', capsule => + html.tag('p', + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('br')}, + + [ + relations.wallpaperArtistContributionsLine?.slots({ + stringKey: capsule + '.wallpaperArtBy', + chronologyKind: 'wallpaperArt', + }), + + relations.bannerArtistContributionsLine?.slots({ + stringKey: capsule + '.bannerArtBy', + chronologyKind: 'bannerArt', + }), + ])), + + language.encapsulate('misc.downloadLayoutMedia', downloadCapsule => + html.tag('p', + {[html.onlyIfContent]: true}, + {[html.joinChildren]: html.tag('br')}, + + [ + language.encapsulate(downloadCapsule, workingCapsule => { + const workingOptions = {}; + + let any = false; + + if (data.wallpaperImagePath) { + any = true; + workingCapsule += '.withWallpaper'; + workingOptions.wallpaper = + relations.linkTemplate.clone().slots({ + path: data.wallpaperImagePath, + content: language.$(downloadCapsule, 'wallpaper'), + }); + } + + if (data.bannerImagePath) { + any = true; + workingCapsule += '.withBanner'; + workingOptions.banner = + relations.linkTemplate.clone().slots({ + path: data.bannerImagePath, + content: language.$(downloadCapsule, 'banner'), + }); + } + + if (any) { + return language.$(workingCapsule, workingOptions); + } else { + return html.blank(); + } + }), + + language.$(downloadCapsule, 'withWallpaperParts', { + [language.onlyIfOptions]: ['parts'], + + parts: + language.formatUnitList( + data.wallpaperPartPaths.map(path => + relations.linkTemplate.clone().slots({ + path, + content: language.sanitize(basename(path.at(-1))), + }))), + }), + ])), + ]), }; diff --git a/src/content/dependencies/generateArtistGroupContributionsInfo.js b/src/content/dependencies/generateArtistGroupContributionsInfo.js index 6940053f..72ce0944 100644 --- a/src/content/dependencies/generateArtistGroupContributionsInfo.js +++ b/src/content/dependencies/generateArtistGroupContributionsInfo.js @@ -195,50 +195,46 @@ export default { : slots.title))), html.tag('dd', {class: topLevelClasses}, - html.tag('ul', {class: 'group-contributions-table'}, - {role: 'list'}, - - (slots.sort === 'count' - ? stitchArrays({ - group: relations.groupLinksSortedByCount, - count: getCounts(data.groupCountsSortedByCount), - duration: - getDurations( - data.groupDurationsSortedByCount, - data.groupDurationsApproximateSortedByCount), - }).map(({group, count, duration}) => - language.encapsulate(capsule, 'item', capsule => - html.tag('li', - html.tag('div', {class: 'group-contributions-row'}, [ - group, - html.tag('span', {class: 'group-contributions-metrics'}, - // When sorting by count, duration details aren't necessarily - // available for all items. - (slots.showBothColumns && duration - ? language.$(capsule, 'countDurationAccent', {count, duration}) - : language.$(capsule, 'countAccent', {count}))), - ])))) - - : stitchArrays({ - group: relations.groupLinksSortedByDuration, - count: getCounts(data.groupCountsSortedByDuration), - duration: - getDurations( - data.groupDurationsSortedByDuration, - data.groupDurationsApproximateSortedByDuration), - }).map(({group, count, duration}) => - language.encapsulate(capsule, 'item', capsule => - html.tag('li', - html.tag('div', {class: 'group-contributions-row'}, [ - group, - html.tag('span', {class: 'group-contributions-metrics'}, - // Count details are always available, since they're just the - // number of contributions directly. And duration details are - // guaranteed for every item when sorting by duration. - (slots.showBothColumns - ? language.$(capsule, 'durationCountAccent', {duration, count}) - : language.$(capsule, 'durationAccent', {duration}))), - ]))))))), + html.tag('table', {class: 'group-contributions-table'}, + (stitchArrays( + (slots.sort === 'count' + ? { + group: relations.groupLinksSortedByCount, + count: getCounts(data.groupCountsSortedByCount), + duration: + getDurations( + data.groupDurationsSortedByCount, + data.groupDurationsApproximateSortedByCount), + } + : { + group: relations.groupLinksSortedByDuration, + count: getCounts(data.groupCountsSortedByDuration), + duration: + getDurations( + data.groupDurationsSortedByDuration, + data.groupDurationsApproximateSortedByDuration), + }) + )).map(({group, count, duration}) => + language.encapsulate(capsule, 'item', capsule => + html.tag('tr', [ + html.tag('td', {class: 'group-contributions-link-cell'}, + html.tag('span', group)), + + html.tag('td', {class: 'group-contributions-metrics-cell'}, + (slots.sort === 'count' + // When sorting by count, duration details aren't necessarily + // available for all items. + ? (slots.showBothColumns && duration + ? language.$(capsule, 'countDurationAccent', {count, duration}) + : language.$(capsule, 'countAccent', {count})) + + // Count details are always available, since they're just the + // number of contributions directly. And duration details are + // guaranteed for every item when sorting by duration. + : (slots.showBothColumns + ? language.$(capsule, 'durationCountAccent', {duration, count}) + : language.$(capsule, 'durationAccent', {duration})))), + ]))))), ]); }), }; diff --git a/src/content/dependencies/generateCoverGrid.js b/src/content/dependencies/generateCoverGrid.js index 091833a9..6f87b54c 100644 --- a/src/content/dependencies/generateCoverGrid.js +++ b/src/content/dependencies/generateCoverGrid.js @@ -187,7 +187,7 @@ export default { : !html.isBlank(relations.bottomCaption) ? html.tag('p', {class: 'grid-caption'}, - slots.caption) + slots.bottomCaption) : html.blank()), ]), |