fix(plugins/starlists): filtering
This commit is contained in:
@@ -158,6 +158,11 @@ export function htmlunescape(string, u = {"&":true, "<":true, ">":true, '"':true
|
||||
.replace(/&/g, u["&"] ? "&" : "&")
|
||||
}
|
||||
|
||||
/**Strip emojis from string */
|
||||
export function stripemojis(string) {
|
||||
return string.replace(/[^\p{L}\p{N}\p{P}\p{Z}^$\n]/gu, "")
|
||||
}
|
||||
|
||||
/**Chartist */
|
||||
export async function chartist() {
|
||||
const css = `<style data-optimizable="true">${await fs.readFile(paths.join(__module(import.meta.url), "../../../node_modules", "node-chartist/dist/main.css")).catch(_ => "")}</style>`
|
||||
|
||||
@@ -8,6 +8,8 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
||||
|
||||
//Load inputs
|
||||
let {limit, ignored, only, "limit.repositories":_limit, "shuffle.repositories":_shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q})
|
||||
ignored = ignored.map(imports.stripemojis)
|
||||
only = only.map(imports.stripemojis)
|
||||
|
||||
//Start puppeteer and navigate to star lists
|
||||
console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`)
|
||||
@@ -28,11 +30,13 @@ export default async function({login, q, imports, data, account}, {enabled = fal
|
||||
))
|
||||
const count = lists.length
|
||||
console.debug(`metrics/compute/${login}/plugins > starlists > found [${lists.map(({name}) => name)}]`)
|
||||
console.log(">>>> DEBUG", only, ignored, lists, lists.filter(({name}) => name).filter(({name}) => (!only.length) || (only.includes(name.toLocaleLowerCase()))))
|
||||
lists = lists
|
||||
.filter(({name}) => name)
|
||||
.filter(({name}) => (!only.length) || (only.includes(name.toLocaleLowerCase())))
|
||||
.filter(({name}) => !ignored.includes(name.toLocaleLowerCase()))
|
||||
.filter(({name}) => {
|
||||
name = imports.stripemojis(name ?? "").trim().toLocaleLowerCase()
|
||||
if (only.length)
|
||||
return only.includes(name)
|
||||
return !ignored.includes(name)
|
||||
})
|
||||
.slice(0, limit)
|
||||
console.debug(`metrics/compute/${login}/plugins > starlists > extracted ${lists.length} lists`)
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ inputs:
|
||||
default: yes
|
||||
|
||||
plugin_starlists_ignored:
|
||||
description: Skipped star lists (case insensitive)
|
||||
description: Skipped star lists (case insensitive, emojis insensitive)
|
||||
type: array
|
||||
format: comma-separated
|
||||
default: ""
|
||||
@@ -42,7 +42,7 @@ inputs:
|
||||
|
||||
plugin_starlists_only:
|
||||
description: |
|
||||
Restrict display to specified star lists (case insensitive)
|
||||
Restrict display to specified star lists (case insensitive, emojis insensitive)
|
||||
|
||||
This option is equivalent to `plugin_starlists_ignored` with all star lists but the ones listed in this option
|
||||
type: array
|
||||
|
||||
Reference in New Issue
Block a user