Skip to content

Commit 98bbeb4

Browse files
authoredSep 14, 2022
feat(plugins/starlists): add ignored and aliases for starlists.languages and some fix (#1224)
1 parent 6583ac7 commit 98bbeb4

File tree

12 files changed

+67
-32
lines changed

12 files changed

+67
-32
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Generate metrics that can be embedded everywhere, including your GitHub profile
1919
</tr>
2020
<tr>
2121
<th colspan="2" align="center">
22-
<h3><a href="/README.md#-plugins">🧩 Customizable with 42 plugins and 296 options!</a></h3>
22+
<h3><a href="/README.md#-plugins">🧩 Customizable with 42 plugins and 298 options!</a></h3>
2323
</th>
2424
</tr>
2525
<tr>

‎action.yml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎source/plugins/base/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ Only use this option when using a plugin that can be configured with <code>token
9797
<img width="900" height="1" alt=""></td>
9898
</tr>
9999
<tr>
100-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
101-
<b>type:</b> <code>boolean</code>
100+
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
102101
<br>
103102
<b>default:</b> no<br></td>
104103
</tr>

‎source/plugins/community/chess/README.md

+3-8
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ All product and company names are trademarks™ or registered® trademarks of th
4040
<img width="900" height="1" alt=""></td>
4141
</tr>
4242
<tr>
43-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
44-
<b>type:</b> <code>boolean</code>
43+
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
4544
<br>
4645
<b>default:</b> no<br></td>
4746
</tr>
@@ -52,7 +51,6 @@ All product and company names are trademarks™ or registered® trademarks of th
5251
</tr>
5352
<tr>
5453
<td nowrap="nowrap">🔐 Token<br>
55-
✨ On <code>master</code>/<code>main</code><br>
5654
🌐 Web instances must configure <code>settings.json</code>:
5755
<ul>
5856
<li><i>metrics.api.chess.any</i></li>
@@ -67,7 +65,6 @@ All product and company names are trademarks™ or registered® trademarks of th
6765
</tr>
6866
<tr>
6967
<td nowrap="nowrap">⏯️ Cannot be preset<br>
70-
✨ On <code>master</code>/<code>main</code><br>
7168
<b>type:</b> <code>string</code>
7269
<br>
7370
<b>default:</b> <code>→ User login</code><br></td>
@@ -78,8 +75,7 @@ All product and company names are trademarks™ or registered® trademarks of th
7875
<img width="900" height="1" alt=""></td>
7976
</tr>
8077
<tr>
81-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
82-
<b>type:</b> <code>string</code>
78+
<td nowrap="nowrap"><b>type:</b> <code>string</code>
8379
<br>
8480
<b>allowed values:</b><ul><li>lichess.org</li></ul></td>
8581
</tr>
@@ -94,8 +90,7 @@ All product and company names are trademarks™ or registered® trademarks of th
9490
<img width="900" height="1" alt=""></td>
9591
</tr>
9692
<tr>
97-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
98-
<b>type:</b> <code>json</code>
93+
<td nowrap="nowrap"><b>type:</b> <code>json</code>
9994
<br>
10095
<b>default:</b> <details><summary>→ Click to expand</summary><pre language="json"><code>{
10196
"size": 40,

‎source/plugins/habits/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ All product and company names are trademarks™ or registered® trademarks of th
6565
</tr>
6666
<tr>
6767
<td nowrap="nowrap">⏩ Inherits <code>repositories_skipped</code><br>
68-
✨ On <code>master</code>/<code>main</code><br>
6968
<b>type:</b> <code>array</code>
7069
<i>(comma-separated)</i>
7170
<br></td>

‎source/plugins/languages/metadata.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ inputs:
7676
Custom languages names
7777
type: string
7878
default: ""
79-
example: javascript:JS typescript:TS
79+
example: javascript:JS, typescript:TS
8080

8181
plugin_languages_sections:
8282
description: |

‎source/plugins/leetcode/README.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ All product and company names are trademarks™ or registered® trademarks of th
3939
<img width="900" height="1" alt=""></td>
4040
</tr>
4141
<tr>
42-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
43-
<b>type:</b> <code>boolean</code>
42+
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
4443
<br>
4544
<b>default:</b> no<br></td>
4645
</tr>
@@ -51,7 +50,6 @@ All product and company names are trademarks™ or registered® trademarks of th
5150
</tr>
5251
<tr>
5352
<td nowrap="nowrap">⏯️ Cannot be preset<br>
54-
✨ On <code>master</code>/<code>main</code><br>
5553
<b>type:</b> <code>string</code>
5654
<br>
5755
<b>default:</b> <code>→ User login</code><br></td>
@@ -67,8 +65,7 @@ All product and company names are trademarks™ or registered® trademarks of th
6765
<img width="900" height="1" alt=""></td>
6866
</tr>
6967
<tr>
70-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
71-
<b>type:</b> <code>array</code>
68+
<td nowrap="nowrap"><b>type:</b> <code>array</code>
7269
<i>(comma-separated)</i>
7370
<br>
7471
<b>default:</b> solved<br>
@@ -80,8 +77,7 @@ All product and company names are trademarks™ or registered® trademarks of th
8077
<img width="900" height="1" alt=""></td>
8178
</tr>
8279
<tr>
83-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
84-
<b>type:</b> <code>number</code>
80+
<td nowrap="nowrap"><b>type:</b> <code>number</code>
8581
<i>(0 ≤
8682
𝑥)</i>
8783
<br>
@@ -94,8 +90,7 @@ All product and company names are trademarks™ or registered® trademarks of th
9490
<img width="900" height="1" alt=""></td>
9591
</tr>
9692
<tr>
97-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
98-
<b>type:</b> <code>number</code>
93+
<td nowrap="nowrap"><b>type:</b> <code>number</code>
9994
<i>(1 ≤
10095
𝑥
10196
≤ 15)</i>

‎source/plugins/notable/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ Some repositories may not be able to reported advanced stats and in the case the
133133
<img width="900" height="1" alt=""></td>
134134
</tr>
135135
<tr>
136-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
137-
<b>type:</b> <code>boolean</code>
136+
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
138137
<br>
139138
<b>default:</b> no<br></td>
140139
</tr>

‎source/plugins/repositories/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ All product and company names are trademarks™ or registered® trademarks of th
117117
<img width="900" height="1" alt=""></td>
118118
</tr>
119119
<tr>
120-
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
121-
<b>type:</b> <code>boolean</code>
120+
<td nowrap="nowrap"><b>type:</b> <code>boolean</code>
122121
<br>
123122
<b>default:</b> no<br></td>
124123
</tr>

‎source/plugins/starlists/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,27 @@ All product and company names are trademarks™ or registered® trademarks of th
9696
<br>
9797
<b>zero behaviour:</b> disable</br>
9898
<b>default:</b> 8<br></td>
99+
</tr>
100+
<tr>
101+
<td nowrap="nowrap"><h4><code>plugin_starlists_languages_ignored</code></h4></td>
102+
<td rowspan="2"><p>Ignored languages in star lists</p>
103+
<img width="900" height="1" alt=""></td>
104+
</tr>
105+
<tr>
106+
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
107+
<b>type:</b> <code>array</code>
108+
<i>(comma-separated)</i>
109+
<br></td>
110+
</tr>
111+
<tr>
112+
<td nowrap="nowrap"><h4><code>plugin_starlists_languages_aliases</code></h4></td>
113+
<td rowspan="2"><p>Custom languages names in star lists</p>
114+
<img width="900" height="1" alt=""></td>
115+
</tr>
116+
<tr>
117+
<td nowrap="nowrap">✨ On <code>master</code>/<code>main</code><br>
118+
<b>type:</b> <code>string</code>
119+
<br></td>
99120
</tr>
100121
<tr>
101122
<td nowrap="nowrap"><h4><code>plugin_starlists_shuffle_repositories</code></h4></td>

‎source/plugins/starlists/index.mjs

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ export default async function({login, q, imports, data, account}, {enabled = fal
77
return null
88

99
//Load inputs
10-
let {limit, ignored, only, "limit.repositories": _limit, languages, "limit.languages": _limit_languages, "shuffle.repositories": _shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q})
10+
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})
1111
ignored = ignored.map(imports.stripemojis)
1212
only = only.map(imports.stripemojis)
13+
_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]))
1314

