From acdca6e00dd7564af9247b9a82ac9cd2d3c99ec6 Mon Sep 17 00:00:00 2001 From: Brandon Stull Date: Mon, 25 Mar 2019 16:31:06 -0400 Subject: [PATCH 1/2] #43 Rearranged css and js imports in the views to reduce redundancy and enable the 'Download Package' button on the splash screen, started working out backend logic for making preflight checks. --- assets/css/mdk-creator.css | 5 --- assets/css/mdk-download.css | 35 +++++++++++++++ assets/css/mdk-main.css | 7 ++- express.js | 88 ++++++++++++++++++++++++++++++++++++- views/creator_mdk.html | 3 -- views/download.html | 20 +++++++++ views/index.html | 3 ++ views/layout.html | 3 ++ views/player_mdk.html | 8 ---- 9 files changed, 154 insertions(+), 18 deletions(-) diff --git a/assets/css/mdk-creator.css b/assets/css/mdk-creator.css index ef3ba90..7fa0644 100644 --- a/assets/css/mdk-creator.css +++ b/assets/css/mdk-creator.css @@ -3,11 +3,6 @@ width: 100%; } -.tools { - margin-top: -12px; - float: right; -} - .center { width: 100%; height: 600px; diff --git a/assets/css/mdk-download.css b/assets/css/mdk-download.css index 88383c4..648ca94 100644 --- a/assets/css/mdk-download.css +++ b/assets/css/mdk-download.css @@ -30,4 +30,39 @@ body#download #build-commands{ body#download #download_button{ margin-right:20px; +} + +body#download #preflight-checklist-container{ + display: block; + text-align: center; +} + +body#download #preflight-checklist{ + display: inline-flex; + flex-direction: column; + align-items: flex-start; + margin: 0 auto; +} + +body#download #preflight-checklist > span .action{ + font-size: 10px; +} + +body#download #preflight-checklist > span:before{ + display: inline-block; + text-align: left; + width: 20px; +} + +body#download #preflight-checklist > span.pass:before{ + content: "✔"; + color: green; +} +body#download #preflight-checklist > span.fail:before{ + content: "X"; + color: red; +} +body#download #preflight-checklist > span.unknown:before{ + content: "?"; + color: orange; } \ No newline at end of file diff --git a/assets/css/mdk-main.css b/assets/css/mdk-main.css index 433387c..9ad8e86 100644 --- a/assets/css/mdk-main.css +++ b/assets/css/mdk-main.css @@ -19,6 +19,11 @@ body { text-decoration: none; } +.tools { + margin-top: -12px; + float: right; +} + #leftbar { width: 250px; background: #333; @@ -107,7 +112,7 @@ body { background: #fff; width: 500px; - height: 280px; + height: 500px; margin: 0 auto; } diff --git a/express.js b/express.js index 7e90018..db0e2a6 100644 --- a/express.js +++ b/express.js @@ -376,7 +376,93 @@ module.exports = (app) => { // Show the package options app.get('/mdk/package', (req, res) => { - res.locals = Object.assign(res.locals, {template: 'download'}) + let status = { + demo: 'unknown', + install: 'unknown', + screenshot: 'unknown', + icon: 'unknown', + scoreModule: 'unknown', + creatorCallback: 'unknown', + playerCallback: 'unknown', + scoreScreenCallback: 'unknown' + } + let action = { + demo: '', + install: '', + screenshot: '', + icon: '', + scoreModule: '', + creatorCallback: '', + playerCallback: '', + scoreScreenCallback: '' + } + //let's see if we can get the demo json file + try { + let demo = JSON.parse(getFileFromWebpack('demo.json').toString()) + + if(!demo.name) { + status.demo = 'fail' + action.demo = "'name' property missing" + } else if(!demo.qset) { + status.demo = 'fail' + action.demo = "'qset' property missing" + } else if(!demo.qset.version) { + status.demo = 'fail' + action.demo = "'qset' 'version' property missing" + } else if(!demo.qset.data) { + status.demo = 'fail' + action.demo = "'qset' 'data' property missing" + } + status.demo = 'pass' + } catch(error) { + status.demo = 'fail' + action.demo = 'demo.json missing or can\'t be parsed' + } + + const checklist = [ + { + status: status.demo, + text: 'demo.json found and valid', + action: action.demo, + }, + { + status: status.install, + text: 'install.yaml found and valid', + action: action.install, + }, + { + status: status.screenshot, + text: 'screenshots found', + action: action.screenshot, + }, + { + status: status.icon, + text: 'icons files found', + action: action.icon, + }, + { + status: status.scoreModule, + text: 'score module found and valid', + action: action.scoreModule, + }, + { + status: status.creatorCallback, + text: 'creator callbacks registered', + action: action.creatorCallback, + }, + { + status: status.playerCallback, + text: 'player callbacks registered', + action: action.playerCallback, + }, + { + status: status.scoreScreenCallback, + text: 'score screen callbacks registered', + action: action.scoreScreenCallback, + }, + ] + + res.locals = Object.assign(res.locals, {template: 'download', checklist: checklist}) res.render(res.locals.template) }) diff --git a/views/creator_mdk.html b/views/creator_mdk.html index d483829..fd582b5 100644 --- a/views/creator_mdk.html +++ b/views/creator_mdk.html @@ -2,10 +2,7 @@ - - -
diff --git a/views/download.html b/views/download.html index cd83769..1404b52 100644 --- a/views/download.html +++ b/views/download.html @@ -1,6 +1,24 @@

Download or Install:

+
+

Preflight Checks:

+ +
+
+ {{#checklist}} + + + {{text}} + + + {{action}} + + + {{/checklist}} +
+
+
@@ -12,6 +30,8 @@

Download or Install:

+ + +
diff --git a/views/player_mdk.html b/views/player_mdk.html index f4c1c13..9feb711 100644 --- a/views/player_mdk.html +++ b/views/player_mdk.html @@ -1,15 +1,7 @@ - - - - - - - -