« 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/wiki-info.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/wiki-info.js')
-rw-r--r--src/data/things/wiki-info.js109
1 files changed, 57 insertions, 52 deletions
diff --git a/src/data/things/wiki-info.js b/src/data/things/wiki-info.js
index 590598be..26b69ba6 100644
--- a/src/data/things/wiki-info.js
+++ b/src/data/things/wiki-info.js
@@ -1,29 +1,35 @@
 export const WIKI_INFO_FILE = 'wiki-info.yaml';
 
-import {input} from '#composite';
+import {input, V} from '#composite';
 import Thing from '#thing';
-import {parseContributionPresets} from '#yaml';
+import {isBoolean, isContributionPresetList, isLanguageCode, isName}
+  from '#validators';
+import {parseContributionPresets, parseWallpaperParts} from '#yaml';
+
+import {exitWithoutDependency, exposeConstant} from '#composite/control-flow';
 
 import {
-  isBoolean,
-  isColor,
-  isContributionPresetList,
-  isLanguageCode,
-  isName,
-  isURL,
-} from '#validators';
-
-import {exitWithoutDependency} from '#composite/control-flow';
-import {contentString, flag, name, referenceList, soupyFind}
-  from '#composite/wiki-properties';
+  canonicalBase,
+  color,
+  contentString,
+  fileExtension,
+  flag,
+  name,
+  referenceList,
+  simpleString,
+  soupyFind,
+  wallpaperParts,
+} from '#composite/wiki-properties';
 
 export class WikiInfo extends Thing {
   static [Thing.friendlyName] = `Wiki Info`;
+  static [Thing.wikiData] = 'wikiInfo';
+  static [Thing.oneInstancePerWiki] = true;
 
   static [Thing.getPropertyDescriptors] = ({Group}) => ({
     // Update & expose
 
-    name: name('Unnamed Wiki'),
+    name: name(V('Unnamed Wiki')),
 
     // Displayed in nav bar.
     nameShort: {
@@ -36,14 +42,7 @@ export class WikiInfo extends Thing {
       },
     },
 
-    color: {
-      flags: {update: true, expose: true},
-      update: {validate: isColor},
-
-      expose: {
-        transform: color => color ?? '#0088ff',
-      },
-    },
+    color: color(V('#0088ff')),
 
     // One-line description used for <meta rel="description"> tag.
     description: contentString(),
@@ -55,18 +54,12 @@ export class WikiInfo extends Thing {
       update: {validate: isLanguageCode},
     },
 
-    canonicalBase: {
-      flags: {update: true, expose: true},
-      update: {validate: isURL},
-      expose: {
-        transform: (value) =>
-          (value === null
-            ? null
-         : value.endsWith('/')
-            ? value
-            : value + '/'),
-      },
-    },
+    canonicalBase: canonicalBase(),
+    canonicalMediaBase: canonicalBase(),
+
+    wikiWallpaperFileExtension: fileExtension(V('jpg')),
+    wikiWallpaperStyle: simpleString(),
+    wikiWallpaperParts: wallpaperParts(),
 
     divideTrackListsByGroups: referenceList({
       class: input.value(Group),
@@ -79,20 +72,19 @@ export class WikiInfo extends Thing {
     },
 
     // Feature toggles
-    enableFlashesAndGames: flag(false),
-    enableListings: flag(false),
-    enableNews: flag(false),
-    enableArtTagUI: flag(false),
-    enableGroupUI: flag(false),
+    enableFlashesAndGames: flag(V(false)),
+    enableListings: flag(V(false)),
+    enableNews: flag(V(false)),
+    enableArtTagUI: flag(V(false)),
+    enableGroupUI: flag(V(false)),
 
     enableSearch: [
-      exitWithoutDependency({
-        dependency: 'searchDataAvailable',
-        mode: input.value('falsy'),
+      exitWithoutDependency('_searchDataAvailable', {
         value: input.value(false),
+        mode: input.value('falsy'),
       }),
 
-      flag(true),
+      flag(V(true)),
     ],
 
     // Update only
@@ -106,24 +98,45 @@ export class WikiInfo extends Thing {
         default: false,
       },
     },
+
+    // Expose only
+
+    isWikiInfo: exposeConstant(V(true)),
   });
 
   static [Thing.yamlDocumentSpec] = {
     fields: {
       'Name': {property: 'name'},
       'Short Name': {property: 'nameShort'},
+
       'Color': {property: 'color'},
+
       'Description': {property: 'description'},
+
       'Footer Content': {property: 'footerContent'},
+
       'Default Language': {property: 'defaultLanguage'},
+
       'Canonical Base': {property: 'canonicalBase'},
-      'Divide Track Lists By Groups': {property: 'divideTrackListsByGroups'},
+      'Canonical Media Base': {property: 'canonicalMediaBase'},
+
+      'Wiki Wallpaper File Extension': {property: 'wikiWallpaperFileExtension'},
+
+      'Wiki Wallpaper Style': {property: 'wikiWallpaperStyle'},
+
+      'Wiki Wallpaper Parts': {
+        property: 'wikiWallpaperParts',
+        transform: parseWallpaperParts,
+      },
+
       'Enable Flashes & Games': {property: 'enableFlashesAndGames'},
       'Enable Listings': {property: 'enableListings'},
       'Enable News': {property: 'enableNews'},
       'Enable Art Tag UI': {property: 'enableArtTagUI'},
       'Enable Group UI': {property: 'enableGroupUI'},
 
+      'Divide Track Lists By Groups': {property: 'divideTrackListsByGroups'},
+
       'Contribution Presets': {
         property: 'contributionPresets',
         transform: parseContributionPresets,
@@ -140,13 +153,5 @@ export class WikiInfo extends Thing {
 
     documentMode: oneDocumentTotal,
     documentThing: WikiInfo,
-
-    save(wikiInfo) {
-      if (!wikiInfo) {
-        return;
-      }
-
-      return {wikiInfo};
-    },
   });
 }