« 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/composite/wiki-properties/canonicalBase.js16
-rw-r--r--src/data/composite/wiki-properties/index.js1
-rw-r--r--src/data/things/wiki-info.js17
3 files changed, 21 insertions, 13 deletions
diff --git a/src/data/composite/wiki-properties/canonicalBase.js b/src/data/composite/wiki-properties/canonicalBase.js
new file mode 100644
index 00000000..81740d6c
--- /dev/null
+++ b/src/data/composite/wiki-properties/canonicalBase.js
@@ -0,0 +1,16 @@
+import {isURL} from '#validators';
+
+export default function() {
+  return {
+    flags: {update: true, expose: true},
+    update: {validate: isURL},
+    expose: {
+      transform: (value) =>
+        (value === null
+          ? null
+       : value.endsWith('/')
+          ? value
+          : value + '/'),
+    },
+  };
+}
diff --git a/src/data/composite/wiki-properties/index.js b/src/data/composite/wiki-properties/index.js
index e8f109d3..57a2b8f2 100644
--- a/src/data/composite/wiki-properties/index.js
+++ b/src/data/composite/wiki-properties/index.js
@@ -4,6 +4,7 @@
 // #composite/data, and #composite/wiki-data.
 
 export {default as annotatedReferenceList} from './annotatedReferenceList.js';
+export {default as canonicalBase} from './canonicalBase.js';
 export {default as color} from './color.js';
 export {default as commentatorArtists} from './commentatorArtists.js';
 export {default as constitutibleArtwork} from './constitutibleArtwork.js';
diff --git a/src/data/things/wiki-info.js b/src/data/things/wiki-info.js
index b6057735..7fb6a350 100644
--- a/src/data/things/wiki-info.js
+++ b/src/data/things/wiki-info.js
@@ -10,12 +10,12 @@ import {
   isContributionPresetList,
   isLanguageCode,
   isName,
-  isURL,
 } from '#validators';
 
 import {exitWithoutDependency, exposeConstant} from '#composite/control-flow';
 
 import {
+  canonicalBase,
   contentString,
   fileExtension,
   flag,
@@ -64,18 +64,8 @@ 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('jpg'),
     wikiWallpaperStyle: simpleString(),
@@ -143,6 +133,7 @@ export class WikiInfo extends Thing {
       'Default Language': {property: 'defaultLanguage'},
 
       'Canonical Base': {property: 'canonicalBase'},
+      'Canonical Media Base': {property: 'canonicalMediaBase'},
 
       'Wiki Wallpaper File Extension': {property: 'wikiWallpaperFileExtension'},