« get me outta code hell

non-jpg full res art links, artist avatars - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-03-05 21:34:59 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-03-05 21:34:59 -0400
commit3bbeea69c6356edd5792ac7898b9623c2e1519de (patch)
treebd8727673d528e5b540db2b2dc51627ca209819b
parent21c6220356b3769b6321bd64e85398fee618cfb1 (diff)
non-jpg full res art links, artist avatars
-rw-r--r--src/data/cacheable-object.js2
-rw-r--r--src/data/things.js20
-rw-r--r--src/misc-templates.js2
-rw-r--r--src/page/album.js13
-rw-r--r--src/page/artist.js9
-rw-r--r--src/page/track.js2
-rwxr-xr-xsrc/upd8.js11
-rw-r--r--src/url-spec.js9
-rw-r--r--src/util/wiki-data.js12
9 files changed, 57 insertions, 23 deletions
diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js
index 99280956..4afb0368 100644
--- a/src/data/cacheable-object.js
+++ b/src/data/cacheable-object.js
@@ -169,7 +169,7 @@ export default class CacheableObject {
             const oldValue = this.#propertyUpdateValues[property];
 
             if (newValue === undefined) {
-                throw new ValueError(`Properties cannot be set to undefined`);
+                throw new TypeError(`Properties cannot be set to undefined`);
             }
 
             if (newValue === oldValue) {
diff --git a/src/data/things.js b/src/data/things.js
index c93b8852..16970af5 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -448,6 +448,9 @@ Album.propertyDescriptors = {
         }
     },
 
+    coverArtFileExtension: Thing.common.fileExtension('jpg'),
+    trackCoverArtFileExtension: Thing.common.fileExtension('jpg'),
+
     wallpaperStyle: Thing.common.simpleString(),
     wallpaperFileExtension: Thing.common.fileExtension('jpg'),
 
@@ -605,6 +608,20 @@ Track.propertyDescriptors = {
         }
     },
 
+    coverArtFileExtension: {
+        flags: {update: true, expose: true},
+
+        update: {validate: isFileExtension},
+
+        expose: {
+            dependencies: ['albumData'],
+            transform: (coverArtFileExtension, { albumData, [Track.instance]: track }) => (
+                coverArtFileExtension ??
+                Track.findAlbum(track, albumData)?.trackCoverArtFileExtension ??
+                true)
+        }
+    },
+
     // Previously known as: (track).aka
     originalReleaseTrackByRef: Thing.common.singleReference(Track),
 
