Skip to content

Commit acdca6e

Browse files
ucfopen#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.
1 parent afd8a29 commit acdca6e

9 files changed

+154
-18
lines changed

assets/css/mdk-creator.css

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
width: 100%;
44
}
55

6-
.tools {
7-
margin-top: -12px;
8-
float: right;
9-
}
10-
116
.center {
127
width: 100%;
138
height: 600px;

assets/css/mdk-download.css

+35
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,39 @@ body#download #build-commands{
3030

3131
body#download #download_button{
3232
margin-right:20px;
33+
}
34+
35+
body#download #preflight-checklist-container{
36+
display: block;
37+
text-align: center;
38+
}
39+
40+
body#download #preflight-checklist{
41+
display: inline-flex;
42+
flex-direction: column;
43+
align-items: flex-start;
44+
margin: 0 auto;
45+
}
46+
47+
body#download #preflight-checklist > span .action{
48+
font-size: 10px;
49+
}
50+
51+
body#download #preflight-checklist > span:before{
52+
display: inline-block;
53+
text-align: left;
54+
width: 20px;
55+
}
56+
57+
body#download #preflight-checklist > span.pass:before{
58+
content: "✔";
59+
color: green;
60+
}
61+
body#download #preflight-checklist > span.fail:before{
62+
content: "X";
63+
color: red;
64+
}
65+
body#download #preflight-checklist > span.unknown:before{
66+
content: "?";
67+
color: orange;
3368
}

assets/css/mdk-main.css

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ body {
1919
text-decoration: none;
2020
}
2121

22+
.tools {
23+
margin-top: -12px;
24+
float: right;
25+
}
26+
2227
#leftbar {
2328
width: 250px;
2429
background: #333;
@@ -107,7 +112,7 @@ body {
107112
background: #fff;
108113

109114
width: 500px;
110-
height: 280px;
115+
height: 500px;
111116

112117
margin: 0 auto;
113118
}

express.js

