From 17cd85327b4c6959ffe6eb3bea6a48e900371af0 Mon Sep 17 00:00:00 2001 From: Benjamin Liden Date: Sun, 26 May 2019 06:03:13 -0400 Subject: [PATCH] bugfixes: added await for fileWrites (was hanging), added path import, url escape issue (#58) * added await for fileWrites (was hanging), added path import * fixed html escaping issue with background image. +consistency * changed default background to smaller params. only 90kb --- assets/themes/dark.css | 6 +++--- assets/themes/light.css | 2 +- build.js | 13 +++---------- populate.js | 4 ++-- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/assets/themes/dark.css b/assets/themes/dark.css index 16c28dc..38ce447 100644 --- a/assets/themes/dark.css +++ b/assets/themes/dark.css @@ -2,9 +2,9 @@ --bg-color: rgb(10, 10, 10); --text-color: #fff; --blog-gray-color: rgb(180, 180, 180); - --background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.6), rgb(10, 10, 10, 1)), url("{{background}}"); + --background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.6), rgb(10, 10, 10, 1)), url("{{{background}}}"); --background-background: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0.6)), - url("{{background}}") center center fixed; + url("{{{background}}}") center center fixed; --height: 50vh; } #display h1 { @@ -26,6 +26,6 @@ @media (max-width: 800px) { :root { --background-image: linear-gradient(0deg, rgba(10, 10, 10, 1), rgba(10, 10, 10, 0)), - url("{{background}}") !important; + url("{{{background}}}") !important; } } diff --git a/assets/themes/light.css b/assets/themes/light.css index 330240a..a4b4b58 100644 --- a/assets/themes/light.css +++ b/assets/themes/light.css @@ -2,6 +2,6 @@ --bg-color: #fff; --text-color: rgb(10, 10, 10); --blog-gray-color: rgb(80, 80, 80); - --background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.4), rgb(10, 10, 10, 0.4)), url("{{background}}"); + --background-image: linear-gradient(90deg, rgba(10, 10, 10, 0.4), rgb(10, 10, 10, 0.4)), url("{{{background}}}"); --background-background: #fff; } diff --git a/build.js b/build.js index 2ba483e..86df9ee 100644 --- a/build.js +++ b/build.js @@ -20,7 +20,7 @@ const config = path.join(outDir, 'config.json'); */ async function populateCSS({ theme = 'light', - background = 'https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=1450', + background = 'https://images.unsplash.com/photo-1553748024-d1b27fb3f960?w=500&h=1000&q=80&fit=crop', } = {}) { /* Get the theme the user requests. Defaults to 'light' */ theme = `${theme}.css`; @@ -73,16 +73,9 @@ async function populateConfig(sort, order, includeFork) { async function buildCommand(username, program) { await populateCSS(program); - let sort = program.sort ? program.sort : 'created'; - let order = "asc"; - let includeFork = false; - if(program.order){ - order = ('%s', program.order); - } - if(program.fork){ - includeFork = true; - } + let order = program.order ? program.order : "asc"; + let includeFork = program.fork ? true : false; await populateConfig(sort, order, includeFork); updateHTML(('%s', username), sort, order, includeFork); } diff --git a/populate.js b/populate.js index 0a2958e..b334346 100644 --- a/populate.js +++ b/populate.js @@ -121,11 +121,11 @@ module.exports.updateHTML = (username, sort, order, includeFork) => { data[0].username = user.login; data[0].name = user.name; data[0].userimg = user.avatar_url; - fs.writeFile(`${outDir}/config.json`, JSON.stringify(data, null, ' '), function (err) { + await fs.writeFile(`${outDir}/config.json`, JSON.stringify(data, null, ' '), function (err) { if (err) throw err; console.log("Config file updated."); }); - fs.writeFile(`${outDir}/index.html`, '' + window.document.documentElement.outerHTML, function (error) { + await fs.writeFile(`${outDir}/index.html`, '' + window.document.documentElement.outerHTML, function (error) { if (error) throw error; console.log(`Build Complete, Files can be Found @ ${outDir}`); });