diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-06-06 20:03:23 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-06-06 20:05:36 -0300 |
commit | a2413a5a08ded1fdf1b039bd992565827cda46ab (patch) | |
tree | 28119093ec3e40d16de9702dcf898b023a10018a /src/content/dependencies | |
parent | 8a647d1727bc5345c4bcb0066ff195c8e45beea4 (diff) |
content: generate{Album,Track}CoverArtwork
Portable functions hoo-ray!
Diffstat (limited to 'src/content/dependencies')
4 files changed, 63 insertions, 29 deletions
diff --git a/src/content/dependencies/generateAlbumCoverArtwork.js b/src/content/dependencies/generateAlbumCoverArtwork.js new file mode 100644 index 00000000..f7e86303 --- /dev/null +++ b/src/content/dependencies/generateAlbumCoverArtwork.js @@ -0,0 +1,23 @@ +export default { + contentDependencies: ['generateCoverArtwork'], + + relations(relation, album) { + return { + coverArtwork: + relation('generateCoverArtwork', album.artTags), + }; + }, + + data(album) { + return { + path: ['media.albumCover', album.directory, album.coverArtFileExtension], + }; + }, + + generate(data, relations) { + return relations.coverArtwork + .slots({ + path: data.path, + }); + }, +}; diff --git a/src/content/dependencies/generateAlbumInfoPageContent.js b/src/content/dependencies/generateAlbumInfoPageContent.js index 5d2817ee..230d7351 100644 --- a/src/content/dependencies/generateAlbumInfoPageContent.js +++ b/src/content/dependencies/generateAlbumInfoPageContent.js @@ -4,9 +4,9 @@ export default { contentDependencies: [ 'generateAdditionalFilesShortcut', 'generateAlbumAdditionalFilesList', + 'generateAlbumCoverArtwork', 'generateAlbumTrackList', 'generateContentHeading', - 'generateCoverArtwork', 'linkAlbumCommentary', 'linkAlbumGallery', 'linkContribution', @@ -35,7 +35,7 @@ export default { if (album.hasCoverArt) { relations.cover = - relation('generateCoverArtwork', album.artTags); + relation('generateAlbumCoverArtwork', album); releaseInfo.coverArtistContributionLinks = contributionLinksRelation(album.coverArtistContribs); } else { @@ -161,8 +161,7 @@ export default { if (data.hasCoverArt) { content.cover = relations.cover .slots({ - path: ['media.albumCover', data.coverArtDirectory, data.coverArtFileExtension], - alt: language.$('misc.alt.trackCover') + alt: language.$('misc.alt.albumCover'), }); } else { content.cover = null; diff --git a/src/content/dependencies/generateTrackCoverArtwork.js b/src/content/dependencies/generateTrackCoverArtwork.js new file mode 100644 index 00000000..f6084f36 --- /dev/null +++ b/src/content/dependencies/generateTrackCoverArtwork.js @@ -0,0 +1,29 @@ +export default { + contentDependencies: ['generateCoverArtwork'], + + relations(relation, track) { + return { + coverArtwork: + relation('generateCoverArtwork', + (track.hasUniqueCoverArt + ? track.artTags + : album.artTags)), + }; + }, + + data(track) { + return { + path: + (track.hasUniqueCoverArt + ? ['media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension] + : ['media.albumCover', track.album.directory, track.album.coverArtFileExtension]), + }; + }, + + generate(data, relations) { + return relations.coverArtwork + .slots({ + path: data.path, + }); + }, +}; diff --git a/src/content/dependencies/generateTrackInfoPageContent.js b/src/content/dependencies/generateTrackInfoPageContent.js index c33c2f62..43f8e689 100644 --- a/src/content/dependencies/generateTrackInfoPageContent.js +++ b/src/content/dependencies/generateTrackInfoPageContent.js @@ -6,7 +6,7 @@ export default { 'generateAdditionalFilesShortcut', 'generateAlbumAdditionalFilesList', 'generateContentHeading', - 'generateCoverArtwork', + 'generateTrackCoverArtwork', 'generateTrackList', 'generateTrackListDividedByGroups', 'linkAlbum', @@ -43,6 +43,11 @@ export default { list: relation('generateAlbumAdditionalFilesList', album, additionalFiles), }); + if (track.hasUniqueCoverArt || album.hasCoverArt) { + relations.cover = + relation('generateTrackCoverArtwork', track); + } + // Section: Release info const releaseInfo = sections.releaseInfo = {}; @@ -51,15 +56,8 @@ export default { contributionLinksRelation(track.artistContribs); if (track.hasUniqueCoverArt) { - relations.cover = - relation('generateCoverArtwork', track.artTags); releaseInfo.coverArtistContributionLinks = contributionLinksRelation(track.coverArtistContribs); - } else if (album.hasCoverArt) { - relations.cover = - relation('generateCoverArtwork', album.artTags); - } else { - relations.cover = null; } // Section: Listen on @@ -285,25 +283,10 @@ export default { link.slots({showContribution, showIcons}))), }); - if (data.hasUniqueCoverArt) { + if (data.hasUniqueCoverArt || data.hasAlbumCoverArt) { content.cover = relations.cover .slots({ - path: [ - 'media.trackCover', - data.albumCoverArtDirectory, - data.trackCoverArtDirectory, - data.coverArtFileExtension, - ], - }); - content.coverNeedsReveal = data.coverNeedsReveal; - } else if (data.hasAlbumCoverArt) { - content.cover = relations.cover - .slots({ - path: [ - 'media.albumCover', - data.albumCoverArtDirectory, - data.coverArtFileExtension, - ], + alt: language.$('misc.alt.trackCover'), }); content.coverNeedsReveal = data.coverNeedsReveal; } else { |