« get me outta code hell

news entry data - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/thing/news-entry.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2022-02-01 16:41:45 -0400
committer(quasar) nebula <qznebula@protonmail.com>2022-02-01 16:41:45 -0400
commit0ad3d3ce23b47eeccd46d063812372de8b9b190b (patch)
tree393f7f6e5a0ebb0d8a7f1c5b78e6f6a3ae0dc5f8 /src/thing/news-entry.js
parente17bf53b3f17d8d8aa62869d4fc97883acc5c1fa (diff)
news entry data
Diffstat (limited to 'src/thing/news-entry.js')
-rw-r--r--src/thing/news-entry.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/thing/news-entry.js b/src/thing/news-entry.js
new file mode 100644
index 0000000..2db2f37
--- /dev/null
+++ b/src/thing/news-entry.js
@@ -0,0 +1,49 @@
+import Thing from './thing.js';
+
+import {
+    isDate,
+    isDirectory,
+    isName,
+} from './validators.js';
+
+export default class NewsEntry extends Thing {
+    static [Thing.referenceType] = 'news-entry';
+
+    static propertyDescriptors = {
+        // Update & expose
+
+        name: {
+            flags: {update: true, expose: true},
+            update: {validate: isName}
+        },
+
+        directory: {
+            flags: {update: true, expose: true},
+            update: {validate: isDirectory},
+            expose: Thing.directoryExpose
+        },
+
+        date: {
+            flags: {update: true, expose: true},
+            update: {validate: isDate}
+        },
+
+        content: {
+            flags: {update: true, expose: true},
+        },
+
+        // Expose only
+
+        contentShort: {
+            flags: {expose: true},
+
+            expose: {
+                dependencies: ['content'],
+
+                compute({ content }) {
+                    return body.split('<hr class="split">')[0];
+                }
+            }
+        },
+    };
+}