From 657171a3794ad2f197b9f25ce320cf60dbe36637 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 2 Mar 2021 10:34:53 +0000 Subject: [PATCH 1/2] Auto-regenerate files --- README.md | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 16e90a9b..1fd1cf70 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Generate your metrics that you can embed everywhere, including your GitHub profile readme! It works for both user and organization accounts, and even for repositories! + +*⚠️ This is the documentation of **v3.5-beta** (`@master` branch) which includes [unreleased features](https://github.com/lowlighter/metrics/compare/latest...master), see documentation of **v3.4** (`@latest` branch) [here](https://github.com/lowlighter/metrics/blob/latest/README.md).* + +
| For user accounts | @@ -21,6 +25,9 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
|---|
| @@ -222,6 +229,9 @@ Generate your metrics that you can embed everywhere, including your GitHub profi | |
|---|---|
With posts descriptions and cover images version+ |
@@ -236,6 +246,9 @@ Generate your metrics that you can embed everywhere, including your GitHub profi |
With tweets attachments version+ |
@@ -319,7 +332,7 @@ Assuming your username is `my-github-user`, you can then embed rendered metrics
```
- 💬 How to setup?+💬 How to setup? (click to expand)### 0. Setup your personal repository @@ -432,7 +445,7 @@ For convenience, you can use the shared instance available at [metrics.lecoq.io] This is mostly intended for previews, to enjoy all features consider using GitHub Action instead.
- 💬 Fair use+💬 Fair use (click to expand)To ensure service availability, shared instance has a few limitations: * Images are cached for 15 minutes @@ -458,7 +471,7 @@ Assuming your username is `my-github-user`, you can then embed rendered metrics ```
- 💬 How to setup?+💬 How to setup? (click to expand)### 0. Prepare your server @@ -750,7 +763,7 @@ While metrics targets mainly user accounts, it's possible to render metrics for 
-
💬 Metrics for organizations+💬 Metrics for organizations (click to expand)Setup is the same as for user accounts, though you'll need to add `read:org` scope, **whether you're member of target organization or not**. @@ -778,7 +791,7 @@ To support private repositories, add full `repo` scope to your personal token.
- 💬 Organizations memberships for user accounts+💬 Organizations memberships for user accounts (click to expand)Only public memberships can be displayed by metrics by default. You can manage your membership visibility in the `People` tab of your organization: @@ -814,6 +827,8 @@ Copyright (c) 2020 lowlighter  + + ## 📖 Useful references * [GitHub GraphQL API](https://docs.github.com/en/graphql) From 30414a02417740ff2517193ab04c4cb0ce5b6ec7 Mon Sep 17 00:00:00 2001 From: Simon Lecoq <22963968+lowlighter@users.noreply.github.com> Date: Tue, 2 Mar 2021 11:35:09 +0100 Subject: [PATCH 2/2] Add plugin_people_sponsors_custom option (#166) --- source/plugins/people/README.md | 3 ++- source/plugins/people/index.mjs | 17 +++++++++++++---- source/plugins/people/metadata.yml | 8 ++++++++ source/plugins/people/tests.yml | 8 ++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/source/plugins/people/README.md b/source/plugins/people/README.md index 19b37832..a93c415e 100644 --- a/source/plugins/people/README.md +++ b/source/plugins/people/README.md @@ -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 ``` diff --git a/source/plugins/people/index.mjs b/source/plugins/people/index.mjs index 79b537fa..6b2a1f91 100644 --- a/source/plugins/people/index.mjs +++ b/source/plugins/people/index.mjs @@ -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} } diff --git a/source/plugins/people/metadata.yml b/source/plugins/people/metadata.yml index 1dda0795..cbc3be3c 100644 --- a/source/plugins/people/metadata.yml +++ b/source/plugins/people/metadata.yml @@ -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 diff --git a/source/plugins/people/tests.yml b/source/plugins/people/tests.yml index a39053f6..cf8197a6 100644 --- a/source/plugins/people/tests.yml +++ b/source/plugins/people/tests.yml @@ -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: |