« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/thing
diff options
context:
space:
mode:
Diffstat (limited to 'src/thing')
-rw-r--r--src/thing/static-page.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/thing/static-page.js b/src/thing/static-page.js
new file mode 100644
index 00000000..18e9d142
--- /dev/null
+++ b/src/thing/static-page.js
@@ -0,0 +1,52 @@
+import Thing from './thing.js';
+
+import {
+    isBoolean,
+    isDirectory,
+    isName,
+    isString,
+} from './validators.js';
+
+export default class StaticPage extends Thing {
+    static [Thing.referenceType] = 'static';
+
+    static propertyDescriptors = {
+        // Update & expose
+
+        name: {
+            flags: {update: true, expose: true},
+            update: {validate: isName}
+        },
+
+        nameShort: {
+            flags: {update: true, expose: true},
+            update: {validate: isName},
+
+            expose: {
+                dependencies: ['name'],
+                transform: (value, { name }) => value ?? name
+            }
+        },
+
+        directory: {
+            flags: {update: true, expose: true},
+            update: {validate: isDirectory},
+            expose: Thing.directoryExpose
+        },
+
+        content: {
+            flags: {update: true, expose: true},
+            update: {validate: isString}
+        },
+
+        stylesheet: {
+            flags: {update: true, expose: true},
+            update: {validate: isString}
+        },
+
+        showInNavigationBar: {
+            flags: {update: true, expose: true},
+            update: {validate: isBoolean, default: true}
+        },
+    };
+}