« 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
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
parent4cbbea4bbc03a54b0b96696a960351437bc27635 (diff)
organize miscellaneous per-kind-of-thing code alphabetically
Diffstat (limited to 'src')
-rw-r--r--src/data/things/language.js3
-rw-r--r--src/data/yaml.js111
-rw-r--r--src/gen-thumbs.js8
-rw-r--r--src/url-spec.js14
4 files changed, 90 insertions, 46 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) {
diff --git a/src/gen-thumbs.js b/src/gen-thumbs.js
index e6c1f5c2..4b2f934d 100644
--- a/src/gen-thumbs.js
+++ b/src/gen-thumbs.js
@@ -779,16 +779,16 @@ export function getExpectedImagePaths(mediaPath, {urls, wikiData}) {
       ])
       .filter(Boolean),
 
-    wikiData.trackData
-      .filter(track => track.hasUniqueCoverArt)
-      .map(track => fromRoot.to('media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension)),
-
     wikiData.artistData
       .filter(artist => artist.hasAvatar)
       .map(artist => fromRoot.to('media.artistAvatar', artist.directory, artist.avatarFileExtension)),
 
     wikiData.flashData
       .map(flash => fromRoot.to('media.flashArt', flash.directory, flash.coverArtFileExtension)),
+
+    wikiData.trackData
+      .filter(track => track.hasUniqueCoverArt)
+      .map(track => fromRoot.to('media.trackCover', track.album.directory, track.directory, track.coverArtFileExtension)),
   ].flat();
 
   sortByName(paths, {getName: path => path});
diff --git a/src/url-spec.js b/src/url-spec.js
index 699f2bef..ea5337a2 100644
--- a/src/url-spec.js
+++ b/src/url-spec.js
@@ -26,8 +26,8 @@ const urlSpec = {
       home: '',
 
       album: 'album/<>/',
-      albumGallery: 'album/<>/gallery/',
       albumCommentary: 'commentary/album/<>/',
+      albumGallery: 'album/<>/gallery/',
 
       artist: 'artist/<>/',
       artistGallery: 'artist/<>/gallery/',
@@ -35,6 +35,7 @@ const urlSpec = {
       commentaryIndex: 'commentary/',
 
       flashIndex: 'flash/',
+
       flash: 'flash/<>/',
 
       flashActGallery: 'flash-act/<>/',
@@ -43,13 +44,17 @@ const urlSpec = {
       groupGallery: 'group/<>/gallery/',
 
       listingIndex: 'list/',
+
       listing: 'list/<>/',
 
       newsIndex: 'news/',
+
       newsEntry: 'news/<>/',
 
       staticPage: '<>/',
+
       tag: 'tag/<>/',
+
       track: 'track/<>/',
     },
   },
@@ -76,17 +81,16 @@ const urlSpec = {
       root: '',
       path: '<>',
 
+      albumAdditionalFile: 'album-additional/<>/<>',
+      albumBanner: 'album-art/<>/banner.<>',
       albumCover: 'album-art/<>/cover.<>',
       albumWallpaper: 'album-art/<>/bg.<>',
-      albumBanner: 'album-art/<>/banner.<>',
-
-      trackCover: 'album-art/<>/<>.<>',
 
       artistAvatar: 'artist-avatar/<>.<>',
 
       flashArt: 'flash-art/<>.<>',
 
-      albumAdditionalFile: 'album-additional/<>/<>',
+      trackCover: 'album-art/<>/<>.<>',
     },
   },