1415
//Start puppeteer and navigate to star lists
1516
console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`)
@@ -63,7 +64,7 @@ export default async function({login, q, imports, data, account}, {enabled = fal
6364
}))
6465
),
6566
)
66-
if (await page.evaluate(() => document.querySelector(".next_page.disabled"))) {
67+
if (!(await page.evaluate(() => document.querySelector(".next_page"))) || await page.evaluate(() => document.querySelector(".next_page.disabled"))) {
6768
console.debug(`metrics/compute/${login}/plugins > starlists > reached last page`)
6869
break
6970
}
@@ -76,12 +77,16 @@ export default async function({login, q, imports, data, account}, {enabled = fal
7677
if (languages) {
7778
list.languages = {}
7879
for (const {language: {name, color}} of repositories) {
79-
if (name)
80-
list.languages[name] = (list.languages[name] ?? 0) + 1
80+
let lang = name
81+
if (lang && lang.toLocaleLowerCase() in _languages_aliases) {
82+
lang = _languages_aliases[name.toLocaleLowerCase()]
83+
}
84+
if (lang)
85+
list.languages[lang] = (list.languages[lang] ?? 0) + 1
8186
if (color)
82-
colors[name] = color
87+
colors[lang] = color
8388
}
84-
list.languages = Object.entries(list.languages).sort((a, b) => b[1] - a[1]).slice(0, _limit_languages || Infinity)
89+
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)
8590
const visible = list.languages.map(([_, value]) => value).reduce((a, b) => a + b, 0)
8691
list.languages = list.languages.map(([name, value]) => ({name, value, color: name in colors ? `#${colors[name]}` : null, x: 0, p: value / visible}))
8792
for (let i = 1; i < list.languages.length; i++)

‎source/plugins/starlists/metadata.yml

+15
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ inputs:
4848
default: 8
4949
min: 0
5050
zero: disable
51+
52+
plugin_starlists_languages_ignored:
53+
description: |
54+
Ignored languages in star lists
55+
type: array
56+
format: comma-separated
57+
default: ""
58+
example: html, css, ...
59+
60+
plugin_starlists_languages_aliases:
61+
description: |
62+
Custom languages names in star lists
63+
type: string
64+
default: ""
65+
example: javascript:JS, typescript:TS
5166

5267
plugin_starlists_shuffle_repositories:
5368
description: |

0 commit comments

Comments
 (0)
Failed to load comments.