« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/data/things.js25
-rw-r--r--src/misc-templates.js2
-rw-r--r--src/page/album.js2
-rw-r--r--src/page/track.js2
4 files changed, 13 insertions, 18 deletions
diff --git a/src/data/things.js b/src/data/things.js
index 901442dd..c93b8852 100644
--- a/src/data/things.js
+++ b/src/data/things.js
@@ -136,6 +136,13 @@ Thing.common = {
         update: {validate: validateArrayItems(isURL)}
     }),
 
+    // A file extension! Or the default, if provided when calling this.
+    fileExtension: (defaultFileExtension = null) => ({
+        flags: {update: true, expose: true},
+        update: {validate: isFileExtension},
+        expose: {transform: value => value ?? defaultFileExtension}
+    }),
+
     // Straightforward flag descriptor for a variety of property purposes.
     // Provide a default value, true or false!
     flag: (defaultValue = false) => {
@@ -442,19 +449,10 @@ Album.propertyDescriptors = {
     },
 
     wallpaperStyle: Thing.common.simpleString(),
-
-    wallpaperFileExtension: {
-        flags: {update: true, expose: true},
-        update: {validate: isFileExtension}
-    },
+    wallpaperFileExtension: Thing.common.fileExtension('jpg'),
 
     bannerStyle: Thing.common.simpleString(),
-
-    bannerFileExtension: {
-        flags: {update: true, expose: true},
-        update: {validate: isFileExtension}
-    },
-
+    bannerFileExtension: Thing.common.fileExtension('jpg'),
     bannerDimensions: {
         flags: {update: true, expose: true},
         update: {validate: isDimensions}
@@ -1132,10 +1130,7 @@ Flash.propertyDescriptors = {
 
     date: Thing.common.simpleDate(),
 
-    coverArtFileExtension: {
-        flags: {update: true, expose: true},
-        update: {validate: isFileExtension}
-    },
+    coverArtFileExtension: Thing.common.fileExtension('jpg'),
 
     contributorContribsByRef: Thing.common.contribsByRef(),
 
diff --git a/src/misc-templates.js b/src/misc-templates.js
index f51d0e5c..eb12496d 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.wallpaperArtists && fixWS`
+        album.wallpaperArtistContribs && 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 f7df2648..6478cce2 100644
--- a/src/page/album.js
+++ b/src/page/album.js
@@ -120,7 +120,7 @@ export function write(album, {wikiData}) {
                     `--album-directory: ${album.directory}`
                 ]),
 
-                banner: album.bannerArtists && {
+                banner: album.bannerArtistContribs && {
                     dimensions: album.bannerDimensions,
                     path: ['media.albumBanner', album.directory, album.bannerFileExtension],
                     alt: strings('misc.alt.albumBanner'),
diff --git a/src/page/track.js b/src/page/track.js
index f9c6fe6d..264195da 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.bannerArtists && {
+                banner: album.bannerArtistContribs && {
                     classes: ['dim'],
                     dimensions: album.bannerDimensions,
                     path: ['media.albumBanner', album.directory, album.bannerFileExtension],