« get me outta code hell

"contributed music/art to groups" on artist pages - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-03-24 19:14:14 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-03-24 19:14:29 -0300
commitcab9c96065939705bd6ac4e1bb872484b205f539 (patch)
treed0f9a24cfa15a3d324539d6e19c209435be20337
parent6911f037d68763d1331c877df6b97160c1a9682e (diff)
"contributed music/art to groups" on artist pages
-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 0cf6a4b..9df6053 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 ace352f..cb0271a 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', {