From 94d64ee2c9846c0cfb771d63effb95ffed9f40ae Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Sat, 10 Sep 2022 00:31:04 +0800 Subject: [PATCH 1/6] fix: directly stop the loop if a star list has only one page --- source/plugins/starlists/index.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/plugins/starlists/index.mjs b/source/plugins/starlists/index.mjs index 6ba8a5187ba..45b5b14eb03 100644 --- a/source/plugins/starlists/index.mjs +++ b/source/plugins/starlists/index.mjs @@ -63,7 +63,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal })) ), ) - if (await page.evaluate(() => document.querySelector(".next_page.disabled"))) { + if (!(await page.evaluate(() => document.querySelector(".next_page"))) || await page.evaluate(() => document.querySelector(".next_page.disabled"))) { console.debug(`metrics/compute/${login}/plugins > starlists > reached last page`) break } From d1721d5b1f5141631b847dc5fb9b95fa9d4ed2b6 Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Sat, 10 Sep 2022 01:40:48 +0800 Subject: [PATCH 2/6] feat(plugins/starlists): add ignored and aliases for starlists.languages --- source/plugins/starlists/README.md | 20 ++++++++++++++++++++ source/plugins/starlists/index.mjs | 15 ++++++++++----- source/plugins/starlists/metadata.yml | 15 +++++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/source/plugins/starlists/README.md b/source/plugins/starlists/README.md index a96f05ec4ee..f7993b5609d 100644 --- a/source/plugins/starlists/README.md +++ b/source/plugins/starlists/README.md @@ -96,6 +96,26 @@ All product and company names are trademarks™ or registered® trademarks of th
zero behaviour: disable
default: 8
+ + +

plugin_starlists_languages_ignored

+

Ignored languages in star lists

+ + + + type: array +(comma-separated) +
+ + +

plugin_starlists_languages_aliases

+

Custom languages names in star lists

+

Example: javascript:JS, typescript:TS

+ + + + type: string +

plugin_starlists_shuffle_repositories

diff --git a/source/plugins/starlists/index.mjs b/source/plugins/starlists/index.mjs index 45b5b14eb03..5c3a76ff2c4 100644 --- a/source/plugins/starlists/index.mjs +++ b/source/plugins/starlists/index.mjs @@ -7,9 +7,10 @@ export default async function({login, q, imports, data, account}, {enabled = fal return null //Load inputs - let {limit, ignored, only, "limit.repositories": _limit, languages, "limit.languages": _limit_languages, "shuffle.repositories": _shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q}) + let {limit, ignored, only, "limit.repositories": _limit, languages, "limit.languages": _limit_languages, "languages.ignored": _languages_ignored, "languages.aliases": _languages_aliases, "shuffle.repositories": _shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q}) ignored = ignored.map(imports.stripemojis) only = only.map(imports.stripemojis) + _languages_aliases = Object.fromEntries(_languages_aliases.split(",").filter(alias => /^[\s\S]+:[\s\S]+$/.test(alias)).map(alias => alias.trim().split(":")).map(([key, value]) => [key.toLocaleLowerCase(), value])) //Start puppeteer and navigate to star lists console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`) @@ -76,12 +77,16 @@ export default async function({login, q, imports, data, account}, {enabled = fal if (languages) { list.languages = {} for (const {language: {name, color}} of repositories) { - if (name) - list.languages[name] = (list.languages[name] ?? 0) + 1 + let lang = name; + if (lang && lang.toLocaleLowerCase() in _languages_aliases) { + lang = _languages_aliases[name.toLocaleLowerCase()]; + } + if (lang) + list.languages[lang] = (list.languages[lang] ?? 0) + 1 if (color) - colors[name] = color + colors[lang] = color } - list.languages = Object.entries(list.languages).sort((a, b) => b[1] - a[1]).slice(0, _limit_languages || Infinity) + list.languages = Object.entries(list.languages).filter(([name]) => !_languages_ignored.includes(name.toLocaleLowerCase())).sort((a, b) => b[1] - a[1]).slice(0, _limit_languages || Infinity) const visible = list.languages.map(([_, value]) => value).reduce((a, b) => a + b, 0) list.languages = list.languages.map(([name, value]) => ({name, value, color: name in colors ? `#${colors[name]}` : null, x: 0, p: value / visible})) for (let i = 1; i < list.languages.length; i++) diff --git a/source/plugins/starlists/metadata.yml b/source/plugins/starlists/metadata.yml index 87267654a3c..6be701a20ef 100644 --- a/source/plugins/starlists/metadata.yml +++ b/source/plugins/starlists/metadata.yml @@ -48,6 +48,21 @@ inputs: default: 8 min: 0 zero: disable + + plugin_starlists_languages_ignored: + description: | + Ignored languages in star lists + type: array + format: comma-separated + default: "" + example: html, css, ... + + plugin_starlists_languages_aliases: + description: | + Custom languages names in star lists + type: string + default: "" + example: javascript:JS, typescript:TS plugin_starlists_shuffle_repositories: description: | From 1e34663a82325779183cf088dfa689a2137b800d Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Sat, 10 Sep 2022 01:41:36 +0800 Subject: [PATCH 3/6] docs(plugins/languages): fix wrong example and add example in README --- source/plugins/languages/README.md | 1 + source/plugins/languages/metadata.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/plugins/languages/README.md b/source/plugins/languages/README.md index 34cf9c6096c..dbfcc569f14 100644 --- a/source/plugins/languages/README.md +++ b/source/plugins/languages/README.md @@ -117,6 +117,7 @@ It will be automatically hidden if empty.

plugin_languages_aliases

Custom languages names

+

Example: javascript:JS, typescript:TS

diff --git a/source/plugins/languages/metadata.yml b/source/plugins/languages/metadata.yml index f730f87351d..4c09f1bdd32 100644 --- a/source/plugins/languages/metadata.yml +++ b/source/plugins/languages/metadata.yml @@ -76,7 +76,7 @@ inputs: Custom languages names type: string default: "" - example: javascript:JS typescript:TS + example: javascript:JS, typescript:TS plugin_languages_sections: description: | From 92b481bb2be292b376edd20767beb7ed17e9346b Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Sat, 10 Sep 2022 02:10:32 +0800 Subject: [PATCH 4/6] fix(docs): remove extra semicolon --- source/plugins/starlists/index.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/plugins/starlists/index.mjs b/source/plugins/starlists/index.mjs index 5c3a76ff2c4..e1384135da1 100644 --- a/source/plugins/starlists/index.mjs +++ b/source/plugins/starlists/index.mjs @@ -77,9 +77,9 @@ export default async function({login, q, imports, data, account}, {enabled = fal if (languages) { list.languages = {} for (const {language: {name, color}} of repositories) { - let lang = name; + let lang = name if (lang && lang.toLocaleLowerCase() in _languages_aliases) { - lang = _languages_aliases[name.toLocaleLowerCase()]; + lang = _languages_aliases[name.toLocaleLowerCase()] } if (lang) list.languages[lang] = (list.languages[lang] ?? 0) + 1 From 3a4b139ae3f3eebe563c0664cb784358ac2bc2ad Mon Sep 17 00:00:00 2001 From: TonyCrane Date: Sat, 10 Sep 2022 02:46:22 +0800 Subject: [PATCH 5/6] feat(plugins/starlists): add ignored and aliases for starlists.languages in action.yml --- action.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/action.yml b/action.yml index 54265f21715..e1d6da1e039 100644 --- a/action.yml +++ b/action.yml @@ -710,6 +710,14 @@ inputs: description: Display limit (languages per star list) default: + plugin_starlists_languages_ignored: + description: Ignored languages in star lists + default: + + plugin_starlists_languages_aliases: + description: Custom languages names in star lists + default: + plugin_starlists_shuffle_repositories: description: Shuffle data default: From 3acc446bac3beb6d050d57ba501dc1fac28d27c7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 9 Sep 2022 18:49:31 +0000 Subject: [PATCH 6/6] ci: auto-regenerate files --- README.md | 2 +- source/plugins/base/README.md | 3 +-- source/plugins/community/chess/README.md | 11 +++-------- source/plugins/habits/README.md | 1 - source/plugins/languages/README.md | 1 - source/plugins/leetcode/README.md | 13 ++++--------- source/plugins/notable/README.md | 3 +-- source/plugins/repositories/README.md | 3 +-- source/plugins/starlists/README.md | 7 ++++--- 9 files changed, 15 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index a2136ba204e..c1a679992e2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Generate metrics that can be embedded everywhere, including your GitHub profile -

🧩 Customizable with 42 plugins and 296 options!

+

🧩 Customizable with 42 plugins and 298 options!

diff --git a/source/plugins/base/README.md b/source/plugins/base/README.md index 2151e43937c..7ffed649937 100644 --- a/source/plugins/base/README.md +++ b/source/plugins/base/README.md @@ -97,8 +97,7 @@ Only use this option when using a plugin that can be configured with token - ✨ On master/main
-type: boolean + type: boolean
default: no
diff --git a/source/plugins/community/chess/README.md b/source/plugins/community/chess/README.md index 0bbdf2ebe5f..c9a7ef97f7e 100644 --- a/source/plugins/community/chess/README.md +++ b/source/plugins/community/chess/README.md @@ -40,8 +40,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
-type: boolean + type: boolean
default: no
@@ -52,7 +51,6 @@ All product and company names are trademarks™ or registered® trademarks of th 🔐 Token
-✨ On master/main
🌐 Web instances must configure settings.json:
  • metrics.api.chess.any
  • @@ -67,7 +65,6 @@ All product and company names are trademarks™ or registered® trademarks of th ⏯️ Cannot be preset
    -✨ On master/main
    type: string
    default: → User login
    @@ -78,8 +75,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: string + type: string
    allowed values:
    • lichess.org
    @@ -94,8 +90,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: json + type: json
    default:
    → Click to expand
    {
       "size": 40,
    diff --git a/source/plugins/habits/README.md b/source/plugins/habits/README.md
    index bdad4cf8404..d77c0b76613 100644
    --- a/source/plugins/habits/README.md
    +++ b/source/plugins/habits/README.md
    @@ -65,7 +65,6 @@ All product and company names are trademarks™ or registered® trademarks of th
       
       
         ⏩ Inherits repositories_skipped
    -✨ On master/main
    type: array (comma-separated)
    diff --git a/source/plugins/languages/README.md b/source/plugins/languages/README.md index dbfcc569f14..34cf9c6096c 100644 --- a/source/plugins/languages/README.md +++ b/source/plugins/languages/README.md @@ -117,7 +117,6 @@ It will be automatically hidden if empty.

    plugin_languages_aliases

    Custom languages names

    -

    Example: javascript:JS, typescript:TS

    diff --git a/source/plugins/leetcode/README.md b/source/plugins/leetcode/README.md index d0b04870760..9f235697af6 100644 --- a/source/plugins/leetcode/README.md +++ b/source/plugins/leetcode/README.md @@ -39,8 +39,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: boolean + type: boolean
    default: no
    @@ -51,7 +50,6 @@ All product and company names are trademarks™ or registered® trademarks of th ⏯️ Cannot be preset
    -✨ On master/main
    type: string
    default: → User login
    @@ -67,8 +65,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: array + type: array (comma-separated)
    default: solved
    @@ -80,8 +77,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: number + type: number (0 ≤ 𝑥)
    @@ -94,8 +90,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: number + type: number (1 ≤ 𝑥 ≤ 15) diff --git a/source/plugins/notable/README.md b/source/plugins/notable/README.md index ae53ed8e3a9..4dd462ab8c5 100644 --- a/source/plugins/notable/README.md +++ b/source/plugins/notable/README.md @@ -133,8 +133,7 @@ Some repositories may not be able to reported advanced stats and in the case the - ✨ On master/main
    -type: boolean + type: boolean
    default: no
    diff --git a/source/plugins/repositories/README.md b/source/plugins/repositories/README.md index c1da0f6de54..935dd7c0052 100644 --- a/source/plugins/repositories/README.md +++ b/source/plugins/repositories/README.md @@ -117,8 +117,7 @@ All product and company names are trademarks™ or registered® trademarks of th - ✨ On master/main
    -type: boolean + type: boolean
    default: no
    diff --git a/source/plugins/starlists/README.md b/source/plugins/starlists/README.md index f7993b5609d..e90dfed8d97 100644 --- a/source/plugins/starlists/README.md +++ b/source/plugins/starlists/README.md @@ -103,18 +103,19 @@ All product and company names are trademarks™ or registered® trademarks of th - type: array + ✨ On master/main
    +type: array (comma-separated)

    plugin_starlists_languages_aliases

    Custom languages names in star lists

    -

    Example: javascript:JS, typescript:TS

    - type: string + ✨ On master/main
    +type: string