« get me outta code hell

banner & wallpaper art, file extension defaults - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-03-05 20:53:16 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-03-05 20:53:16 -0400
commit21c6220356b3769b6321bd64e85398fee618cfb1 (patch)
treedcec170694865fcf7760d69c21356f4e5dee857f /src/data
parentc55764a1f4d7903ed149b6491d9def8064c9e2ac (diff)
banner & wallpaper art, file extension defaults
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things.js25
1 files changed, 10 insertions, 15 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(),