@@ -779,6 +796,9 @@ Artist.propertyDescriptors = {
     urls: Thing.common.urls(),
     contextNotes: Thing.common.simpleString(),
 
+    hasAvatar: Thing.common.flag(false),
+    avatarFileExtension: Thing.common.fileExtension('jpg'),
+
     aliasNames: {
         flags: {update: true, expose: true},
         update: {
diff --git a/src/misc-templates.js b/src/misc-templates.js
index eb12496d..300fd8a1 100644
--- a/src/misc-templates.js
+++ b/src/misc-templates.js
@@ -182,7 +182,7 @@ export function getThemeString(color, additionalVariables = []) {
 }
 export function getAlbumStylesheet(album, {to}) {
     return [
-        album.wallpaperArtistContribs && fixWS`
+        album.wallpaperArtistContribs.length && fixWS`
             body::before {
                 background-image: url("${to('media.albumWallpaper', album.directory, album.wallpaperFileExtension)}");
                 ${album.wallpaperStyle}
diff --git a/src/page/album.js b/src/page/album.js
index 6478cce2..d7447a4c 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -74,10 +74,10 @@ export function write(album, {wikiData}) {
             duration: albumDuration,
             color: album.color,
             cover: serializeCover(album, getAlbumCover),
-            artistContribs: serializeContribs(album.artistContribs || []),
-            coverArtistContribs: serializeContribs(album.coverArtistContribs || []),
-            wallpaperArtistContribs: serializeContribs(album.wallpaperArtistContribs || []),
-            bannerArtistContribs: serializeContribs(album.bannerArtistContribs || []),
+            artistContribs: serializeContribs(album.artistContribs),
+            coverArtistContribs: serializeContribs(album.coverArtistContribs),
+            wallpaperArtistContribs: serializeContribs(album.wallpaperArtistContribs),
+            bannerArtistContribs: serializeContribs(album.bannerArtistContribs),
             groups: serializeGroupsForAlbum(album),
             trackGroups: album.trackGroups?.map(trackGroup => ({
                 name: trackGroup.name,
@@ -98,6 +98,7 @@ export function write(album, {wikiData}) {
             fancifyURL,
             generateChronologyLinks,
             generateCoverLink,
+            getAlbumCover,
             getAlbumStylesheet,
             getArtistString,
             getLinkThemeString,
@@ -120,7 +121,7 @@ export function write(album, {wikiData}) {
                     `--album-directory: ${album.directory}`
                 ]),
 
-                banner: album.bannerArtistContribs && {
+                banner: album.bannerArtistContribs.length && {
                     dimensions: album.bannerDimensions,
                     path: ['media.albumBanner', album.directory, album.bannerFileExtension],
                     alt: strings('misc.alt.albumBanner'),
@@ -130,7 +131,7 @@ export function write(album, {wikiData}) {
                 main: {
                     content: fixWS`
                         ${generateCoverLink({
-                            path: ['media.albumCover', album.directory],
+                            src: getAlbumCover(album),
                             alt: strings('misc.alt.albumCover'),
                             tags: album.artTags
                         })}
diff --git a/src/page/artist.js b/src/page/artist.js
index 6a465604..dae0e198 100644
--- a/src/page/artist.js
+++ b/src/page/artist.js
@@ -272,6 +272,7 @@ export function write(artist, {wikiData}) {
             fancifyURL,
             generateCoverLink,
             generateInfoGalleryLinks,
+            getArtistAvatar,
             getArtistString,
             link,
             strings,
@@ -290,7 +291,7 @@ export function write(artist, {wikiData}) {
                 main: {
                     content: fixWS`
                         ${artist.hasAvatar && generateCoverLink({
-                            path: ['localized.artistAvatar', artist.directory],
+                            src: getArtistAvatar(artist),
                             alt: strings('misc.alt.artistAvatar')
                         })}
                         <h1>${strings('artistPage.title', {artist: name})}</h1>
@@ -369,9 +370,9 @@ export function write(artist, {wikiData}) {
                                                         track: link.track(track)
                                                     })
                                                     : `<i>${strings('artistPage.creditList.entry.album.' + {
-                                                        wallpaperArtists: 'wallpaperArt',
-                                                        bannerArtists: 'bannerArt',
-                                                        coverArtists: 'coverArt'
+                                                        wallpaperArtistContribs: 'wallpaperArt',
+                                                        bannerArtistContribs: 'bannerArt',
+                                                        coverArtistContribs: 'coverArt'
                                                     }[key])}</i>`),
                                                 ...props
                                             }))
diff --git a/src/page/track.js b/src/page/track.js
index 264195da..9a3307b4 100644
--- a/src/page/track.js
+++ b/src/page/track.js
@@ -149,7 +149,7 @@ export function write(track, {wikiData}) {
 
                 // disabled for now! shifting banner position per height of page is disorienting
                 /*
-                banner: album.bannerArtistContribs && {
+                banner: album.bannerArtistContribs.length && {
                     classes: ['dim'],
                     dimensions: album.bannerDimensions,
                     path: ['media.albumBanner', album.directory, album.bannerFileExtension],
diff --git a/src/upd8.js b/src/upd8.js
index 38027bab..e946ca2a 100755
--- a/src/upd8.js
+++ b/src/upd8.js
@@ -159,6 +159,7 @@ import {
     getAlbumCover,
     getAlbumListTag,
     getAllTracks,
+    getArtistAvatar,
     getArtistCommentary,
     getArtistNumContributions,
     getFlashCover,
@@ -867,6 +868,9 @@ const processAlbumDocument = makeProcessDocument(Album, {
         coverArtistContribsByRef: 'Cover Artists',
         trackCoverArtistContribsByRef: 'Default Track Cover Artists',
 
+        coverArtFileExtension: 'Cover Art File Extension',
+        trackCoverArtFileExtension: 'Track Art File Extension',
+
         wallpaperArtistContribsByRef: 'Wallpaper Artists',
         wallpaperStyle: 'Wallpaper Style',
         wallpaperFileExtension: 'Wallpaper File Extension',
@@ -923,6 +927,7 @@ const processTrackDocument = makeProcessDocument(Track, {
         urls: 'URLs',
 
         coverArtDate: 'Cover Art Date',
+        coverArtFileExtension: 'Cover Art File Extension',
         dateFirstReleased: 'Date First Released',
         hasCoverArt: 'Has Cover Art',
         hasURLs: 'Has URLs',
@@ -947,6 +952,8 @@ const processArtistDocument = makeProcessDocument(Artist, {
 
         directory: 'Directory',
         urls: 'URLs',
+        hasAvatar: 'Has Avatar',
+        avatarFileExtension: 'Avatar File Extension',
 
         aliasNames: 'Aliases',
 
@@ -3301,6 +3308,10 @@ async function main() {
                     to
                 });
 
+                bound.getArtistAvatar = bindOpts(getArtistAvatar, {
+                    to
+                });
+
                 bound.generateChronologyLinks = bindOpts(generateChronologyLinks, {
                     link: bound.link,
                     linkAnythingMan: bound.linkAnythingMan,
diff --git a/src/url-spec.js b/src/url-spec.js
index 3a77858b..b9366b0d 100644
--- a/src/url-spec.js
+++ b/src/url-spec.js
@@ -70,13 +70,12 @@ const urlSpec = {
             root: '',
             path: '<>',
 
-            albumCover: 'album-art/<>/cover.jpg',
+            albumCover: 'album-art/<>/cover.<>',
             albumWallpaper: 'album-art/<>/bg.<>',
             albumBanner: 'album-art/<>/banner.<>',
-            trackCover: 'album-art/<>/<>.jpg',
-            artistAvatar: 'artist-avatar/<>.jpg',
-            flashArt: 'flash-art/<>.jpg',
-            flashArtGif: 'flash-art/<>.gif' // Hack! Sorry not sorry. ::::)
+            trackCover: 'album-art/<>/<>.<>',
+            artistAvatar: 'artist-avatar/<>.<>',
+            flashArt: 'flash-art/<>.<>',
         }
     }
 };
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 36c61454..870c0b0e 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -98,7 +98,7 @@ export function filterAlbumsByCommentary(albums) {
 }
 
 export function getAlbumCover(album, {to}) {
-    return to('media.albumCover', album.directory);
+    return to('media.albumCover', album.directory, album.coverArtFileExtension);
 }
 
 export function getAlbumListTag(album) {
@@ -143,9 +143,7 @@ export function getArtistCommentary(artist, {justEverythingMan}) {
 }
 
 export function getFlashCover(flash, {to}) {
-    return (flash.jiff
-        ? to('media.flashArtGif', flash.directory)
-        : to('media.flashArt', flash.directory));
+    return to('media.flashArt', flash.directory, flash.coverArtFileExtension);
 }
 
 export function getFlashLink(flash) {
@@ -162,10 +160,14 @@ export function getTrackCover(track, {to}) {
     if (!track.hasCoverArt) {
         return getAlbumCover(track.album, {to});
     } else {
-        return to('media.trackCover', track.album.directory, track.directory);
+        return to('media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension);
     }
 }
 
+export function getArtistAvatar(artist, {to}) {
+    return to('media.artistAvatar', artist.directory, artist.avatarFileExtension);
+}
+
 // Big-ass homepage row functions
 
 export function getNewAdditions(numAlbums, {wikiData}) {