Add support for stars plugin in placeholder

This commit is contained in:
linguist
2021-01-03 18:34:26 +01:00
parent 2186611784
commit 758ebfd9cf
3 changed files with 16 additions and 6 deletions

View File

@@ -115,8 +115,13 @@
const placeholder = Object.entries(parse(req.query)).filter(([key, value]) =>
((key in Plugins)&&(!!value))||
((key === "template")&&(value in Templates))||
(/base[.](header|activity|community|repositories|metadata)/.test(key))
).map(([key, value]) => `${key}${key === "template" ? `#${value}` : ""}`).sort().join("+")
(/base[.](header|activity|community|repositories|metadata)/.test(key))||
(["pagespeed.detailed", "pagespeed.screenshot", "habits.charts", "habits.facts", "topics.mode"].includes(key))
).map(([key, value]) => `${key}${
key === "template" ? `#${value}` :
key === "topics.mode" ? `#${value === "mastered" ? value : "starred"}` :
!!value
}`).sort().join("+")
//Request params
const {login} = req.params
@@ -148,8 +153,8 @@
//Compute rendering
try {
//Render
console.debug(`metrics/app/${login} > ${util.inspect(req.query, {depth:Infinity, maxStringLength:256})}`)
const q = parse(req.query)
console.debug(`metrics/app/${login} > ${util.inspect(q, {depth:Infinity, maxStringLength:256})}`)
const {rendered, mime} = await metrics({login, q}, {
graphql, rest, plugins, conf,
die:q["plugins.errors.fatal"] ?? false,
@@ -204,7 +209,7 @@
query[key] = Number(value)
//Parse boolean
if (/^(?:true|false)$/.test(value))
query[key] = value === "true"
query[key] = (value === "true")||(value === true)
//Parse null
if (/^null$/.test(value))
query[key] = null