« get me outta code hell

LyricsEntry.js « content « things « data « src - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/content/LyricsEntry.js
blob: 88e4464dfdf4b4abcf67c0b3f8dc08a53ecf0a27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {V} from '#composite';
import Thing from '#thing';

import {exitWithoutDependency, exposeConstant} from '#composite/control-flow';
import {contentString} from '#composite/wiki-properties';

import {hasAnnotationPart} from '#composite/things/content';

import {ContentEntry} from './ContentEntry.js';

export class LyricsEntry extends ContentEntry {
  static [Thing.wikiData] = 'lyricsData';

  static [Thing.getPropertyDescriptors] = () => ({
    // Update & expose

    originDetails: contentString(),

    // Expose only

    isLyricsEntry: exposeConstant(V(true)),

    isWikiLyrics: hasAnnotationPart(V('wiki lyrics')),
    helpNeeded: hasAnnotationPart(V('help needed')),

    hasSquareBracketAnnotations: [
      exitWithoutDependency('isWikiLyrics', V(false), V('falsy')),
      exitWithoutDependency('body', V(false)),

      {
        dependencies: ['body'],
        compute: ({body}) =>
          /\[.*\]/m.test(body),
      },
    ],
  });

  static [Thing.yamlDocumentSpec] = Thing.extendDocumentSpec(ContentEntry, {
    fields: {
      'Origin Details': {property: 'originDetails'},
    },
  });
}