« 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/StaticPage.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/StaticPage.js')
-rw-r--r--src/data/things/StaticPage.js64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/data/things/StaticPage.js b/src/data/things/StaticPage.js
new file mode 100644
index 00000000..5ddddb9d
--- /dev/null
+++ b/src/data/things/StaticPage.js
@@ -0,0 +1,64 @@
+import {V} from '#composite';
+import Thing from '#thing';
+import {isName} from '#validators';
+
+import {exposeConstant} from '#composite/control-flow';
+import {contentString, directory, flag, name, simpleString}
+  from '#composite/wiki-properties';
+
+export class StaticPage extends Thing {
+  static [Thing.referenceType] = 'static';
+  static [Thing.friendlyName] = `Static Page`;
+  static [Thing.wikiData] = 'staticPageData';
+
+  static [Thing.getPropertyDescriptors] = () => ({
+    // Update & expose
+
+    name: name(V('Unnamed Static Page')),
+
+    nameShort: {
+      flags: {update: true, expose: true},
+      update: {validate: isName},
+
+      expose: {
+        dependencies: ['name'],
+        transform: (value, {name}) => value ?? name,
+      },
+    },
+
+    directory: directory(),
+
+    stylesheet: simpleString(),
+    script: simpleString(),
+    content: contentString(),
+
+    absoluteLinks: flag(V(false)),
+
+    // Expose only
+
+    isStaticPage: exposeConstant(V(true)),
+  });
+
+  static [Thing.findSpecs] = {
+    staticPage: {
+      referenceTypes: ['static'],
+      bindTo: 'staticPageData',
+    },
+  };
+
+  static [Thing.yamlDocumentSpec] = {
+    fields: {
+      'Name': {property: 'name'},
+      'Short Name': {property: 'nameShort'},
+      'Directory': {property: 'directory'},
+
+      'Absolute Links': {property: 'absoluteLinks'},
+
+      'Style': {property: 'stylesheet'},
+      'Script': {property: 'script'},
+      'Content': {property: 'content'},
+
+      'Review Points': {ignore: true},
+    },
+  };
+}