« 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/things
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/group/Group.js (renamed from src/data/things/group.js)130
-rw-r--r--src/data/things/group/GroupCategory.js58
-rw-r--r--src/data/things/group/Series.js79
-rw-r--r--src/data/things/group/index.js3
-rw-r--r--src/data/things/index.js2
5 files changed, 143 insertions, 129 deletions
diff --git a/src/data/things/group.js b/src/data/things/group/Group.js
index cc5f4cb8..b065f9a3 100644
--- a/src/data/things/group.js
+++ b/src/data/things/group/Group.js
@@ -1,11 +1,8 @@
-export const GROUP_DATA_FILE = 'groups.yaml';
+const GROUP_DATA_FILE = 'groups.yaml';
 
-import {inspect} from 'node:util';
-
-import {colors} from '#cli';
 import {input, V} from '#composite';
 import Thing from '#thing';
-import {is, isBoolean} from '#validators';
+import {isBoolean} from '#validators';
 import {parseAnnotatedReferences, parseSerieses} from '#yaml';
 
 import {withPropertyFromObject} from '#composite/data';
@@ -19,7 +16,6 @@ import {
 
 import {
   annotatedReferenceList,
-  color,
   contentString,
   directory,
   flag,
@@ -27,7 +23,6 @@ import {
   referenceList,
   soupyFind,
   soupyReverse,
-  thing,
   thingList,
   urls,
 } from '#composite/wiki-properties';
@@ -235,124 +230,3 @@ export class Group extends Thing {
     sort: null,
   });
 }
