updates helmet policies, makes new startup script
This commit is contained in:
10
pm2Start.js
Normal file
10
pm2Start.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
var pm2 = require('pm2');
|
||||||
|
pm2.connect(function() {
|
||||||
|
pm2.start({
|
||||||
|
script: 'server/server.js',
|
||||||
|
exec_mode: 'fork',
|
||||||
|
max_memory_restart: '900M'
|
||||||
|
}, function(err, apps) {
|
||||||
|
pm2.disconnect();
|
||||||
|
});
|
||||||
|
});
|
@ -18,7 +18,7 @@ editor.setSize("100%", "auto");
|
|||||||
// Hijack tab key to enter two spaces intead
|
// Hijack tab key to enter two spaces intead
|
||||||
editor.setOption("extraKeys", {
|
editor.setOption("extraKeys", {
|
||||||
Tab: function(cm) {
|
Tab: function(cm) {
|
||||||
if (cm.somethingSelected()){
|
if (cm.somethingSelected()) {
|
||||||
cm.indentSelection("add");
|
cm.indentSelection("add");
|
||||||
} else {
|
} else {
|
||||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
@ -26,7 +26,7 @@ editor.setOption("extraKeys", {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Shift-Tab": function(cm) {
|
"Shift-Tab": function(cm) {
|
||||||
if (cm.somethingSelected()){
|
if (cm.somethingSelected()) {
|
||||||
cm.indentSelection("subtract");
|
cm.indentSelection("subtract");
|
||||||
} else {
|
} else {
|
||||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||||
@ -61,7 +61,10 @@ codeOutput.setValue('/**\n' +
|
|||||||
' */');
|
' */');
|
||||||
codeOutput.setSize("100%", "100%");
|
codeOutput.setSize("100%", "100%");
|
||||||
var info = editor.getScrollInfo();
|
var info = editor.getScrollInfo();
|
||||||
var after = editor.charCoords({line: editor.getCursor().line + 1, ch: 0}, "local").top;
|
var after = editor.charCoords({
|
||||||
|
line: editor.getCursor().line + 1,
|
||||||
|
ch: 0
|
||||||
|
}, "local").top;
|
||||||
if (info.top + info.clientHeight < after)
|
if (info.top + info.clientHeight < after)
|
||||||
editor.scrollTo(null, after - info.clientHeight + 3);
|
editor.scrollTo(null, after - info.clientHeight + 3);
|
||||||
|
|
||||||
@ -83,8 +86,8 @@ editorValue = allSeeds;
|
|||||||
|
|
||||||
myCodeMirror.setValue(editorValue);
|
myCodeMirror.setValue(editorValue);
|
||||||
|
|
||||||
function doLinting () {
|
function doLinting() {
|
||||||
editor.operation(function () {
|
editor.operation(function() {
|
||||||
for (var i = 0; i < widgets.length; ++i)
|
for (var i = 0; i < widgets.length; ++i)
|
||||||
editor.removeLineWidget(widgets[i]);
|
editor.removeLineWidget(widgets[i]);
|
||||||
widgets.length = 0;
|
widgets.length = 0;
|
||||||
@ -106,14 +109,14 @@ function doLinting () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$('#submitButton').on('click', function () {
|
$('#submitButton').on('click', function() {
|
||||||
bonfireExecute();
|
bonfireExecute();
|
||||||
});
|
});
|
||||||
|
|
||||||
function bonfireExecute() {
|
function bonfireExecute() {
|
||||||
attempts++;
|
attempts++;
|
||||||
ga('send', 'event', 'Challenge', 'ran-code', challenge_Name);
|
ga('send', 'event', 'Challenge', 'ran-code', challenge_Name);
|
||||||
userTests= null;
|
userTests = null;
|
||||||
$('#codeOutput').empty();
|
$('#codeOutput').empty();
|
||||||
var userJavaScript = myCodeMirror.getValue();
|
var userJavaScript = myCodeMirror.getValue();
|
||||||
userJavaScript = removeComments(userJavaScript);
|
userJavaScript = removeComments(userJavaScript);
|
||||||
@ -145,16 +148,23 @@ var scrapeTests = function(userJavaScript) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
var regex = new RegExp(/(expect(\s+)?\(.*\;)|(assert(\s+)?\(.*\;)|(assert\.\w.*\;)|(.*\.should\..*\;)/);
|
var regex = new RegExp(
|
||||||
|
/(expect(\s+)?\(.*\;)|(assert(\s+)?\(.*\;)|(assert\.\w.*\;)|(.*\.should\..*\;)/
|
||||||
|
);
|
||||||
var match = regex.exec(userJavaScript);
|
var match = regex.exec(userJavaScript);
|
||||||
while (match != null) {
|
while (match != null) {
|
||||||
var replacement = '//' + counter + testSalt;
|
var replacement = '//' + counter + testSalt;
|
||||||
userJavaScript = userJavaScript.substring(0, match.index) + replacement + userJavaScript.substring(match.index + match[0].length);
|
userJavaScript = userJavaScript.substring(0, match.index) + replacement +
|
||||||
|
userJavaScript.substring(match.index + match[0].length);
|
||||||
|
|
||||||
if (!userTests) {
|
if (!userTests) {
|
||||||
userTests= [];
|
userTests = [];
|
||||||
}
|
}
|
||||||
userTests.push({"text": match[0], "line": counter, "err": null});
|
userTests.push({
|
||||||
|
"text": match[0],
|
||||||
|
"line": counter,
|
||||||
|
"err": null
|
||||||
|
});
|
||||||
counter++;
|
counter++;
|
||||||
match = regex.exec(userJavaScript);
|
match = regex.exec(userJavaScript);
|
||||||
}
|
}
|
||||||
@ -176,17 +186,22 @@ var createTestDisplay = function() {
|
|||||||
if (pushed) {
|
if (pushed) {
|
||||||
userTests.pop();
|
userTests.pop();
|
||||||
}
|
}
|
||||||
for (var i = 0; i < userTests.length;i++) {
|
for (var i = 0; i < userTests.length; i++) {
|
||||||
var test = userTests[i];
|
var test = userTests[i];
|
||||||
var testDoc = document.createElement("div");
|
var testDoc = document.createElement("div");
|
||||||
if (test.err != null) {
|
if (test.err != null) {
|
||||||
console.log('Should be displaying bad tests');
|
console.log('Should be displaying bad tests');
|
||||||
$(testDoc)
|
$(testDoc)
|
||||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-10 test-output wrappable test-vertical-center grayed-out-test-output'>" + test.text + "</div><div class='col-xs-10 test-output wrappable'>" + test.err + "</div></div><div class='ten-pixel-break'/>")
|
.html(
|
||||||
|
"<div class='row'><div class='col-xs-2 text-center'><i class='ion-close-circled big-error-icon'></i></div><div class='col-xs-10 test-output wrappable test-vertical-center grayed-out-test-output'>" +
|
||||||
|
test.text + "</div><div class='col-xs-10 test-output wrappable'>" +
|
||||||
|
test.err + "</div></div><div class='ten-pixel-break'/>")
|
||||||
.appendTo($('#testSuite'));
|
.appendTo($('#testSuite'));
|
||||||
} else {
|
} else {
|
||||||
$(testDoc)
|
$(testDoc)
|
||||||
.html("<div class='row'><div class='col-xs-2 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-10 test-output test-vertical-center wrappable grayed-out-test-output'>" + test.text + "</div></div><div class='ten-pixel-break'/>")
|
.html(
|
||||||
|
"<div class='row'><div class='col-xs-2 text-center'><i class='ion-checkmark-circled big-success-icon'></i></div><div class='col-xs-10 test-output test-vertical-center wrappable grayed-out-test-output'>" +
|
||||||
|
test.text + "</div></div><div class='ten-pixel-break'/>")
|
||||||
.appendTo($('#testSuite'));
|
.appendTo($('#testSuite'));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -208,18 +223,21 @@ var runTests = function(err, data) {
|
|||||||
pushed = false;
|
pushed = false;
|
||||||
$('#testSuite').children().remove();
|
$('#testSuite').children().remove();
|
||||||
if (err && userTests.length > 0) {
|
if (err && userTests.length > 0) {
|
||||||
userTests= [{text:"Program Execution Failure", err: "No user tests were run."}];
|
userTests = [{
|
||||||
|
text: "Program Execution Failure",
|
||||||
|
err: "No user tests were run."
|
||||||
|
}];
|
||||||
createTestDisplay();
|
createTestDisplay();
|
||||||
} else if (userTests) {
|
} else if (userTests) {
|
||||||
userTests.push(false);
|
userTests.push(false);
|
||||||
pushed = true;
|
pushed = true;
|
||||||
userTests.forEach(function(chaiTestFromJSON, indexOfTestArray, __testArray){
|
userTests.forEach(function(chaiTestFromJSON, indexOfTestArray,
|
||||||
|
__testArray) {
|
||||||
try {
|
try {
|
||||||
if (chaiTestFromJSON) {
|
if (chaiTestFromJSON) {
|
||||||
var output = eval(reassembleTest(chaiTestFromJSON, data));
|
var output = eval(reassembleTest(chaiTestFromJSON, data));
|
||||||
debugger;
|
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch (error) {
|
||||||
allTestsPassed = false;
|
allTestsPassed = false;
|
||||||
__testArray[indexOfTestArray].err = error.message;
|
__testArray[indexOfTestArray].err = error.message;
|
||||||
} finally {
|
} finally {
|
||||||
@ -239,12 +257,12 @@ var runTests = function(err, data) {
|
|||||||
|
|
||||||
function showCompletion() {
|
function showCompletion() {
|
||||||
var time = Math.floor(Date.now()) - started;
|
var time = Math.floor(Date.now()) - started;
|
||||||
ga('send', 'event', 'Challenge', 'solved', challenge_Name + ', Time: ' + time +', Attempts: ' + attempts);
|
ga('send', 'event', 'Challenge', 'solved', challenge_Name + ', Time: ' + time +
|
||||||
|
', Attempts: ' + attempts);
|
||||||
var bonfireSolution = myCodeMirror.getValue();
|
var bonfireSolution = myCodeMirror.getValue();
|
||||||
var didCompleteWith = $('#completed-with').val() || null;
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
$.post(
|
$.post(
|
||||||
'/completed-bonfire/',
|
'/completed-bonfire/', {
|
||||||
{
|
|
||||||
challengeInfo: {
|
challengeInfo: {
|
||||||
challengeId: challenge_Id,
|
challengeId: challenge_Id,
|
||||||
challengeName: challenge_Name,
|
challengeName: challenge_Name,
|
||||||
@ -252,10 +270,11 @@ function showCompletion() {
|
|||||||
challengeType: challengeType,
|
challengeType: challengeType,
|
||||||
solution: bonfireSolution
|
solution: bonfireSolution
|
||||||
}
|
}
|
||||||
}, function(res) {
|
},
|
||||||
|
function(res) {
|
||||||
if (res) {
|
if (res) {
|
||||||
$('#complete-courseware-dialog').modal('show');
|
$('#complete-courseware-dialog').modal('show');
|
||||||
$('#complete-courseware-dialog').keydown(function (e) {
|
$('#complete-courseware-dialog').keydown(function(e) {
|
||||||
if (e.ctrlKey && e.keyCode == 13) {
|
if (e.ctrlKey && e.keyCode == 13) {
|
||||||
$('#next-courseware-button').click();
|
$('#next-courseware-button').click();
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,8 @@ app.use(helmet.csp({
|
|||||||
'*.aspnetcdn.com',
|
'*.aspnetcdn.com',
|
||||||
'*.d3js.org',
|
'*.d3js.org',
|
||||||
'https://cdn.inspectlet.com/inspectlet.js',
|
'https://cdn.inspectlet.com/inspectlet.js',
|
||||||
'http://cdn.inspectlet.com/inspectlet.js'
|
'http://cdn.inspectlet.com/inspectlet.js',
|
||||||
|
'http://www.freecodecamp.org'
|
||||||
].concat(trusted),
|
].concat(trusted),
|
||||||
'connect-src': [].concat(trusted),
|
'connect-src': [].concat(trusted),
|
||||||
styleSrc: [
|
styleSrc: [
|
||||||
|
Reference in New Issue
Block a user