From 1a1e3fcbae3e15a1ed5a88c827aa6bd8b321a2cb Mon Sep 17 00:00:00 2001 From: Oj Date: Fri, 2 Jul 2021 19:22:57 +0100 Subject: [PATCH] [SiteGen] Rewrite to use sidebar, add repos --- src/index.js | 3 + src/siteGen/index.js | 30 ++++++++- src/siteGen/template.html | 130 +++++++++++++++++++++++++++++++++++--- 3 files changed, 152 insertions(+), 11 deletions(-) diff --git a/src/index.js b/src/index.js index b881156..20e0010 100644 --- a/src/index.js +++ b/src/index.js @@ -33,6 +33,9 @@ global.distDir = distDir; const modulesDir = `${distDir}/module`; +await SiteGen(); +process.exit(); + const resetDir = (dir) => { rmSync(dir, { recursive: true, force: true }); mkdirSync(dir, { recursive: true }); diff --git a/src/siteGen/index.js b/src/siteGen/index.js index 8741fd1..6971f9f 100644 --- a/src/siteGen/index.js +++ b/src/siteGen/index.js @@ -45,7 +45,22 @@ return `
${m.version === '0' || m.version.toLowerCase().includes('auto') ? '' : `v${m.version}`}
`; -} +}; + +const makeRepo = (r) => { + return ` +
+
${r.name}
+
${r.description}
+
+ +
+
${r.themes} themes
+
${r.plugins} plugins
+
${r.developers} developers
+
+
`; +}; export default () => { let template = readFileSync(join(__dirname, 'template.html'), 'utf8'); @@ -53,6 +68,7 @@ export default () => { const repos = glob.sync(join(global.distDir, '*.json')); let cards = []; + let metas = []; let name = 'GooseMod Store'; let description = ''; @@ -68,6 +84,17 @@ export default () => { } cards = cards.concat(json.modules); + + metas.push({ + ...json.meta, + + themes: json.modules.filter((x) => x.tags.includes('theme')).length, + plugins: json.modules.filter((x) => !x.tags.includes('theme')).length, + + developers: Object.keys(json.modules.reduce((acc, x) => { (!Array.isArray(x.authors) ? [ x.authors ] : x.authors).forEach((a) => acc[typeof a === 'object' ? a.i : a] = true); return acc; }, {})).length, + + filename: repo.split('/').pop() + }); } description += `Browse ${cards.filter((x) => x.tags.includes('theme')).length} themes and ${cards.filter((x) => !x.tags.includes('theme')).length} plugins from ${Object.keys(cards.reduce((acc, x) => { (!Array.isArray(x.authors) ? [ x.authors ] : x.authors).forEach((a) => acc[typeof a === 'object' ? a.i : a] = true); return acc; }, {})).length} developers.`; @@ -76,6 +103,7 @@ export default () => { template = template .replace('ALL_CARDS', cards.join('\n')) + .replace('REPOS', metas.map((x) => makeRepo(x)).join('\n')) .replaceAll('NAME', name) .replaceAll('DESCRIPTION', description); diff --git a/src/siteGen/template.html b/src/siteGen/template.html index 006ad65..b6d642d 100644 --- a/src/siteGen/template.html +++ b/src/siteGen/template.html @@ -44,23 +44,64 @@ width: 100%; background-color: #101418; + + overflow: hidden; } - body { - box-sizing: border-box; - display: flex; - justify-content: center; + .sidebar { + display: inline-block; + width: 180px; + height: 100vh; + vertical-align: top; - padding: 22px; + box-sizing: border-box; + + background-color: var(--background-secondary); + } + + .sidebar > div { + width: 100%; + + padding: 12px 16px; + + color: var(--text-normal); + background-color: var(--background-tertiary); + + box-sizing: border-box; + + cursor: pointer; + } + + .sidebar > .sidebar-header { + cursor: default; + + color: var(--header-primary); + background-color: transparent; + } + + .sidebar > div.active { + background-color: #7289da; + } + + .sidebar-button:hover { + background-color: #14181C; } .container { - width: 85vw; + padding: 22px; - display: flex; + width: calc(100vw - 185px); + height: 100vh; + + overflow-y: auto; + + display: inline-flex; flex-flow: row wrap; + align-items: center; justify-content: center; + + box-sizing: border-box; } @media (max-width: 1300px) { @@ -77,6 +118,54 @@ flex-basis: 100%; } + body.themes .gm-store-card:not(.theme) { + display: none; + } + + body.plugins .gm-store-card.theme { + display: none; + } + + .container.repos { + display: none; + } + + body.repos .container.cards { + display: none; + } + + body.repos .container.repos { + display: inline-flex; + } + + .container.repos { + align-content: flex-start; + } + + .container .repo { + width: 300px; + height: 200px; + + justify-content: space-between; + display: flex; + flex-flow: column; + + text-decoration: none; + } + + .repo * { + cursor: pointer; + } + + .repo > :last-child { + display: flex; + justify-content: space-around; + } + + .repo > strong { + color: var(--text-normal); + } + .gm-inline-dropdown { display: flex; align-items: center; @@ -105,7 +194,7 @@ margin-right: 12px; } -.gm-store-card { +.gm-store-card, .repo { box-shadow: var(--elevation-medium); background-color: var(--background-secondary); @@ -340,8 +429,15 @@ - -
+ + + +
@@ -358,6 +454,10 @@ ALL_CARDS
+
+ REPOS +
+ \ No newline at end of file