From cab9c96065939705bd6ac4e1bb872484b205f539 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 24 Mar 2021 19:14:14 -0300 Subject: "contributed music/art to groups" on artist pages --- strings-default.json | 3 +++ upd8.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) 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}) })}

+

${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) + }))) + })}

${generateTrackList(releasedTrackListChunks, {strings, to})} `} ${unreleasedTracks.length && fixWS` @@ -3202,6 +3223,13 @@ function writeArtistPage(artist) { text: strings('artistPage.viewArtGallery.link') }) })}

`} +

${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) + }))) + })}

${artListChunks.map(({album, chunk}) => fixWS`
${strings('artistPage.creditList.album.withDate', { -- cgit 1.3.0-6-gf8a5