This commit is contained in:
lowlighter
2021-03-02 11:39:43 +01:00
5 changed files with 51 additions and 10 deletions

View File

@@ -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!
<sup>*⚠️ 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).*</sup>
<table>
<tr>
<th align="center">For user accounts</th>
@@ -21,6 +25,9 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
</tr>
</table>
And you can customize these heavily with plugins, templates and hundreds of options!
<table>
<tr>
<th colspan="2" align="center">
@@ -222,6 +229,9 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.posts.svg">
<details><summary>With posts descriptions and cover images version</summary>
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.posts.full.svg">
</details>
<img width="900" height="1" alt="">
</td>
<td align="center">
@@ -236,6 +246,9 @@ Generate your metrics that you can embed everywhere, including your GitHub profi
<tr>
<td align="center">
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.tweets.svg">
<details><summary>With tweets attachments version</summary>
<img alt="" width="400" src="https://github.com/lowlighter/lowlighter/blob/master/metrics.plugin.tweets.attachments.svg">
</details>
<img width="900" height="1" alt="">
</td>
<td align="center">
@@ -319,7 +332,7 @@ Assuming your username is `my-github-user`, you can then embed rendered metrics
```
<details>
<summary>💬 How to setup?</summary>
<summary><b>💬 How to setup?</b> <i>(click to expand)</i></summary>
### 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.
<details>
<summary>💬 Fair use</summary>
<summary><b>💬 Fair use</b> <i>(click to expand)</i></summary>
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
```
<details>
<summary>💬 How to setup?</summary>
<summary><b>💬 How to setup?</b> <i>(click to expand)</i></summary>
### 0. Prepare your server
@@ -750,7 +763,7 @@ While metrics targets mainly user accounts, it's possible to render metrics for
![Metrics (organization account)](https://github.com/lowlighter/lowlighter/blob/master/metrics.organization.svg)
<details>
<summary>💬 Metrics for organizations</summary>
<summary><b>💬 Metrics for organizations</b> <i>(click to expand)</i></summary>
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.
</details>
<details>
<summary>💬 Organizations memberships for user accounts</summary>
<summary><b>💬 Organizations memberships for user accounts</b> <i>(click to expand)</i></summary>
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
![License details](https://github.com/lowlighter/lowlighter/blob/master/metrics.licenses.svg)
![Sponsors](https://github.com/lowlighter/lowlighter/blob/master/metrics.sponsors.svg)
## 📖 Useful references
* [GitHub GraphQL API](https://docs.github.com/en/graphql)

View File

@@ -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
```

View File

@@ -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}
}

View File

@@ -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

View File

@@ -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: