diff --git a/app.js b/app.js index 279c24b74f..0fbff67ef6 100644 --- a/app.js +++ b/app.js @@ -260,6 +260,9 @@ app.get( '/bonfires/:bonfireNumber', bonfireController.returnIndividualBonfire ); +app.get('/bonfire', function(req, res) { + res.redirect(301, '/playground'); +}); app.get('/bonfires', bonfireController.returnBonfire); app.get('/bonfire/generator', bonfireController.returnGenerator); app.post('/bonfire/generator', bonfireController.generateChallenge); diff --git a/controllers/bonfire.js b/controllers/bonfire.js index 079aad96b1..e52a2d19fb 100644 --- a/controllers/bonfire.js +++ b/controllers/bonfire.js @@ -12,7 +12,23 @@ var highestBonfireNumber = 2; exports.index = function(req, res) { res.render('bonfire/bonfire.jade', { - title: 'Learn to code with Bonfire' + title: 'Learn to code with Bonfire', + completedWith: null, + title: null, + difficulty: null, + brief: null, + details: null, + tests: null, + challengeSeed: null, + challengeEntryPoint: null, + cc: req.user ? req.user.bonfiresHash : undefined, + points: req.user ? req.user.points : undefined, + verb: resources.randomVerb(), + phrase: resources.randomPhrase(), + compliment: resources.randomCompliment(), + bonfires: [], + bonfireHash: "test" + }); Bonfire.find({}, null, { sort: { difficulty: 1 } }, function(err, c) { diff --git a/public/js/lib/bonfire/bonfireFramework.js b/public/js/lib/bonfire/bonfireFramework.js index 3d9f68b6b5..5514d1d798 100644 --- a/public/js/lib/bonfire/bonfireFramework.js +++ b/public/js/lib/bonfire/bonfireFramework.js @@ -123,11 +123,6 @@ function bonfireExecute() { }); } -var replaceQuotesInTests = function() { - userTests.forEach(function(elt, ix, arr) { - arr[ix].text = arr[ix].text.replace(/\"/g,'\''); - }); -}; var userTests; var testSalt = Math.random(); @@ -145,9 +140,7 @@ var scrapeTests = function(userJavaScript) { var match = regex.exec(userJavaScript); while (match != null) { 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) { userTests= []; @@ -157,9 +150,6 @@ var scrapeTests = function(userJavaScript) { match = regex.exec(userJavaScript); } - if (userTests) { - replaceQuotesInTests(); - } return userJavaScript; }; @@ -170,7 +160,6 @@ function removeComments(userJavaScript) { function removeLogs(userJavaScript) { return userJavaScript.replace(/(console\.[\w]+\s*\(.*\;)/g, ''); - return userJavaScript; } var pushed = false; @@ -210,14 +199,13 @@ var runTests = function(err, data) { userTests= [{text:"Program Execution Failure", err: "No user tests were run."}]; createTestDisplay(); } else if (userTests) { - userTests.push(false); pushed = true; userTests.forEach(function(test, ix, arr){ try { if (test) { - var test = JSON.stringify(reassembleTest(test, data)); - var output = eval(test); + console.log(); + var output = eval(reassembleTest(test, data)); } } catch(error) { allTestsPassed = false; diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json index bf8412d639..920824fa2c 100644 --- a/seed_data/bonfires.json +++ b/seed_data/bonfires.json @@ -14,7 +14,7 @@ "expect(meetBonfire(\"test\")).to.be.true;" ], "challengeSeed": "function meetBonfire(argument) {\n // Good luck!\n console.log(\"you can read this function's argument in the developer tools\", argument);\n\nreturn false;\n}\n\n", - "challengeEntryPoint": "meetBonfire(\"You can do this!\");", + "challengeEntryPoint": "meetBonfire(\"You can do this!\");" }, { "_id" : "aaa48de84e1ecc7c742e1124", @@ -37,7 +37,7 @@ "assert.deepEqual(palindrome(\"nope\"), false);" ], "challengeSeed": "function palindrome(str) {\n // Good luck!\n return true;\n}\n\n", - "challengeEntryPoint": "palindrome(\"eye\");", + "challengeEntryPoint": "palindrome(\"eye\");" }, { "_id" : "ff0395860f5d3034dc0bfc94", @@ -74,7 +74,7 @@ "assert.deepEqual(telephoneCheck(\"2(757)622-7382\"), false);" ], "challengeSeed": "function telephoneCheck(str) {\n // Good luck!\n return true;\n}\n\n", - "challengeEntryPoint": "telephoneCheck(\"555-555-5555\");", + "challengeEntryPoint": "telephoneCheck(\"555-555-5555\");" }, { "_id": "202eed8fc186c8434cb6d618", @@ -92,7 +92,7 @@ "Your result must be a string." ], "challengeEntryPoint": "reverseString('hello');", - "challengeSeed": "function reverseString(str) {\n return str;\r\n}", + "challengeSeed": "function reverseString(str) {\n return str;\r\n}" }, { "_id": "302f7aae1aa3152a5b413bca", diff --git a/views/bonfire/show.jade b/views/bonfire/show.jade index 23a3404d68..bc1017d59b 100644 --- a/views/bonfire/show.jade +++ b/views/bonfire/show.jade @@ -23,7 +23,7 @@ block content .col-xs-12.col-sm-12.col-md-3 #testCreatePanel h2.text-center #{name} - Difficulty:   + Difficulty if (difficulty == "0") i.ion-ios-flame-outline i.ion-ios-flame-outline