diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-17 18:16:18 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-17 18:16:18 -0400 |
commit | ec129ac9ce0b143ca4c325108ea66c2d0e7352ff (patch) | |
tree | 0dad7fa2757aa91ed698443d8767722071caed4f /src/content/dependencies | |
parent | 6acbc628cb111c53d0b312ab90cd4807ad4bd8d1 (diff) |
content: generate{Album,}ReferencedArtworksPage
Diffstat (limited to 'src/content/dependencies')
5 files changed, 223 insertions, 105 deletions
diff --git a/src/content/dependencies/generateAlbumReferencedArtworksPage.js b/src/content/dependencies/generateAlbumReferencedArtworksPage.js new file mode 100644 index 00000000..3f3d77b3 --- /dev/null +++ b/src/content/dependencies/generateAlbumReferencedArtworksPage.js @@ -0,0 +1,68 @@ +export default { + contentDependencies: [ + 'generateAlbumCoverArtwork', + 'generateAlbumStyleRules', + 'generateBackToAlbumLink', + 'generateReferencedArtworksPage', + 'linkAlbum', + ], + + extraDependencies: ['html', 'language'], + + relations: (relation, album) => ({ + page: + relation('generateReferencedArtworksPage', album.referencedArtworks), + + albumStyleRules: + relation('generateAlbumStyleRules', album, null), + + albumLink: + relation('linkAlbum', album), + + backToAlbumLink: + relation('generateBackToAlbumLink', album), + + cover: + relation('generateAlbumCoverArtwork', album), + }), + + data: (album) => ({ + name: + album.name, + + color: + album.color, + }), + + generate: (data, relations, {html, language}) => + relations.page.slots({ + title: + language.$('albumPage.title', { + album: + data.name, + }), + + color: data.color, + styleRules: [relations.albumStyleRules], + + cover: relations.cover, + + navLinks: [ + {auto: 'home'}, + + { + html: + relations.albumLink + .slot('attributes', {class: 'current'}), + + accent: + html.tag('a', {href: ''}, + {class: 'current'}, + + language.$('referencedArtworksPage.subtitle')), + }, + ], + + navBottomRowContent: relations.backToAlbumLink, + }), +}; diff --git a/src/content/dependencies/generateBackToAlbumLink.js b/src/content/dependencies/generateBackToAlbumLink.js new file mode 100644 index 00000000..6648b463 --- /dev/null +++ b/src/content/dependencies/generateBackToAlbumLink.js @@ -0,0 +1,15 @@ +export default { + contentDependencies: ['linkAlbum'], + extraDependencies: ['language'], + + relations: (relation, track) => ({ + trackLink: + relation('linkAlbum', track), + }), + + generate: (relations, {language}) => + relations.trackLink.slots({ + content: language.$('albumPage.nav.backToAlbum'), + color: false, + }), +}; diff --git a/src/content/dependencies/generateReferencedArtworksPage.js b/src/content/dependencies/generateReferencedArtworksPage.js new file mode 100644 index 00000000..fa65a245 --- /dev/null +++ b/src/content/dependencies/generateReferencedArtworksPage.js @@ -0,0 +1,121 @@ +import {stitchArrays} from '#sugar'; + +export default { + contentDependencies: [ + 'generateCoverGrid', + 'generatePageLayout', + 'image', + 'linkAlbum', + 'linkTrack', + ], + + extraDependencies: ['html', 'language'], + + relations: (relation, referencedArtworks) => ({ + layout: + relation('generatePageLayout'), + + coverGrid: + relation('generateCoverGrid'), + + links: + referencedArtworks.map(({thing}) => + (thing.album + ? relation('linkTrack', thing) + : relation('linkAlbum', thing))), + + images: + referencedArtworks.map(({thing}) => + relation('image', thing.artTags)), + }), + + data: (referencedArtworks) => ({ + count: + referencedArtworks.length, + + names: + referencedArtworks + .map(({thing}) => thing.name), + + paths: + referencedArtworks + .map(({thing}) => + (thing.album + ? ['media.trackCover', thing.album.directory, thing.directory, thing.coverArtFileExtension] + : ['media.albumCover', thing.directory, thing.coverArtFileExtension])), + + dimensions: + referencedArtworks + .map(({thing}) => thing.coverArtDimensions), + + coverArtistNames: + referencedArtworks + .map(({thing}) => + thing.coverArtistContribs + .map(contrib => contrib.artist.name)), + }), + + slots: { + color: {validate: v => v.isColor}, + + styleRules: {type: 'html', mutable: false}, + + title: {type: 'html', mutable: false}, + cover: {type: 'html', mutable: true}, + + navLinks: {validate: v => v.isArray}, + navBottomRowContent: {type: 'html', mutable: false}, + }, + + generate: (data, relations, slots, {html, language}) => + language.encapsulate('referencedArtworksPage', pageCapsule => + relations.layout.slots({ + title: slots.title, + subtitle: language.$(pageCapsule, 'subtitle'), + + color: slots.color, + styleRules: slots.styleRules, + + cover: + slots.cover + .slot('mode', 'primary-artists'), + + mainClasses: ['top-index'], + mainContent: [ + html.tag('p', {class: 'quick-info'}, + language.$(pageCapsule, 'statsLine', { + artworks: + language.countArtworks(data.count, { + unit: true, + }), + })), + + relations.coverGrid.slots({ + links: relations.links, + names: data.names, + + images: + stitchArrays({ + image: relations.images, + path: data.paths, + dimensions: data.dimensions, + }).map(({image, path, dimensions}) => + image.slots({ + path, + dimensions, + })), + + info: + data.coverArtistNames.map(names => + language.$('misc.coverGrid.details.coverArtists', { + artists: + language.formatUnitList(names), + })), + }), + ], + + navLinkStyle: 'hierarchical', + navLinks: slots.navLinks, + navBottomRowContent: slots.navBottomRowContent, + })), +}; diff --git a/src/content/dependencies/generateTrackNavLinks.js b/src/content/dependencies/generateTrackNavLinks.js index e6e6d6ab..2d4ad378 100644 --- a/src/content/dependencies/generateTrackNavLinks.js +++ b/src/content/dependencies/generateTrackNavLinks.js @@ -55,7 +55,7 @@ export default { {class: 'current'}, (slots.currentExtra === 'referenced-art' - ? language.$(navCapsule, 'referencedArtworks') + ? language.$('referencedArtworksPage.subtitle') : null)), }, ]), diff --git a/src/content/dependencies/generateTrackReferencedArtworksPage.js b/src/content/dependencies/generateTrackReferencedArtworksPage.js index 545276c5..ac81e525 100644 --- a/src/content/dependencies/generateTrackReferencedArtworksPage.js +++ b/src/content/dependencies/generateTrackReferencedArtworksPage.js @@ -1,23 +1,17 @@ -import {stitchArrays} from '#sugar'; - export default { contentDependencies: [ 'generateAlbumStyleRules', 'generateBackToTrackLink', - 'generateCoverGrid', - 'generatePageLayout', + 'generateReferencedArtworksPage', 'generateTrackCoverArtwork', 'generateTrackNavLinks', - 'image', - 'linkAlbum', - 'linkTrack', ], extraDependencies: ['html', 'language'], relations: (relation, track) => ({ - layout: - relation('generatePageLayout'), + page: + relation('generateReferencedArtworksPage', track.referencedArtworks), albumStyleRules: relation('generateAlbumStyleRules', track.album, track), @@ -30,21 +24,6 @@ export default { cover: relation('generateTrackCoverArtwork', track), - - coverGrid: - relation('generateCoverGrid'), - - links: - track.referencedArtworks - .map(({thing}) => - (thing.album - ? relation('linkTrack', thing) - : relation('linkAlbum', thing))), - - images: - track.referencedArtworks - .map(({thing}) => - relation('image', thing.artTags)), }), data: (track) => ({ @@ -53,91 +32,26 @@ export default { color: track.color, - - count: - track.referencedArtworks.length, - - names: - track.referencedArtworks - .map(({thing}) => thing.name), - - paths: - track.referencedArtworks - .map(({thing}) => - (thing.album - ? ['media.trackCover', thing.album.directory, thing.directory, thing.coverArtFileExtension] - : ['media.albumCover', thing.directory, thing.coverArtFileExtension])), - - dimensions: - track.referencedArtworks - .map(({thing}) => thing.coverArtDimensions), - - coverArtistNames: - track.referencedArtworks - .map(({thing}) => - thing.coverArtistContribs - .map(contrib => contrib.artist.name)), }), generate: (data, relations, {html, language}) => - language.encapsulate('trackReferencedArtworksPage', pageCapsule => - relations.layout.slots({ - title: - language.$(pageCapsule, 'title', { - track: - data.name, - }), - - subtitle: - language.$(pageCapsule, 'subtitle'), - - color: data.color, - styleRules: [relations.albumStyleRules], - - cover: - relations.cover - .slot('mode', 'primary-artists'), - - mainClasses: ['top-index'], - mainContent: [ - html.tag('p', {class: 'quick-info'}, - language.$(pageCapsule, 'statsLine', { - artworks: - language.countArtworks(data.count, { - unit: true, - }), - })), - - relations.coverGrid.slots({ - links: relations.links, - names: data.names, + relations.page.slots({ + title: + language.$('trackPage.title', { + track: + data.name, + }), - images: - stitchArrays({ - image: relations.images, - path: data.paths, - dimensions: data.dimensions, - }).map(({image, path, dimensions}) => - image.slots({ - path, - dimensions, - })), + color: data.color, + styleRules: [relations.albumStyleRules], - info: - data.coverArtistNames.map(names => - language.$('misc.coverGrid.details.coverArtists', { - artists: - language.formatUnitList(names), - })), - }), - ], + cover: relations.cover, - navLinkStyle: 'hierarchical', - navLinks: - html.resolve( - relations.navLinks - .slot('currentExtra', 'referenced-art')), + navLinks: + html.resolve( + relations.navLinks + .slot('currentExtra', 'referenced-art')), - navBottomRowContent: relations.backToTrackLink, - })), + navBottomRowContent: relations.backToTrackLink, + }), }; |