Skip to content

Commit 52ca4d0

Browse files
committed
docs(plugins): clarification, fix typos and style
1 parent 3c00e64 commit 52ca4d0

File tree

47 files changed

+733
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+733
-408
lines changed

.github/readme/partials/documentation/setup/web.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ Configuration file also contains settings about enabled templates, plugins and f
8484
}
8585
```
8686

87-
> ⚠️ Extras features **should not** be enabled on a public server, most of these are compute-intensive and some of some even allow remote code execution! Use with caution
87+
> ⚠️ Extras features **should not** be enabled on a public server, most of these are either compute, network or API intensive tasks. Some extras features even allow remote code execution which could compromise server security.
88+
>
89+
> Use at your own risk, *metrics* and its authors cannot be held responsible for any damage caused.
8890
8991
## 3️ Start docker container
9092

.github/scripts/quickstart/plugin/metadata.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: "🧩 <%= `${name.charAt(0).toLocaleUpperCase()}${name.substring(1)}` %>"
1+
name: 🧩 <%= `${name.charAt(0).toLocaleUpperCase()}${name.substring(1)}` %>
22
category: community
3-
description: Short description
3+
description: |
4+
Short description
45
examples:
56
default: https://via.placeholder.com/468x60?text=No%20preview%20available
67
authors:
@@ -13,6 +14,7 @@ scopes: []
1314
inputs:
1415

1516
plugin_<%= name %>:
16-
description: Enable <%= name %> plugin
17+
description: |
18+
Enable <%= name %> plugin
1719
type: boolean
1820
default: no

.github/scripts/quickstart/template/metadata.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: "🖼️ Template name"
1+
name: 🖼️ Template name
22
extends: classic
3-
description: Short description
3+
description: |
4+
Short description
45
examples:
56
default: https://via.placeholder.com/468x60?text=No%20preview%20available
67
authors:

source/app/metrics/metadata.mjs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,38 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
212212
Object.assign(meta.inputs, inputs, Object.fromEntries(Object.entries(inputs).map(([key, value]) => [metadata.to.query(key, {name}), value])))
213213
}
214214

215+
//Extra features parser
216+
{
217+
meta.extras = function(input, {extras = {}}) {
218+
//Required permissions
219+
const required = inputs[metadata.to.yaml(input, {name})]?.extras ?? null
220+
if (!required)
221+
return true
222+
console.debug(`metrics/extras > ${name} > ${input} > require [${required}]`)
223+
224+
//Legacy handling
225+
const enabled = extras?.features ?? extras?.default ?? false
226+
if (typeof enabled === "boolean") {
227+
console.debug(`metrics/extras > ${name} > ${input} > extras features is set to ${enabled}`)
228+
return enabled
229+
}
230+
if (!Array.isArray(required)) {
231+
console.debug(`metrics/extras > ${name} > ${input} > extras is not a permission array, skipping`)
232+
return false
233+
}
234+
235+
//Check permissions
236+
if (!Array.isArray(extras.features))
237+
throw new Error(`metrics/extras > ${name} > ${input} > extras.features is not an array`)
238+
const missing = required.filter(permission => !extras.features.includes(permission))
239+
if (missing.length > 0) {
240+
console.debug(`metrics/extras > ${name} > ${input} > missing permissions [${missing}], skipping`)
241+
return false
242+
}
243+
return true
244+
}
245+
}
246+
215247
//Action metadata
216248
{
217249
//Extract comments
@@ -538,6 +570,12 @@ metadata.to = {
538570
key = key.replace(/^plugin_/, "").replace(/_/g, ".")
539571
return name ? key.replace(new RegExp(`^(${name}.)`, "g"), "") : key
540572
},
573+
yaml(key, {name = ""} = {}) {
574+
const parts = [key.replaceAll(".", "_")]
575+
if (name)
576+
parts.unshift((name === "base") ? name : `plugin_${name}`)
577+
return parts.join("_")
578+
}
541579
}
542580

543581
//Demo for main and individual readmes

source/plugins/achievements/metadata.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: "🏆 Achievements"
1+
name: 🏆 Achievements
22
category: github
3-
description: This plugin displays several highlights about what you achieved on GitHub.
3+
description: |
4+
This plugin displays several highlights about what an account has achieved on GitHub.
45
examples:
56
+compact display: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.achievements.compact.svg
67
detailed display: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.achievements.svg
@@ -13,13 +14,14 @@ scopes:
1314
inputs:
1415

1516
plugin_achievements:
16-
description: Enable achievements plugin
17+
description: |
18+
Enable achievements plugin
1719
type: boolean
1820
default: no
1921

2022
plugin_achievements_threshold:
2123
description: |
22-
Display rank threshold
24+
Rank threshold filter
2325
2426
Use `X` to display achievements not yet unlocked
2527
type: string
@@ -32,13 +34,15 @@ inputs:
3234
- X
3335

3436
plugin_achievements_secrets:
35-
description: Display secrets achievements
37+
description: |
38+
Secrets achievements
3639
type: boolean
3740
default: yes
3841

3942
plugin_achievements_display:
4043
description: |
4144
Display style
45+
4246
- `detailed`: display icon, name, description and ranking
4347
- `compact`: display icon, name and value
4448
type: string
@@ -48,28 +52,30 @@ inputs:
4852
- compact
4953

5054
plugin_achievements_limit:
51-
description: Display limit
55+
description: |
56+
Display limit
5257
type: number
5358
default: 0
5459
min: 0
60+
zero: disable
5561

5662
plugin_achievements_ignored:
5763
description: |
58-
Hide specified achievements
64+
Ignored achievements
5965
60-
Use names without the rank adjective (i.e. without "great", "super" or "master")
66+
Use achievements names without their rank adjective (i.e. without "great", "super" or "master")
6167
type: array
6268
format: comma-separated
6369
default: ""
6470
example: octonaut, automator, explorer
6571

6672
plugin_achievements_only:
6773
description: |
68-
Restrict display to specified achievements
74+
Showcased achievements
6975
70-
Use names without the rank adjective (i.e. without "great", "super" or "master")
76+
Use achievements names without their rank adjective (i.e. without "great", "super" or "master")
7177
72-
This option is equivalent to `plugin_achievements_ignored` with all existing achievements but the ones listed in this option
78+
This option is equivalent to [`plugin_achievements_ignored`](/source/plugins/achievements/README.md#plugin_achievements_ignored) with all existing achievements except the ones listed in this option
7379
type: array
7480
format: comma-separated
7581
default: ""

source/plugins/activity/metadata.yml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: "📰 Recent activity"
1+
name: 📰 Recent activity
22
category: github
3-
description: This plugin displays your recent activity on GitHub.
3+
description: |
4+
This plugin displays recent activity on GitHub.
45
examples:
56
default: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.activity.svg
67
index: 13
@@ -13,26 +14,30 @@ scopes:
1314
inputs:
1415

1516
plugin_activity:
16-
description: Enable activity plugin
17+
description: |
18+
Enable activity plugin
1719
type: boolean
1820
default: no
1921

2022
plugin_activity_limit:
21-
description: Display limit
23+
description: |
24+
Display limit
2225
type: number
2326
default: 5
2427
min: 1
2528
max: 1000
2629

2730
plugin_activity_load:
28-
description: Events to load
31+
description: |
32+
Events to load
2933
type: number
3034
default: 300
3135
min: 100
3236
max: 1000
3337

3438
plugin_activity_days:
35-
description: Events maximum age
39+
description: |
40+
Events maximum age
3641
type: number
3742
default: 14
3843
min: 0
@@ -43,20 +48,22 @@ inputs:
4348
description: |
4449
Events visibility
4550
46-
Lets you hide private activity when using a `repo` scope token
51+
Can be used to toggle private activity visibility when using a token with `repo` scope
4752
type: string
4853
default: all
4954
values:
5055
- public
5156
- all
5257

5358
plugin_activity_timestamps:
54-
description: Display events timestamps
59+
description: |
60+
Events timestamps
5561
type: boolean
5662
default: no
5763

5864
plugin_activity_skipped:
59-
description: Skipped repositories
65+
description: |
66+
Skipped repositories
6067
type: array
6168
format: comma-separated
6269
default: ""
@@ -67,7 +74,7 @@ inputs:
6774
description: |
6875
Ignored users
6976
70-
Useful to ignore bots activity
77+
Can be used to ignore bots activity
7178
type: array
7279
format: comma-separated
7380
default: ""

source/plugins/anilist/metadata.yml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
name: "🌸 Anilist watch list and reading list"
1+
name: 🌸 Anilist watch list and reading list
22
category: social
3-
description: This plugin displays your favorites animes, mangas and characters from your [AniList](https://anilist.co) account.
3+
description: |
4+
This plugin displays favorites animes, mangas and characters from a [AniList](https://anilist.co) account.
45
examples:
56
+for anime watchers: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.anilist.svg
67
for manga readers: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.anilist.manga.svg
@@ -13,12 +14,21 @@ scopes: []
1314
inputs:
1415

1516
plugin_anilist:
16-
description: Enable aniList plugin
17+
description: |
18+
Enable aniList plugin
1719
type: boolean
1820
default: no
1921

22+
plugin_anilist_user:
23+
type: string
24+
description: |
25+
AniList login
26+
default: .user.login
27+
preset: no
28+
2029
plugin_anilist_medias:
21-
description: Display medias types
30+
description: |
31+
Medias types
2232
type: array
2333
format: comma-separated
2434
default: anime, manga
@@ -29,7 +39,8 @@ inputs:
2939
plugin_anilist_sections:
3040
description: |
3141
Displayed sections
32-
- `favorites` will display favorites `plugin_anilist_medias`
42+
43+
- `favorites` will display favorites from `plugin_anilist_medias`
3344
- `watching` will display animes currently in watching list
3445
- `reading` will display manga currently in reading list
3546
- `characters` will display liked characters
@@ -44,26 +55,25 @@ inputs:
4455
- characters
4556

4657
plugin_anilist_limit:
47-
description: Display limit (medias)
58+
description: |
59+
Display limit (medias)
4860
type: number
4961
default: 2
5062
min: 0
5163
zero: disable
5264

5365
plugin_anilist_limit_characters:
54-
description: Display limit (characters)
66+
description: |
67+
Display limit (characters)
5568
type: number
5669
default: 22
5770
min: 0
5871
zero: disable
5972

6073
plugin_anilist_shuffle:
61-
description: Shuffle data for varied outputs
74+
description: |
75+
Shuffle data
76+
77+
Can be used to create varied outputs
6278
type: boolean
6379
default: yes
64-
65-
plugin_anilist_user:
66-
type: string
67-
description: AniList login
68-
default: .user.login
69-
preset: no

0 commit comments

Comments
 (0)