Add plugin_people_sponsors_custom option (#166)
This commit is contained in:
@@ -50,6 +50,7 @@ Sections will be ordered the same as specified in `plugin_people_types`.
|
||||
plugin_people_limit: 28 # Limit to 28 entries per section
|
||||
plugin_people_size: 28 # Size in pixels of displayed avatars
|
||||
plugin_people_identicons: no # Use avatars (do not use identicons)
|
||||
plugin_people_thanks: lowlighter, octocat # Users that will be displayed in "thanks" sections
|
||||
plugin_people_thanks: lowlighter, octocat # Users that will be displayed in "thanks" section
|
||||
plugin_people_sponsors_custom: octocat # Users that will be displayed additionally in "sponsors" section
|
||||
plugin_people_shuffle: yes # Shuffle for varied output
|
||||
```
|
||||
|
||||
@@ -21,9 +21,13 @@
|
||||
}
|
||||
|
||||
//Load inputs
|
||||
let {limit, types, size, identicons, thanks, shuffle} = imports.metadata.plugins.people.inputs({data, account, q}, {types:context.default})
|
||||
let {limit, types, size, identicons, thanks, shuffle, "sponsors.custom":_sponsors} = imports.metadata.plugins.people.inputs({data, account, q}, {types:context.default})
|
||||
//Filter types
|
||||
types = [...new Set([...types].map(type => (context.alias[type] ?? type)).filter(type => context.types.includes(type)) ?? [])]
|
||||
if ((types.includes("sponsorshipsAsMaintainer"))&&(_sponsors?.length)) {
|
||||
types.unshift("sponsorshipsCustom")
|
||||
data.user.sponsorshipsAsMaintainer.totalCount += _sponsors.length
|
||||
}
|
||||
|
||||
//Retrieve followers from graphql api
|
||||
console.debug(`metrics/compute/${login}/plugins > people > querying api`)
|
||||
@@ -37,9 +41,10 @@
|
||||
const {data:nodes} = await rest.repos.listContributors({owner, repo})
|
||||
result[type].push(...nodes.map(({login, avatar_url}) => ({login, avatarUrl:avatar_url})))
|
||||
}
|
||||
else if (type === "thanks") {
|
||||
const nodes = await Promise.all(thanks.map(async username => (await rest.users.getByUsername({username})).data))
|
||||
result[type].push(...nodes.map(({login, avatar_url}) => ({login, avatarUrl:avatar_url})))
|
||||
else if ((type === "thanks")||(type === "sponsorshipsCustom")) {
|
||||
const users = {thanks, sponsorshipsCustom:_sponsors}[type] ?? []
|
||||
const nodes = await Promise.all(users.map(async username => (await rest.users.getByUsername({username})).data))
|
||||
result[{sponsorshipsCustom:"sponsorshipsAsMaintainer"}[type] ?? type].push(...nodes.map(({login, avatar_url}) => ({login, avatarUrl:avatar_url})))
|
||||
}
|
||||
//GraphQL
|
||||
else {
|
||||
@@ -77,6 +82,10 @@
|
||||
await Promise.all(result[type].map(async user => user.avatar = await imports.imgb64(user.avatarUrl)))
|
||||
}
|
||||
|
||||
//Special type handling
|
||||
if (types.includes("sponsorshipsCustom"))
|
||||
types.splice(types.indexOf("sponsorshipsCustom"), 1)
|
||||
|
||||
//Results
|
||||
return {types, size, ...result}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,14 @@ inputs:
|
||||
format: comma-separated
|
||||
default: ""
|
||||
|
||||
# Add specified users to GitHub sponsors ("sponsors" must be specified in "plugin_people_types")
|
||||
# This is useful to list sponsors from unsupported GitHub sponsors sources
|
||||
plugin_people_sponsors_custom:
|
||||
description: Custom GitHub sponsors
|
||||
type: array
|
||||
format: comma-separated
|
||||
default: ""
|
||||
|
||||
# Use GitHub identicons instead of users' avatar (for privacy purposes)
|
||||
plugin_people_identicons:
|
||||
description: Use identicons instead of avatars
|
||||
|
||||
@@ -32,6 +32,14 @@
|
||||
plugin_people: yes
|
||||
plugin_people_types: sponsors
|
||||
|
||||
- name: People plugin (custom sponsors)
|
||||
uses: lowlighter/metrics@latest
|
||||
with:
|
||||
token: MOCKED_TOKEN
|
||||
plugin_people: yes
|
||||
plugin_people_types: sponsors
|
||||
plugin_people_sponsors_custom: lowlighter, octocat
|
||||
|
||||
- name: People plugin (stargazers)
|
||||
uses: lowlighter/metrics@latest
|
||||
with:
|
||||
|
||||
Reference in New Issue
Block a user