« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/composite/things/content/hasAnnotationPart.js31
-rw-r--r--src/data/composite/things/content/index.js1
-rw-r--r--src/data/things/content.js30
3 files changed, 58 insertions, 4 deletions
diff --git a/src/data/composite/things/content/hasAnnotationPart.js b/src/data/composite/things/content/hasAnnotationPart.js
new file mode 100644
index 00000000..f989d829
--- /dev/null
+++ b/src/data/composite/things/content/hasAnnotationPart.js
@@ -0,0 +1,31 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {exposeWhetherDependencyAvailable} from '#composite/control-flow';
+
+import withAnnotationParts from './withAnnotationParts.js';
+
+export default templateCompositeFrom({
+  annotation: `hasAnnotationPart`,
+
+  compose: false,
+
+  inputs: {
+    part: input({type: 'string'}),
+  },
+
+  steps: () => [
+    withAnnotationParts({
+      mode: input.value('strings'),
+    }),
+
+    withIndexInList({
+      item: input('part'),
+      list: '#annotationParts',
+    }),
+
+    exposeWhetherDependencyAvailable({
+      dependency: '#index',
+      mode: input.value('index'),
+    }),
+  ],
+});
diff --git a/src/data/composite/things/content/index.js b/src/data/composite/things/content/index.js
index 71133ce0..474c2af2 100644
--- a/src/data/composite/things/content/index.js
+++ b/src/data/composite/things/content/index.js
@@ -1,3 +1,4 @@
+export {default as hasAnnotationPart} from './hasAnnotationPart.js';
 export {default as withAnnotationParts} from './withAnnotationParts.js';
 export {default as withSourceText} from './withSourceText.js';
 export {default as withWebArchiveDate} from './withWebArchiveDate.js';
diff --git a/src/data/things/content.js b/src/data/things/content.js
index 660d7020..91da2248 100644
--- a/src/data/things/content.js
+++ b/src/data/things/content.js
@@ -15,8 +15,12 @@ import {
   withResultOfAvailabilityCheck,
 } from '#composite/control-flow';
 
-import {withAnnotationParts, withSourceText, withWebArchiveDate}
-  from '#composite/things/content';
+import {
+  hasAnnotationPart,
+  withAnnotationParts,
+  withSourceText,
+  withWebArchiveDate,
+} from '#composite/things/content';
 
 export class ContentEntry extends Thing {
   static [Thing.getPropertyDescriptors] = ({Artist}) => ({
@@ -134,6 +138,24 @@ export class ContentEntry extends Thing {
   };
 }
 
-export class CommentaryEntry extends ContentEntry {}
-export class LyricsEntry extends ContentEntry {}
+export class CommentaryEntry extends ContentEntry {
+  static [Thing.getPropertyDescriptors] = () => ({
+    // Expose only
+
+    isWikiEditorCommentary: hasAnnotationPart({
+      part: input.value('wiki editor'),
+    }),
+  });
+}
+
+export class LyricsEntry extends ContentEntry {
+  static [Thing.getPropertyDescriptors] = () => ({
+    // Expose only
+
+    isWikiLyrics: hasAnnotationPart({
+      part: input.value('wiki lyrics'),
+    }),
+  });
+}
+
 export class CreditingSourcesEntry extends ContentEntry {}