From 732273af162ff6b97cf4442964223fbf6c2acf5f Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Tue, 31 Jan 2023 09:49:02 -0400 Subject: data format cleanup: tracks * Remove `Has URLs` (`hasURLs`), unused * Tidy `propertyFieldMapping` order --- src/data/things/track.js | 2 -- src/data/yaml.js | 15 ++++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/data/things/track.js b/src/data/things/track.js index 6b1e958b..1778ed27 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/yaml.js b/src/data/yaml.js index f269d447..c4fb3ae9 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -255,29 +255,26 @@ 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', + + 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', }, }); -- cgit 1.3.0-6-gf8a5 From bbb9a3ad9c4626b4b9a2559d0e251d1fe1f5ef01 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 4 Feb 2023 20:32:24 -0400 Subject: data format cleanup: albums * Remove `Is Major Release` (`isMajorRelease`) * Remove major-release code in wiki-data.js * Tidy `propertyFieldMapping` order Major releases were useful when albums were being added to the wiki on the regular, but are unused on HSMusic now, and alternative approaches get more particular results (currently hard-coded grid layout for larger icons, and manually selected albums in homepage rows). --- src/data/things/album.js | 2 -- src/data/yaml.js | 35 ++++++++++++++++------------------- src/util/wiki-data.js | 41 +++++++---------------------------------- 3 files changed, 23 insertions(+), 55 deletions(-) (limited to 'src') 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/yaml.js b/src/data/yaml.js index c4fb3ae9..18f67c74 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', }, }); diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js index c93cb661..0eb86a1e 100644 --- a/src/util/wiki-data.js +++ b/src/util/wiki-data.js @@ -424,26 +424,14 @@ export function getArtistAvatar(artist, {to}) { // Big-ass homepage row functions export function getNewAdditions(numAlbums, {wikiData}) { - const {albumData} = wikiData; - - // Sort al8ums, in descending order of priority, 8y... - // - // * D8te of addition to the wiki (descending). - // * Major releases first. - // * D8te of release (descending). - // - // Major releases go first to 8etter ensure they show up in the list (and - // are usually at the start of the final output for a given d8 of release - // too). - const sortedAlbums = albumData + const sortedAlbums = wikiData.albumData .filter((album) => album.isListedOnHomepage) .sort((a, b) => { if (a.dateAddedToWiki > b.dateAddedToWiki) return -1; if (a.dateAddedToWiki < b.dateAddedToWiki) return 1; - if (a.isMajorRelease && !b.isMajorRelease) return -1; - if (!a.isMajorRelease && b.isMajorRelease) return 1; if (a.date > b.date) return -1; if (a.date < b.date) return 1; + return 0; }); // When multiple al8ums are added to the wiki at a time, we want to show @@ -515,28 +503,13 @@ export function getNewAdditions(numAlbums, {wikiData}) { } } - // Finally, do some quick mapping shenanigans to 8etter display the result - // in a grid. (This should pro8a8ly 8e a separ8te, shared function, 8ut - // whatevs.) - return albums.map((album) => ({large: album.isMajorRelease, item: album})); + return albums.map((album) => ({item: album})); } export function getNewReleases(numReleases, {wikiData}) { - const {albumData} = wikiData; - - const latestFirst = albumData + return wikiData.albumData .filter((album) => album.isListedOnHomepage) - .reverse(); - - const majorReleases = latestFirst.filter((album) => album.isMajorRelease); - majorReleases.splice(1); - - const otherReleases = latestFirst - .filter((album) => !majorReleases.includes(album)) - .slice(0, numReleases - majorReleases.length); - - return [ - ...majorReleases.map((album) => ({large: true, item: album})), - ...otherReleases.map((album) => ({large: false, item: album})), - ]; + .reverse() + .slice(0, numReleases) + .map((album) => ({item: album})); } -- cgit 1.3.0-6-gf8a5 From f554897f3728fcb771fe26dffad898a54b37335a Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 5 Feb 2023 08:40:25 -0400 Subject: data format cleanup: commentary fields The parseCommentary function was actually going unused. This commit moves its behavior to the more appropriate location (validateCommentary), which actually unveils a couple data errors in the HSMusic data files. --- src/data/things/validators.js | 13 ++++++++++++- src/data/yaml.js | 12 ------------ 2 files changed, 12 insertions(+), 13 deletions(-) (limited to 'src') 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(':')) { + 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 18f67c74..47cdc858 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -474,18 +474,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(':')) { - throw new Error(`Missing commentary citation: "${lines[0].slice(0, 40)}..."`); - } - return text; - } else { - return null; - } -} - export function parseContributors(contributors) { if (!contributors) { return null; -- cgit 1.3.0-6-gf8a5 From 3b873a6d04f3d317423d1a037536692de808b6fe Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 24 Feb 2023 14:57:47 -0400 Subject: regroup some yaml fields --- src/data/yaml.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/data/yaml.js b/src/data/yaml.js index d2a1a053..6350588d 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -278,15 +278,14 @@ export const processTrackDocument = makeProcessDocument(T.Track, { 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'], @@ -301,15 +300,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', }, }); @@ -369,8 +368,8 @@ export const processStaticPageDocument = makeProcessDocument(T.StaticPage, { nameShort: 'Short Name', directory: 'Directory', - content: 'Content', stylesheet: 'Style', + content: 'Content', }, }); -- cgit 1.3.0-6-gf8a5