+87-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,93 @@ module.exports = (app) => {
376376

377377
// Show the package options
378378
app.get('/mdk/package', (req, res) => {
379-
res.locals = Object.assign(res.locals, {template: 'download'})
379+
let status = {
380+
demo: 'unknown',
381+
install: 'unknown',
382+
screenshot: 'unknown',
383+
icon: 'unknown',
384+
scoreModule: 'unknown',
385+
creatorCallback: 'unknown',
386+
playerCallback: 'unknown',
387+
scoreScreenCallback: 'unknown'
388+
}
389+
let action = {
390+
demo: '',
391+
install: '',
392+
screenshot: '',
393+
icon: '',
394+
scoreModule: '',
395+
creatorCallback: '',
396+
playerCallback: '',
397+
scoreScreenCallback: ''
398+
}
399+
//let's see if we can get the demo json file
400+
try {
401+
let demo = JSON.parse(getFileFromWebpack('demo.json').toString())
402+
403+
if(!demo.name) {
404+
status.demo = 'fail'
405+
action.demo = "'name' property missing"
406+
} else if(!demo.qset) {
407+
status.demo = 'fail'
408+
action.demo = "'qset' property missing"
409+
} else if(!demo.qset.version) {
410+
status.demo = 'fail'
411+
action.demo = "'qset' 'version' property missing"
412+
} else if(!demo.qset.data) {
413+
status.demo = 'fail'
414+
action.demo = "'qset' 'data' property missing"
415+
}
416+
status.demo = 'pass'
417+
} catch(error) {
418+
status.demo = 'fail'
419+
action.demo = 'demo.json missing or can\'t be parsed'
420+
}
421+
422+
const checklist = [
423+
{
424+
status: status.demo,
425+
text: 'demo.json found and valid',
426+
action: action.demo,
427+
},
428+
{
429+
status: status.install,
430+
text: 'install.yaml found and valid',
431+
action: action.install,
432+
},
433+
{
434+
status: status.screenshot,
435+
text: 'screenshots found',
436+
action: action.screenshot,
437+
},
438+
{
439+
status: status.icon,
440+
text: 'icons files found',
441+
action: action.icon,
442+
},
443+
{
444+
status: status.scoreModule,
445+
text: 'score module found and valid',
446+
action: action.scoreModule,
447+
},
448+
{
449+
status: status.creatorCallback,
450+
text: 'creator callbacks registered',
451+
action: action.creatorCallback,
452+
},
453+
{
454+
status: status.playerCallback,
455+
text: 'player callbacks registered',
456+
action: action.playerCallback,
457+
},
458+
{
459+
status: status.scoreScreenCallback,
460+
text: 'score screen callbacks registered',
461+
action: action.scoreScreenCallback,
462+
},
463+
]
464+
465+
res.locals = Object.assign(res.locals, {template: 'download', checklist: checklist})
380466
res.render(res.locals.template)
381467
})
382468

views/creator_mdk.html

-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
<link rel="stylesheet" href="/mdk/assets/css/create.css" type="text/css" />
33
<link rel="stylesheet" href="/mdk/assets/css/ng-modal.css" type="text/css" />
44

5-
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.9/angular.min.js"></script>
6-
<script src="/mdk/assets/js/materia.js"></script>
75
<script src="/mdk/assets/js/author.js"></script>
8-
<script src="/mdk/mdk-assets/js/mdk-package.js"></script>
96

107
<div id="topbar">
118
<a class="logo" href="/">Materia Developer Kit</a>

views/download.html

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
<link rel='stylesheet' href='/mdk/assets/css/mdk-download.css' type='text/css' />
22

33
<h1 class='centered'>Download or Install:</h1>
4+
<hr/>
5+
<h2 class='centered'>Preflight Checks:</h2>
6+
7+
<div id='preflight-checklist-container'>
8+
<div id='preflight-checklist'>
9+
{{#checklist}}
10+
<span class={{status}}>
11+
<span>
12+
{{text}}
13+
</span>
14+
<span class='action'>
15+
{{action}}
16+
</span>
17+
</span>
18+
{{/checklist}}
19+
</div>
20+
</div>
21+
422
<hr/>
523
<div id='build-commands' class='centered'>
624
<a href="/mdk/download"><button class='edit_button orange' id='download_button'>Download .wigt</button></a>
@@ -12,6 +30,8 @@ <h1 class='centered'>Download or Install:</h1>
1230
</div>
1331

1432
<script>
33+
34+
1535
document.getElementById('cancel-button').onclick = (e) => {
1636
window.parent.MDK.Package.cancel();
1737
return false

views/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<div id="topbar">
22
<a class='logo' href='/'>Materia Developer Kit</a>
3+
<div class="tools">
4+
<button id="downloadLink" class="edit_button orange" onclick="MDK.Package.showPackageDownload();">Download Package</button>
5+
</div>
36
</div>
47

58
<center class='widget'>

views/layout.html

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
var MEDIA_URL = '/mdk/media'
1212
var STATIC_CROSSDOMAIN = 'http://localhost:{{ port }}/'
1313
</script>
14+
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.9/angular.min.js"></script>
15+
<script src="/mdk/assets/js/materia.js"></script>
16+
<script src="/mdk/mdk-assets/js/mdk-package.js"></script>
1417
</head>
1518
<body id="{{ template }}" >
1619
<div id='modalbg'></div>

views/player_mdk.html

-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
1-
<link rel="stylesheet" href="/mdk/assets/css/main.css" type="text/css" />
21
<link rel="stylesheet" href="/mdk/assets/css/play.css" type="text/css" />
32
<link rel="stylesheet" href="/mdk/assets/css/ng-modal.css" type="text/css" />
4-
<link rel="stylesheet" href="/mdk/assets/css/mdk-creator.css" type="text/css" />
5-
<link rel="stylesheet" href="/mdk/assets/css/mdk-download.css" type="text/css" />
63

7-
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.9/angular.min.js"></script>
8-
<!-- <script src='//cdnjs.cloudflare.com/ajax/libs/swfobject/2.2/swfobject.min.js'></script> -->
9-
<script src="/mdk/assets/js/materia.js"></script>
104
<script src="/mdk/assets/js/student.js"></script>
11-
<script src="/mdk/mdk-assets/js/mdk-package.js"></script>
12-
<!-- <script src="/mdk/mdk-assets/js/mdk-player.js"></script> -->
135

146
<script >
157
var PLAY_ID = '{{ instance }}';

0 commit comments

Comments
 (0)