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["&"] ? "&" : "&")
|
.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 */
|
/**Chartist */
|
||||||
export async function 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>`
|
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
|
//Load inputs
|
||||||
let {limit, ignored, only, "limit.repositories":_limit, "shuffle.repositories":_shuffle} = imports.metadata.plugins.starlists.inputs({data, account, q})
|
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
|
//Start puppeteer and navigate to star lists
|
||||||
console.debug(`metrics/compute/${login}/plugins > starlists > starting browser`)
|
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
|
const count = lists.length
|
||||||
console.debug(`metrics/compute/${login}/plugins > starlists > found [${lists.map(({name}) => name)}]`)
|
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
|
lists = lists
|
||||||
.filter(({name}) => name)
|
.filter(({name}) => {
|
||||||
.filter(({name}) => (!only.length) || (only.includes(name.toLocaleLowerCase())))
|
name = imports.stripemojis(name ?? "").trim().toLocaleLowerCase()
|
||||||
.filter(({name}) => !ignored.includes(name.toLocaleLowerCase()))
|
if (only.length)
|
||||||
|
return only.includes(name)
|
||||||
|
return !ignored.includes(name)
|
||||||
|
})
|
||||||
.slice(0, limit)
|
.slice(0, limit)
|
||||||
console.debug(`metrics/compute/${login}/plugins > starlists > extracted ${lists.length} lists`)
|
console.debug(`metrics/compute/${login}/plugins > starlists > extracted ${lists.length} lists`)
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ inputs:
|
|||||||
default: yes
|
default: yes
|
||||||
|
|
||||||
plugin_starlists_ignored:
|
plugin_starlists_ignored:
|
||||||
description: Skipped star lists (case insensitive)
|
description: Skipped star lists (case insensitive, emojis insensitive)
|
||||||
type: array
|
type: array
|
||||||
format: comma-separated
|
format: comma-separated
|
||||||
default: ""
|
default: ""
|
||||||
@@ -42,7 +42,7 @@ inputs:
|
|||||||
|
|
||||||
plugin_starlists_only:
|
plugin_starlists_only:
|
||||||
description: |
|
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
|
This option is equivalent to `plugin_starlists_ignored` with all star lists but the ones listed in this option
|
||||||
type: array
|
type: array
|
||||||
|
|||||||
Reference in New Issue
Block a user