-
-export class GroupCategory extends Thing {
-  static [Thing.referenceType] = 'group-category';
-  static [Thing.friendlyName] = `Group Category`;
-  static [Thing.wikiData] = 'groupCategoryData';
-
-  static [Thing.getPropertyDescriptors] = ({Group}) => ({
-    // Update & expose
-
-    name: name(V('Unnamed Group Category')),
-    directory: directory(),
-
-    excludeGroupsFromGalleryTabs: flag(V(false)),
-
-    color: color(),
-
-    groups: referenceList({
-      class: input.value(Group),
-      find: soupyFind.input('group'),
-    }),
-
-    // Update only
-
-    find: soupyFind(),
-
-    // Expose only
-
-    isGroupCategory: exposeConstant(V(true)),
-  });
-
-  static [Thing.reverseSpecs] = {
-    groupCategoriesWhichInclude: {
-      bindTo: 'groupCategoryData',
-
-      referencing: groupCategory => [groupCategory],
-      referenced: groupCategory => groupCategory.groups,
-    },
-  };
-
-  static [Thing.yamlDocumentSpec] = {
-    fields: {
-      'Category': {property: 'name'},
-
-      'Color': {property: 'color'},
-
-      'Exclude Groups From Gallery Tabs': {
-        property: 'excludeGroupsFromGalleryTabs',
-      },
-    },
-  };
-}
-
-export class Series extends Thing {
-  static [Thing.wikiData] = 'seriesData';
-
-  static [Thing.getPropertyDescriptors] = ({Album, Group}) => ({
-    // Update & expose
-
-    name: name(V('Unnamed Series')),
-
-    showAlbumArtists: {
-      flags: {update: true, expose: true},
-      update: {
-        validate:
-          is('all', 'differing', 'none'),
-      },
-    },
-
-    description: contentString(),
-
-    group: thing(V(Group)),
-
-    albums: referenceList({
-      class: input.value(Album),
-      find: soupyFind.input('album'),
-    }),
-
-    // Update only
-
-    find: soupyFind(),
-  });
-
-  static [Thing.yamlDocumentSpec] = {
-    fields: {
-      'Name': {property: 'name'},
-
-      'Description': {property: 'description'},
-
-      'Show Album Artists': {property: 'showAlbumArtists'},
-
-      'Albums': {property: 'albums'},
-    },
-  };
-
-  [inspect.custom](depth, options, inspect) {
-    const parts = [];
-
-    parts.push(Thing.prototype[inspect.custom].apply(this));
-
-    if (depth >= 0) showGroup: {
-      let group = null;
-      try {
-        group = this.group;
-      } catch {
-        break showGroup;
-      }
-
-      const groupName = group.name;
-      const groupIndex = group.serieses.indexOf(this);
-
-      const num =
-        (groupIndex === -1
-          ? 'indeterminate position'
-          : `#${groupIndex + 1}`);
-
-      parts.push(` (${colors.yellow(num)} in ${colors.green(`"${groupName}"`)})`);
-    }
-
-    return parts.join('');
-  }
-}
diff --git a/src/data/things/group/GroupCategory.js b/src/data/things/group/GroupCategory.js
new file mode 100644
index 00000000..daf31868
--- /dev/null
+++ b/src/data/things/group/GroupCategory.js
@@ -0,0 +1,58 @@
+import {input, V} from '#composite';
+import Thing from '#thing';
+
+import {exposeConstant} from '#composite/control-flow';
+
+import {color, directory, flag, name, referenceList, soupyFind}
+  from '#composite/wiki-properties';
+
+export class GroupCategory extends Thing {
+  static [Thing.referenceType] = 'group-category';
+  static [Thing.friendlyName] = `Group Category`;
+  static [Thing.wikiData] = 'groupCategoryData';
+
+  static [Thing.getPropertyDescriptors] = ({Group}) => ({
+    // Update & expose
+
+    name: name(V('Unnamed Group Category')),
+    directory: directory(),
+
+    excludeGroupsFromGalleryTabs: flag(V(false)),
+
+    color: color(),
+
+    groups: referenceList({
+      class: input.value(Group),
+      find: soupyFind.input('group'),
+    }),
+
+    // Update only
+
+    find: soupyFind(),
+
+    // Expose only
+
+    isGroupCategory: exposeConstant(V(true)),
+  });
+
+  static [Thing.reverseSpecs] = {
+    groupCategoriesWhichInclude: {
+      bindTo: 'groupCategoryData',
+
+      referencing: groupCategory => [groupCategory],
+      referenced: groupCategory => groupCategory.groups,
+    },
+  };
+
+  static [Thing.yamlDocumentSpec] = {
+    fields: {
+      'Category': {property: 'name'},
+
+      'Color': {property: 'color'},
+
+      'Exclude Groups From Gallery Tabs': {
+        property: 'excludeGroupsFromGalleryTabs',
+      },
+    },
+  };
+}
diff --git a/src/data/things/group/Series.js b/src/data/things/group/Series.js
new file mode 100644
index 00000000..940fe575
--- /dev/null
+++ b/src/data/things/group/Series.js
@@ -0,0 +1,79 @@
+import {inspect} from 'node:util';
+
+import {colors} from '#cli';
+import {input, V} from '#composite';
+import Thing from '#thing';
+import {is} from '#validators';
+
+import {contentString, name, referenceList, soupyFind, thing}
+  from '#composite/wiki-properties';
+
+export class Series extends Thing {
+  static [Thing.wikiData] = 'seriesData';
+
+  static [Thing.getPropertyDescriptors] = ({Album, Group}) => ({
+    // Update & expose
+
+    name: name(V('Unnamed Series')),
+
+    showAlbumArtists: {
+      flags: {update: true, expose: true},
+      update: {
+        validate:
+          is('all', 'differing', 'none'),
+      },
+    },
+
+    description: contentString(),
+
+    group: thing(V(Group)),
+
+    albums: referenceList({
+      class: input.value(Album),
+      find: soupyFind.input('album'),
+    }),
+
+    // Update only
+
+    find: soupyFind(),
+  });
+
+  static [Thing.yamlDocumentSpec] = {
+    fields: {
+      'Name': {property: 'name'},
+
+      'Description': {property: 'description'},
+
+      'Show Album Artists': {property: 'showAlbumArtists'},
+
+      'Albums': {property: 'albums'},
+    },
+  };
+
+  [inspect.custom](depth, options, inspect) {
+    const parts = [];
+
+    parts.push(Thing.prototype[inspect.custom].apply(this));
+
+    if (depth >= 0) showGroup: {
+      let group = null;
+      try {
+        group = this.group;
+      } catch {
+        break showGroup;
+      }
+
+      const groupName = group.name;
+      const groupIndex = group.serieses.indexOf(this);
+
+      const num =
+        (groupIndex === -1
+          ? 'indeterminate position'
+          : `#${groupIndex + 1}`);
+
+      parts.push(` (${colors.yellow(num)} in ${colors.green(`"${groupName}"`)})`);
+    }
+
+    return parts.join('');
+  }
+}
diff --git a/src/data/things/group/index.js b/src/data/things/group/index.js
new file mode 100644
index 00000000..1723f136
--- /dev/null
+++ b/src/data/things/group/index.js
@@ -0,0 +1,3 @@
+export * from './Group.js';
+export * from './GroupCategory.js';
+export * from './Series.js';
diff --git a/src/data/things/index.js b/src/data/things/index.js
index 74c6f1e4..4a3d7ad8 100644
--- a/src/data/things/index.js
+++ b/src/data/things/index.js
@@ -1,6 +1,7 @@
 // Not actually the entry point for #things - that's init.js in this folder.
 
 export * from './album/index.js';
+export * from './group/index.js';
 export * from './homepage-layout/index.js';
 
 export * from './AdditionalFile.js';
@@ -18,5 +19,4 @@ export * from './WikiInfo.js';
 
 export * from './content.js';
 export * from './flash.js';
-export * from './group.js';
 export * from './sorting-rule.js';