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

@@ -269,6 +269,7 @@
topics:{mode:"topics.mode" in q ? q["topics.mode"] : "starred", list:[...new Array("topics.limit" in q ? Math.max(Number(q["topics.limit"])||0, 0) : 12).fill(null).map(() => ({name:"######", description:"", icon:null})), {name:`And ## more...`, description:"", icon:null}]},
projects:{list:[...new Array("projects.limit" in q ? Math.max(Number(q["projects.limit"])||0, 0) : 4).fill(null).map(() => ({name:"########", updated:"########", progress:{enabled:true, todo:"##", doing:"##", done:"##", total:"##"}}))]},
tweets:{profile:{username:"########", verified:false}, list:[...new Array("tweets.limit" in q ? Math.max(Number(q["tweets.limit"])||0, 0) : 2).fill(null).map(() => ({text:"###### ###### ####### ######".repeat(4), created_at:Date.now()}))]},
stars:{repositories:[...new Array("stars.limit" in q ? Math.max(Number(q["stars.limit"])||0, 0) : 4).fill({node:{nameWithOwner:"########/########", description:"###### ###### ####### ######".repeat(4)}})]},
}[key]??{})]
)),
})

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

View File

@@ -35,9 +35,10 @@
nav {
display: flex;
border-bottom: 1px solid var(--color-border-secondary);
margin: 32px 0 24px;
overflow: auto;
}
nav .tab {
flex-shrink: 0;
display: flex;
align-items: center;
padding: 8px 16px;
@@ -274,7 +275,7 @@
}
/* Media screen */
@media only screen and (min-width: 700px) {
@media only screen and (min-width: 860px) {
.left {
width: 25%;
margin: 0 8px;
@@ -282,6 +283,9 @@
.right {
width: 0%;
}
nav {
margin: 32px 0 24px;
}
nav .left {
display: block;
}