« get me outta code hell

Merge branch 'preview' into sheet-music-midis - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-02-26 18:04:59 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-02-26 18:13:48 -0400
commit999fc0c58485649aee8e4deb3ea6419aa687c228 (patch)
treef19bd9e3ad038ddfb823e20ad19868e03cc9ee4c /src/data
parent212c5fe9972dad3c53826c0364376a98b6c5a3c3 (diff)
parent8d05431f0c815227ba5cd503e88b0ee531c6eeb8 (diff)
Merge branch 'preview' into sheet-music-midis
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/album.js2
-rw-r--r--src/data/things/track.js2
-rw-r--r--src/data/things/validators.js13
-rw-r--r--src/data/yaml.js77
4 files changed, 41 insertions, 53 deletions
diff --git a/src/data/things/album.js b/src/data/things/album.js
index 0c0c7fb4..2a188f2d 100644
--- a/src/data/things/album.js
+++ b/src/data/things/album.js
@@ -106,7 +106,6 @@ export class Album extends Thing {
     hasCoverArt: Thing.common.flag(true),
     hasTrackArt: Thing.common.flag(true),
     hasTrackNumbers: Thing.common.flag(true),
-    isMajorRelease: Thing.common.flag(false),
     isListedOnHomepage: Thing.common.flag(true),
     isListedInGalleries: Thing.common.flag(true),
 
@@ -192,7 +191,6 @@ export class Album extends Thing {
     bannerDimensions: S.id,
 
     hasTrackArt: S.id,
-    isMajorRelease: S.id,
     isListedOnHomepage: S.id,
 
     commentary: S.id,
diff --git a/src/data/things/track.js b/src/data/things/track.js
index aecc876f..0751b2d0 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -34,8 +34,6 @@ export class Track extends Thing {
     urls: Thing.common.urls(),
     dateFirstReleased: Thing.common.simpleDate(),
 
-    hasURLs: Thing.common.flag(true),
-
     artistContribsByRef: Thing.common.contribsByRef(),
     contributorContribsByRef: Thing.common.contribsByRef(),
     coverArtistContribsByRef: Thing.common.contribsByRef(),
diff --git a/src/data/things/validators.js b/src/data/things/validators.js
index 24db3c79..b116120a 100644
--- a/src/data/things/validators.js
+++ b/src/data/things/validators.js
@@ -195,7 +195,18 @@ export function isColor(color) {
 }
 
 export function isCommentary(commentary) {
-  return isString(commentary);
+  isString(commentary);
+
+  const [firstLine] = commentary.match(/.*/);
+  if (!firstLine.replace(/<\/b>/g, '').includes(':</i>')) {
+    throw new TypeError(`Missing commentary citation: "${
+      firstLine.length > 40
+        ? firstLine.slice(0, 40) + '...'
+        : firstLine
+    }"`);
+  }
+
+  return true;
 }
 
 const isArtistRef = validateReference('artist');
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 01cb5501..7cd23cfc 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -186,14 +186,20 @@ export const processAlbumDocument = makeProcessDocument(T.Album, {
 
   propertyFieldMapping: {
     name: 'Album',
-
-    color: 'Color',
     directory: 'Directory',
+    date: 'Date',
+    color: 'Color',
     urls: 'URLs',
 
-    artistContribsByRef: 'Artists',
-    coverArtistContribsByRef: 'Cover Artists',
-    trackCoverArtistContribsByRef: 'Default Track Cover Artists',
+    hasCoverArt: 'Has Cover Art',
+    hasTrackArt: 'Has Track Art',
+    hasTrackNumbers: 'Has Track Numbers',
+    isListedOnHomepage: 'Listed on Homepage',
+    isListedInGalleries: 'Listed in Galleries',
+
+    coverArtDate: 'Cover Art Date',
+    trackArtDate: 'Default Track Cover Art Date',
+    dateAddedToWiki: 'Date Added',
 
     coverArtFileExtension: 'Cover Art File Extension',
     trackCoverArtFileExtension: 'Track Art File Extension',
@@ -207,23 +213,14 @@ export const processAlbumDocument = makeProcessDocument(T.Album, {
     bannerFileExtension: 'Banner File Extension',
     bannerDimensions: 'Banner Dimensions',
 
-    date: 'Date',
-    trackArtDate: 'Default Track Cover Art Date',
-    coverArtDate: 'Cover Art Date',
-    dateAddedToWiki: 'Date Added',
-
-    hasCoverArt: 'Has Cover Art',
-    hasTrackArt: 'Has Track Art',
-    hasTrackNumbers: 'Has Track Numbers',
-    isMajorRelease: 'Major Release',
-    isListedOnHomepage: 'Listed on Homepage',
-    isListedInGalleries: 'Listed in Galleries',
+    commentary: 'Commentary',
+    additionalFiles: 'Additional Files',
 
+    artistContribsByRef: 'Artists',
+    coverArtistContribsByRef: 'Cover Artists',
+    trackCoverArtistContribsByRef: 'Default Track Cover Artists',
     groupsByRef: 'Groups',
     artTagsByRef: 'Art Tags',
-    commentary: 'Commentary',
-
-    additionalFiles: 'Additional Files',
   },
 });
 
@@ -257,46 +254,42 @@ export const processTrackDocument = makeProcessDocument(T.Track, {
 
   propertyFieldMapping: {
     name: 'Track',
-
     directory: 'Directory',
     duration: 'Duration',
     urls: 'URLs',
 
+    dateFirstReleased: 'Date First Released',
     coverArtDate: 'Cover Art Date',
     coverArtFileExtension: 'Cover Art File Extension',
-    dateFirstReleased: 'Date First Released',
     hasCoverArt: 'Has Cover Art',
-    hasURLs: 'Has URLs',
 
+    lyrics: 'Lyrics',
+    commentary: 'Commentary',
+    additionalFiles: 'Additional Files',
+    sheetMusicFiles: 'Sheet Music Files',
+    midiProjectFiles: 'MIDI Project Files',
+
+    originalReleaseTrackByRef: 'Originally Released As',
     referencedTracksByRef: 'Referenced Tracks',
     sampledTracksByRef: 'Sampled Tracks',
     artistContribsByRef: 'Artists',
     contributorContribsByRef: 'Contributors',
     coverArtistContribsByRef: 'Cover Artists',
     artTagsByRef: 'Art Tags',
-    originalReleaseTrackByRef: 'Originally Released As',
-
-    commentary: 'Commentary',
-    lyrics: 'Lyrics',
-
-    additionalFiles: 'Additional Files',
-    sheetMusicFiles: 'Sheet Music Files',
-    midiProjectFiles: 'MIDI Project Files',
   },
 });
 
 export const processArtistDocument = makeProcessDocument(T.Artist, {
   propertyFieldMapping: {
     name: 'Artist',
-
     directory: 'Directory',
     urls: 'URLs',
+    contextNotes: 'Context Notes',
+
     hasAvatar: 'Has Avatar',
     avatarFileExtension: 'Avatar File Extension',
 
     aliasNames: 'Aliases',
-
-    contextNotes: 'Context Notes',
   },
 
   ignoredFields: ['Dead URLs'],
@@ -311,15 +304,15 @@ export const processFlashDocument = makeProcessDocument(T.Flash, {
 
   propertyFieldMapping: {
     name: 'Flash',
-
     directory: 'Directory',
     page: 'Page',
+    urls: 'URLs',
+
     date: 'Date',
     coverArtFileExtension: 'Cover Art File Extension',
 
     featuredTracksByRef: 'Featured Tracks',
     contributorContribsByRef: 'Contributors',
-    urls: 'URLs',
   },
 });
 
@@ -379,8 +372,8 @@ export const processStaticPageDocument = makeProcessDocument(T.StaticPage, {
     nameShort: 'Short Name',
     directory: 'Directory',
 
-    content: 'Content',
     stylesheet: 'Style',
+    content: 'Content',
   },
 });
 
@@ -479,18 +472,6 @@ export function parseAdditionalFiles(array) {
   }));
 }
 
-export function parseCommentary(text) {
-  if (text) {
-    const lines = String(text.trim()).split('\n');
-    if (!lines[0].replace(/<\/b>/g, '').includes(':</i>')) {
-      throw new Error(`Missing commentary citation: "${lines[0].slice(0, 40)}..."`);
-    }
-    return text;
-  } else {
-    return null;
-  }
-}
-
 export function parseContributors(contributors) {
   // If this isn't something we can parse, just return it as-is.
   // The Thing object's validators will handle the data error better