« get me outta code hell

organize miscellaneous per-kind-of-thing code alphabetically - 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-12-08 20:04:54 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-28 17:14:14 -0400
commit479ac8741f6be49c3493b85e46d2387f63a02a7e (patch)
treebd98ed75a4bdc42711bed0dbb42aeb15e63cf9bc /src/data
parent4cbbea4bbc03a54b0b96696a960351437bc27635 (diff)
organize miscellaneous per-kind-of-thing code alphabetically
Diffstat (limited to 'src/data')
-rw-r--r--src/data/things/language.js3
-rw-r--r--src/data/yaml.js111
2 files changed, 77 insertions, 37 deletions
diff --git a/src/data/things/language.js b/src/data/things/language.js
index d7e8a1a6..6c15e282 100644
--- a/src/data/things/language.js
+++ b/src/data/things/language.js
@@ -542,12 +542,11 @@ Object.assign(Language.prototype, {
   countAdditionalFiles: countHelper('additionalFiles', 'files'),
   countAlbums: countHelper('albums'),
   countArtworks: countHelper('artworks'),
-  countDays: countHelper('days'),
-  countFlashes: countHelper('flashes'),
   countCommentaryEntries: countHelper('commentaryEntries', 'entries'),
   countContributions: countHelper('contributions'),
   countCoverArts: countHelper('coverArts'),
   countDays: countHelper('days'),
+  countFlashes: countHelper('flashes'),
   countMonths: countHelper('months'),
   countTimesReferenced: countHelper('timesReferenced'),
   countTimesUsed: countHelper('timesUsed'),
diff --git a/src/data/yaml.js b/src/data/yaml.js
index 82b7faf2..c79ce53b 100644
--- a/src/data/yaml.js
+++ b/src/data/yaml.js
@@ -44,14 +44,13 @@ function inspect(value, opts = {}) {
 
 // --> YAML data repository structure constants
 
-export const WIKI_INFO_FILE = 'wiki-info.yaml';
-export const BUILD_DIRECTIVE_DATA_FILE = 'build-directives.yaml';
-export const HOMEPAGE_LAYOUT_DATA_FILE = 'homepage.yaml';
+export const ART_TAG_DATA_FILE = 'tags.yaml';
 export const ARTIST_DATA_FILE = 'artists.yaml';
 export const FLASH_DATA_FILE = 'flashes.yaml';
-export const NEWS_DATA_FILE = 'news.yaml';
-export const ART_TAG_DATA_FILE = 'tags.yaml';
 export const GROUP_DATA_FILE = 'groups.yaml';
+export const HOMEPAGE_LAYOUT_DATA_FILE = 'homepage.yaml';
+export const NEWS_DATA_FILE = 'news.yaml';
+export const WIKI_INFO_FILE = 'wiki-info.yaml';
 
 export const DATA_ALBUM_DIRECTORY = 'album';
 export const DATA_STATIC_PAGE_DIRECTORY = 'static-page';
@@ -1538,7 +1537,63 @@ export async function loadAndProcessDataDocuments({dataPath}) {
 export function linkWikiDataArrays(wikiData, {
   XXX_decacheWikiData = false,
 } = {}) {
-  function assignWikiData(things, ...keys) {
+  const linkWikiDataSpec = new Map([
+    [wikiData.albumData, [
+      'artTagData',
+      'artistData',
+      'groupData',
+    ]],
+
+    [wikiData.artTagData, [
+      'albumData',
+      'trackData',
+    ]],
+
+    [wikiData.artistData, [
+      'albumData',
+      'artistData',
+      'flashData',
+      'trackData',
+    ]],
+
+    [wikiData.flashData, [
+      'artistData',
+      'flashActData',
+      'trackData',
+    ]],
+
+    [wikiData.flashActData, [
+      'flashData',
+    ]],
+
+    [wikiData.groupData, [
+      'albumData',
+      'groupCategoryData',
+    ]],
+
+    [wikiData.groupCategoryData, [
+      'groupData',
+    ]],
+
+    [wikiData.homepageLayout?.rows, [
+      'albumData',
+      'groupData',
+    ]],
+
+    [wikiData.trackData, [
+      'albumData',
+      'artTagData',
+      'artistData',
+      'flashData',
+      'trackData',
+    ]],
+
+    [[wikiData.wikiInfo], [
+      'groupData',
+    ]],
+  ]);
+
+  for (const [things, keys] of linkWikiDataSpec.entries()) {
     if (things === undefined) return;
     for (let i = 0; i < things.length; i++) {
       const thing = things[i];
@@ -1550,20 +1605,6 @@ export function linkWikiDataArrays(wikiData, {
       }
     }
   }
-
-  const WD = wikiData;
-
-  assignWikiData([WD.wikiInfo], 'groupData');
-
-  assignWikiData(WD.albumData, 'artistData', 'artTagData', 'groupData');
-  assignWikiData(WD.trackData, 'albumData', 'artistData', 'artTagData', 'flashData', 'trackData');
-  assignWikiData(WD.artistData, 'albumData', 'artistData', 'flashData', 'trackData');
-  assignWikiData(WD.groupData, 'albumData', 'groupCategoryData');
-  assignWikiData(WD.groupCategoryData, 'groupData');
-  assignWikiData(WD.flashData, 'artistData', 'flashActData', 'trackData');
-  assignWikiData(WD.flashActData, 'flashData');
-  assignWikiData(WD.artTagData, 'albumData', 'trackData');
-  assignWikiData(WD.homepageLayout?.rows, 'albumData', 'groupData');
 }
 
 export function sortWikiDataArrays(wikiData) {
@@ -1667,10 +1708,6 @@ export function filterDuplicateDirectories(wikiData) {
 // data array.
 export function filterReferenceErrors(wikiData) {
   const referenceSpec = [
-    ['wikiInfo', processWikiInfoDocument, {
-      divideTrackListsByGroups: 'group',
-    }],
-
     ['albumData', processAlbumDocument, {
       artistContribs: '_contrib',
       coverArtistContribs: '_contrib',
@@ -1682,17 +1719,6 @@ export function filterReferenceErrors(wikiData) {
       commentary: '_commentary',
     }],
 
-    ['trackData', processTrackDocument, {
-      artistContribs: '_contrib',
-      contributorContribs: '_contrib',
-      coverArtistContribs: '_contrib',
-      referencedTracks: '_trackNotRerelease',
-      sampledTracks: '_trackNotRerelease',
-      artTags: 'artTag',
-      originalReleaseTrack: '_trackNotRerelease',
-      commentary: '_commentary',
-    }],
-
     ['groupCategoryData', processGroupCategoryDocument, {
       groups: 'group',
     }],
@@ -1710,6 +1736,21 @@ export function filterReferenceErrors(wikiData) {
     ['flashActData', processFlashActDocument, {
       flashes: 'flash',
     }],
+
+    ['trackData', processTrackDocument, {
+      artistContribs: '_contrib',
+      contributorContribs: '_contrib',
+      coverArtistContribs: '_contrib',
+      referencedTracks: '_trackNotRerelease',
+      sampledTracks: '_trackNotRerelease',
+      artTags: 'artTag',
+      originalReleaseTrack: '_trackNotRerelease',
+      commentary: '_commentary',
+    }],
+
+    ['wikiInfo', processWikiInfoDocument, {
+      divideTrackListsByGroups: 'group',
+    }],
   ];
 
   function getNestedProp(obj, key) {