From 2f0298bc0d6175a54607018062c4a6cca4d10b26 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Fri, 28 May 2021 13:47:00 +0200 Subject: [PATCH] Fix and improve placeholder generation --- source/app/web/statics/app.placeholder.js | 61 +++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/source/app/web/statics/app.placeholder.js b/source/app/web/statics/app.placeholder.js index bc302849..28fd6e6f 100644 --- a/source/app/web/statics/app.placeholder.js +++ b/source/app/web/statics/app.placeholder.js @@ -214,7 +214,7 @@ ...(set.plugins.enabled.notable ? ({ notable: { - contributions: new Array(2 + faker.datatype.number(2)).fill(null).map(_ => ({ name: faker.lorem.slug(), avatar: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==" })), + contributions: new Array(2 + faker.datatype.number(2)).fill(null).map(_ => ({ name: `${options["notable.repositories"] ? `${faker.lorem.slug()}/` : ""}${faker.lorem.slug()}`, avatar: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==" })), }, }) : null), @@ -306,8 +306,12 @@ title: faker.lorem.word(), unlock: null, text: faker.lorem.sentence(), - icon: - ``, + get icon() { + const colors = {S:["#FF0000", "#FF8500"], A:["#B59151", "#FFD576"], B:["#7D6CFF", "#B2A8FF"], C:["#2088FF", "#79B8FF"], $:["#FF48BD", "#FF92D8"], X:["#7A7A7A", "#B0B0B0"]} + return `` + .replace(/#primary/g, colors[this.rank][0]) + .replace(/#secondary/g, colors[this.rank][1]) + }, rank: faker.random.arrayElement(["A", "B", "C", "X", "$"]), progress: faker.datatype.number(100) / 100, value: faker.datatype.number(1000), @@ -333,6 +337,8 @@ ...(set.plugins.enabled.languages ? ({ languages: { + unique: faker.datatype.number(50), + sections: options["languages.sections"].split(", ").map(x => x.trim()).filter(x => /^(most-used|recently-used)$/.test(x)), details: options["languages.details"].split(",").map(x => x.trim()).filter(x => x), get colors() { return Object.fromEntries(Object.entries(this.favorites).map(([key, { color }]) => [key, color])) @@ -341,7 +347,20 @@ get stats() { return Object.fromEntries(Object.entries(this.favorites).map(([key, { value }]) => [key, value])) }, + ["stats.recent"]:{ + total: faker.datatype.number(10000), + get lines() { + return Object.fromEntries(Object.entries(this.favorites).map(([key, { value }]) => [key, value])) + }, + get stats() { + return Object.fromEntries(Object.entries(this.favorites).map(([key, { value }]) => [key, value])) + }, + commits:faker.datatype.number(500), + files:faker.datatype.number(1000), + days:Number(options["languages.recent.days"]) + }, favorites: distribution(7).map((value, index, array) => ({ name: faker.lorem.word(), color: faker.internet.color(), value, size: faker.datatype.number(1000000), x: array.slice(0, index).reduce((a, b) => a + b, 0) })), + recent: distribution(7).map((value, index, array) => ({ name: faker.lorem.word(), color: faker.internet.color(), value, size: faker.datatype.number(1000000), x: array.slice(0, index).reduce((a, b) => a + b, 0) })), }, }) : null), @@ -383,6 +402,11 @@ habits: { facts: options["habits.facts"], charts: options["habits.charts"], + lines: { + average: { + chars: faker.datatype.number(1000)/10, + } + }, commits: { get hour() { return Object.keys(this.hours).filter(key => /^\d+$/.test(key)).map(key => [key, this.hours[key]]).sort((a, b) => b[1] - a[1]).shift()?.[0] @@ -911,6 +935,37 @@ }, }) : null), + //Support + ...(set.plugins.enabled.support + ? ({ + support: { + stats: { solutions: faker.datatype.number(100), posts: faker.datatype.number(1000), topics: faker.datatype.number(1000), received: faker.datatype.number(1000), hearts: faker.datatype.number(1000) }, + badges: { uniques: [ ], multiples: [], count: faker.datatype.number(1000) } + }, + }) + : null), + //Screenshot + ...(set.plugins.enabled.screenshot + ? ({ + screenshot: { + image:"data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==", + title: options["screenshot.title"], + height: 440, + width: 454, + }, + }) + : null), + //Skyline + ...(set.plugins.enabled.skyline + ? ({ + skyline: { + animation:"data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOcOnfpfwAGfgLYttYINwAAAABJRU5ErkJggg==", + width: 454, + height: 284, + compatibility: false + }, + }) + : null), //Stackoverflow ...(set.plugins.enabled.stackoverflow ? ({