« get me outta code hell

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:
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/album.js8
-rw-r--r--src/data/things/thing.js10
2 files changed, 13 insertions, 5 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 01f52c2d..5e281f06 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -1,6 +1,6 @@
 import find from '#find';
 import {stitchArrays} from '#sugar';
-import {isDate, isDimensions, isTrackSectionList} from '#validators';
+import {isDate, isTrackSectionList} from '#validators';
 
 import {
   compositeFrom,
@@ -19,6 +19,7 @@ import Thing, {
   commentatorArtists,
   contribsPresent,
   contributionList,
+  dimensions,
   directory,
   fileExtension,
   flag,
@@ -171,10 +172,7 @@ export class Album extends Thing {
 
     bannerStyle: simpleString(),
     bannerFileExtension: fileExtension('jpg'),
-    bannerDimensions: {
-      flags: {update: true, expose: true},
-      update: {validate: isDimensions},
-    },
+    bannerDimensions: dimensions(),
 
     hasTrackNumbers: flag(true),
     isListedOnHomepage: flag(true),
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
index 9e7f940f..0484b589 100644
--- a/src/data/things/thing.js
+++ b/src/data/things/thing.js
@@ -25,6 +25,7 @@ import {
   isColor,
   isContributionList,
   isDate,
+  isDimensions,
   isDirectory,
   isFileExtension,
   isName,
@@ -122,6 +123,15 @@ export function fileExtension(defaultFileExtension = null) {
   };
 }
 
+// Plain ol' image dimensions. This is a two-item array of positive integers,
+// corresponding to width and height respectively.
+export function dimensions() {
+  return {
+    flags: {update: true, expose: true},
+    update: {validate: isDimensions},
+  };
+}
+
 // Straightforward flag descriptor for a variety of property purposes.
 // Provide a default value, true or false!
 export function flag(defaultValue = false) {