From 781d96ca14dc011fb094eb4bc81442cef4ae04aa Mon Sep 17 00:00:00 2001 From: David Ashby Date: Sat, 2 Apr 2022 17:21:02 -0400 Subject: [PATCH] wrap up initial discogs work --- .gitignore | 3 ++- frontend/files/records/app.js | 38 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 0f649f2..7edbd02 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /manager *.properties .DS_Store -*.csv \ No newline at end of file +*.csv +/vendor \ No newline at end of file diff --git a/frontend/files/records/app.js b/frontend/files/records/app.js index 73a1f3c..fa02c61 100644 --- a/frontend/files/records/app.js +++ b/frontend/files/records/app.js @@ -66,6 +66,21 @@ function renderTable(records, sortField) { function apiResponseParsing(record) { record.sortName = titleCleaner(record.name); + record.artists = record.artists.map((artist) => { + return artist.replace(/ \([0-9]+\)$/, ""); + }); + record.sortArtist = record.artists.reduce((acc, curr) => { + return ( + acc + + curr + .replace(/^(An?|The)\s/i, "") + .toLowerCase() + .replaceAll('"', "") + .replaceAll(":", "") + .replaceAll("'", "") + .replaceAll(" ", "") + ); + }, ""); return record; } @@ -101,28 +116,16 @@ function searchCleaner(str) { .replaceAll(" ", ""); } -// AlbumName string `json:"name"` -// Artists []string `json:"artists"` -// SortArtist string `json:"sortArtist"` -// Identifier string `json:"identifier"` -// Format string `json:"format"` -// Genre string `json:"genre"` -// Label string `json:"label"` -// Year string `json:"year"` -// Description string `json:"description"` -// CoverURL string `json:"coverURL"` -// DiscogsURL string `json:"discogsURL"` - function RecordTemplate({ name, artists, coverURL, - description, format, genre, identifier, label, year, + discogsURL, }) { return `${coverURL ? `` : ""}

${name}

@@ -130,8 +133,13 @@ function RecordTemplate({ ${identifier}
${genre}, ${label}, ${year}
${format} -
-

${description}

+
+ + Data provided by Discogs. +
`; }