« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--strings-default.json3
-rwxr-xr-xupd8.js28
2 files changed, 31 insertions, 0 deletions
diff --git a/strings-default.json b/strings-default.json
index 0cf6a4bb..9df60538 100644
--- a/strings-default.json
+++ b/strings-default.json
@@ -177,6 +177,9 @@
     "artistPage.creditList.entry.withArtists": "{ENTRY} (with {ARTISTS})",
     "artistPage.creditList.entry.withArtists.withContribution": "{ENTRY} ({CONTRIBUTION}; with {ARTISTS})",
     "artistPage.contributedDurationLine": "{ARTIST} has contributed {DURATION} of music shared on this wiki.",
+    "artistPage.musicGroupsLine": "Contributed music to groups: {GROUPS}",
+    "artistPage.artGroupsLine": "Contributed art to groups: {GROUPS}",
+    "artistPage.groupsLine.item": "{GROUP} ({CONTRIBUTIONS})",
     "artistPage.trackList.title": "Tracks",
     "artistPage.unreleasedTrackList.title": "Unreleased Tracks",
     "artistPage.artList.title": "Art",
diff --git a/upd8.js b/upd8.js
index ace352fe..cb0271a1 100755
--- a/upd8.js
+++ b/upd8.js
@@ -3061,6 +3061,20 @@ function writeArtistPage(artist) {
 
     const totalReleasedDuration = getTotalDuration(releasedTracks);
 
+    const countGroups = things => {
+        const usedGroups = things.flatMap(thing => thing.groups || thing.album?.groups || []);
+        return groupData
+            .map(group => ({
+                group,
+                contributions: usedGroups.filter(g => g === group).length
+            }))
+            .filter(({ contributions }) => contributions > 0)
+            .sort((a, b) => b.contributions - a.contributions);
+    };
+
+    const musicGroups = countGroups(releasedTracks);
+    const artGroups = countGroups(artThingsAll);
+
     let flashes, flashListChunks;
     if (wikiInfo.features.flashesAndGames) {
         flashes = C.sortByDate(artist.flashes.asContributor.slice());
@@ -3188,6 +3202,13 @@ function writeArtistPage(artist) {
                             artist: artist.name,
                             duration: strings.count.duration(totalReleasedDuration, {approximate: true, unit: true})
                         })}</p>
+                        <p>${strings('artistPage.musicGroupsLine', {
+                            groups: strings.list.unit(musicGroups
+                                .map(({ group, contributions }) => strings('artistPage.groupsLine.item', {
+                                    group: strings.link.groupInfo(group, {to}),
+                                    contributions: strings.count.contributions(contributions)
+                                })))
+                        })}</p>
                         ${generateTrackList(releasedTrackListChunks, {strings, to})}
                     `}
                     ${unreleasedTracks.length && fixWS`
@@ -3202,6 +3223,13 @@ function writeArtistPage(artist) {
                                 text: strings('artistPage.viewArtGallery.link')
                             })
                         })}</p>`}
+                        <p>${strings('artistPage.artGroupsLine', {
+                            groups: strings.list.unit(artGroups
+                                .map(({ group, contributions }) => strings('artistPage.groupsLine.item', {
+                                    group: strings.link.groupInfo(group, {to}),
+                                    contributions: strings.count.contributions(contributions)
+                                })))
+                        })}</p>
                         <dl>
                             ${artListChunks.map(({album, chunk}) => fixWS`
                                 <dt>${strings('artistPage.creditList.album.withDate', {