From 758ebfd9cf634089635b1bdb10ba618286a64745 Mon Sep 17 00:00:00 2001 From: linguist <22963968+lowlighter@users.noreply.github.com> Date: Sun, 3 Jan 2021 18:34:26 +0100 Subject: [PATCH] Add support for stars plugin in placeholder --- source/app/metrics.mjs | 1 + source/app/web/instance.mjs | 13 +++++++++---- source/app/web/statics/style.css | 8 ++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/source/app/metrics.mjs b/source/app/metrics.mjs index c2648bdd..b3fd7c74 100644 --- a/source/app/metrics.mjs +++ b/source/app/metrics.mjs @@ -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]??{})] )), }) diff --git a/source/app/web/instance.mjs b/source/app/web/instance.mjs index c39e0f62..359b39c5 100644 --- a/source/app/web/instance.mjs +++ b/source/app/web/instance.mjs @@ -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 diff --git a/source/app/web/statics/style.css b/source/app/web/statics/style.css index 987a691c..8d459b52 100644 --- a/source/app/web/statics/style.css +++ b/source/app/web/statics/style.css @@ -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; }