From 064fc68b304cb3ae44005da008313e91a760743e Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 4 Aug 2015 11:04:40 -0500 Subject: [PATCH 01/10] Update bootstrap.json fixed line 1886, changed col-xs-12 to col-xs-6 "assert($('.col-xs-6').children('h4') && $('.col-xs-6').children('h4').length > 1, 'Add an h4 element to each of your <div class=\\'col-xs-6\\'> elements.');", --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index c0b4014f93..68d6c70fc9 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -1883,7 +1883,7 @@ "Above your right-well, inside its \"col-xs-6\" div element, add a h4 element with the text \"#right-well\"." ], "tests": [ - "assert($('.col-xs-12').children('h4') && $('.col-xs-12').children('h4').length > 1, 'Add an h4 element to each of your <div class=\\'col-xs-6\\'> elements.');", + "assert($('.col-xs-6').children('h4') && $('.col-xs-6').children('h4').length > 1, 'Add an h4 element to each of your <div class=\\'col-xs-6\\'> elements.');", "assert(new RegExp('#left-well','gi').test($('h4').text()), 'One h4 element should have the text \"#left-well\".');", "assert(new RegExp('#right-well','gi').test($('h4').text()), 'One h4 element should have the text \"#right-well\".');" ], From 8a1694203675e872c4eb50cbbda5ac21ab1e8ae5 Mon Sep 17 00:00:00 2001 From: sonorangirl Date: Mon, 10 Aug 2015 18:05:07 -0700 Subject: [PATCH 02/10] Fixed typos in 1st slot machine challenge --- seed/challenges/basic-javascript.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index c8cd7046a9..04fd44d166 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1071,16 +1071,16 @@ "title": "Create a JavaScript Slot Machine", "difficulty":"9.988", "description":[ - "We are now going to try and combine some of the stuff we've just learnt abd create the logic for a slot machine game", + "We are now going to try and combine some of the stuff we've just learned and create the logic for a slot machine game", "For this we will need to generate three random numbers between 1 and 5 to represent the possible values of each individual slot", "Store the three random numbers in slotOne, slotTwo and slotThree", "Generate the random numbers by using the system we used earlier in /challenges/random-whole-numbers-in-a-range", "Math.floor(Math.random() * (5 - 1 + 1)) + 1; " ], "tests":[ - "assert(typeof(runSlots($('.slot'))[0]) == 'number', 'SlotOne should be a random number');", - "assert(typeof(runSlots($('.slot'))[1]) == 'number', 'SlotTwo should be a random number');", - "assert(typeof(runSlots($('.slot'))[2]) == 'number', 'SlotThree should be a random number');", + "assert(typeof(runSlots($('.slot'))[0]) == 'number', 'slotOne should be a random number');", + "assert(typeof(runSlots($('.slot'))[1]) == 'number', 'slotTwo should be a random number');", + "assert(typeof(runSlots($('.slot'))[2]) == 'number', 'slotThree should be a random number');", "assert((function(){if(editor.match(/Math.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi) !== null){return(editor.match(/Math.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi).length >= 3);}else{return(false);}})(), 'You should have used Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');" ], "challengeSeed":[ From 8efe8ee825b2f22e3aa6a41d595b9ebb63e7b8ca Mon Sep 17 00:00:00 2001 From: sonorangirl Date: Mon, 10 Aug 2015 19:22:18 -0700 Subject: [PATCH 03/10] Fixed RegEx so that 4th test would pass --- seed/challenges/basic-javascript.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 04fd44d166..7834110ea0 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1081,7 +1081,7 @@ "assert(typeof(runSlots($('.slot'))[0]) == 'number', 'slotOne should be a random number');", "assert(typeof(runSlots($('.slot'))[1]) == 'number', 'slotTwo should be a random number');", "assert(typeof(runSlots($('.slot'))[2]) == 'number', 'slotThree should be a random number');", - "assert((function(){if(editor.match(/Math.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi) !== null){return(editor.match(/Math.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi).length >= 3);}else{return(false);}})(), 'You should have used Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');" + "assert((function(){if(editor.match(/Math\\.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi) !== null){return(editor.match(/Math\\.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi).length >= 3);}else{return(false);}})(), 'You should have used Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');" ], "challengeSeed":[ "fccss", From fb44b50941a575781e815223ace36da9a6dd3f04 Mon Sep 17 00:00:00 2001 From: sonorangirl Date: Mon, 10 Aug 2015 19:32:52 -0700 Subject: [PATCH 04/10] Made some spaces optional for 4th test --- seed/challenges/basic-javascript.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index 7834110ea0..0aa6f4f02f 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1081,7 +1081,7 @@ "assert(typeof(runSlots($('.slot'))[0]) == 'number', 'slotOne should be a random number');", "assert(typeof(runSlots($('.slot'))[1]) == 'number', 'slotTwo should be a random number');", "assert(typeof(runSlots($('.slot'))[2]) == 'number', 'slotThree should be a random number');", - "assert((function(){if(editor.match(/Math\\.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi) !== null){return(editor.match(/Math\\.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi).length >= 3);}else{return(false);}})(), 'You should have used Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');" + "assert((function(){if(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?5\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi) !== null){return(editor.match(/Math\\.floor\\(\\s?Math\\.random\\(\\)\\s?\\*\\s?\\(\\s?5\\s?\\-\\s?1\\s?\\+\\s?1\\s?\\)\\s?\\)\\s?\\+\\s?1;/gi).length >= 3);}else{return(false);}})(), 'You should have used Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');" ], "challengeSeed":[ "fccss", From 5f21db457d74ef364e2c0f43fb88be1ef73110af Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 10 Aug 2015 23:29:32 -0700 Subject: [PATCH 05/10] fix challenge ordering Now challenges are ordered on map first by top order value of json file second by index of array --- common/models/challenge.json | 3 +++ seed/index.js | 3 ++- server/boot/challenge.js | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/models/challenge.json b/common/models/challenge.json index 743332107d..08fa48779b 100644 --- a/common/models/challenge.json +++ b/common/models/challenge.json @@ -22,6 +22,9 @@ "order": { "type": "number" }, + "suborder": { + "type": "number" + }, "dashedName": { "type": "string" }, diff --git a/seed/index.js b/seed/index.js index 38305428a2..334a11d3dc 100644 --- a/seed/index.js +++ b/seed/index.js @@ -63,7 +63,8 @@ Challenge.destroyAll(function(err, info) { .toLowerCase() .replace(/\:/g, '') .replace(/\s/g, '-'); - challenge.order = +('' + order + (index + 1)); + challenge.order = order; + challenge.suborder = index + 1; challenge.block = block; return challenge; diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 1fc4342def..feea89818a 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -458,7 +458,10 @@ module.exports = function(app) { .map(camperCount => numberWithCommas(camperCount)); const query = { - order: 'order ASC' + order: [ + 'order ASC', + 'suborder ASC' + ] }; // create a stream of all the challenges From 2256f3ef6e2cfec7dd82b975ca5795ba792d2401 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Mon, 10 Aug 2015 23:38:10 -0700 Subject: [PATCH 06/10] fix add github link to passport --- common/models/User-Identity.js | 2 +- server/passport-providers.js | 14 ++++++++++++++ server/server.js | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/models/User-Identity.js b/common/models/User-Identity.js index 87a7ffef57..779ad2f48f 100644 --- a/common/models/User-Identity.js +++ b/common/models/User-Identity.js @@ -79,7 +79,7 @@ export default function(UserIdent) { } // if user signed in with github refresh their info - if (userIdent.provider === 'github-login') { + if (/github/.test(userIdent.provider)) { debug("user isn't github cool or username from github is different"); setProfileFromGithub(user, profile, profile._json); userChanged = true; diff --git a/server/passport-providers.js b/server/passport-providers.js index ddd29f64db..5ffcbf1a09 100644 --- a/server/passport-providers.js +++ b/server/passport-providers.js @@ -141,5 +141,19 @@ module.exports = { clientSecret: process.env.GITHUB_SECRET, scope: ['email'], failureFlash: true + }, + 'github-link': { + provider: 'github', + authScheme: 'oauth2', + module: 'passport-github', + authPath: '/link/github', + callbackURL: '/link/github/callback', + callbackPath: '/link/github/callback', + successRedirect: successRedirect, + failureRedirect: failureRedirect, + clientID: process.env.GITHUB_ID, + clientSecret: process.env.GITHUB_SECRET, + scope: ['email'], + failureFlash: true } }; diff --git a/server/server.js b/server/server.js index 93a0f06d8d..bf0cb8c396 100755 --- a/server/server.js +++ b/server/server.js @@ -102,7 +102,7 @@ var passportOptions = { userObj.email = email; } - if (provider === 'github-login') { + if (/github/.test(provider)) { setProfileFromGithub(userObj, profile, profile._json); } return userObj; From 7348cff96ecf5659d77887a6576cf3e0e8ce64ac Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 11 Aug 2015 12:49:37 -0700 Subject: [PATCH 07/10] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 13007cd912..d62477d7bd 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,6 @@ TWITTER_TOKEN=stuff TWITTER_TOKEN_SECRET=stuff BLOGGER_KEY=stuff -SLACK_WEBHOOK=stuff SESSION_SECRET=secretstuff COOKIE_SECRET='this is a secret' From 6fd19738ce5c9b812f6cf3465153a757764a837b Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 11 Aug 2015 13:22:16 -0700 Subject: [PATCH 08/10] refactor and lint home router --- server/boot/home.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/server/boot/home.js b/server/boot/home.js index 1e40fb01a3..177a2eff2b 100644 --- a/server/boot/home.js +++ b/server/boot/home.js @@ -1,29 +1,29 @@ -var defaultProfileImage = - require('../../common/utils/constantStrings.json').defaultProfileImage; -var message = +import { defaultProfileImage } from '../../common/utils/constantStrings.json'; + +const message = 'Learn to Code JavaScript and get a Coding Job by Helping Nonprofits'; module.exports = function(app) { var router = app.loopback.Router(); - router.get('/', index); + router.get('/', addDefaultImage, index); app.use(router); - function index(req, res, next) { - if (req.user) - if (!req.user.picture) { - req.user.picture = defaultProfileImage; - - req.user.save(function (err) { - if (err) { - return next(err); - } - res.render('get-started', {title: message}); - }); - } else { - res.render('resources/get-started', {title: message}); - } else { - res.render('home', { title: message }); + function addDefaultImage(req, res, next) { + if (!req.user || req.user.picture) { + return next(); } + req.user.picture = defaultProfileImage; + req.user.save(function(err) { + if (err) { return next(err); } + next(); + }); + } + + function index(req, res) { + if (req.user) { + return res.render('resources/get-started', { title: message }); + } + res.render('home', { title: message }); } }; From 0fcf3bcf42214abae84db4919871496e2392c8ba Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 11 Aug 2015 14:17:08 -0700 Subject: [PATCH 09/10] fix challenge completion should give brownie points closes #1665 --- server/boot/challenge.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/boot/challenge.js b/server/boot/challenge.js index feea89818a..cbcc47e614 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -38,9 +38,10 @@ function updateUserProgress(user, challengeId, completedChallenge) { return id === challengeId; }); - if (alreadyCompleted) { + if (!alreadyCompleted) { user.progressTimestamps.push({ - timestamp: Date.now() + timestamp: Date.now(), + completedChallenge }); } user.completedChallenges.push(completedChallenge); From 08384864832c16b29cfba98cf82b29804d870922 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 11 Aug 2015 14:49:57 -0700 Subject: [PATCH 10/10] properly define id fields for basic models closes #1724 --- common/models/challenge.json | 4 ++++ common/models/job.json | 4 ++++ common/models/nonprofit.json | 4 ++++ common/models/story.json | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/common/models/challenge.json b/common/models/challenge.json index 08fa48779b..84cf3a4c6b 100644 --- a/common/models/challenge.json +++ b/common/models/challenge.json @@ -4,6 +4,10 @@ "idInjection": true, "trackChanges": false, "properties": { + "id": { + "type": "string", + "id": true + }, "name": { "type": "string", "index": { diff --git a/common/models/job.json b/common/models/job.json index 12473628cc..a3392fee82 100644 --- a/common/models/job.json +++ b/common/models/job.json @@ -4,6 +4,10 @@ "idInjection": true, "trackChanges": false, "properties": { + "id": { + "type": "string", + "id": true + }, "position": { "type": "string" }, diff --git a/common/models/nonprofit.json b/common/models/nonprofit.json index 5d8dddbc3d..d83bd55739 100644 --- a/common/models/nonprofit.json +++ b/common/models/nonprofit.json @@ -4,6 +4,10 @@ "idInjection": true, "trackChanges": false, "properties": { + "id": { + "type": "string", + "id": true + }, "name": { "type": "string", "index": { diff --git a/common/models/story.json b/common/models/story.json index 6f252cefb3..5d8e56dfb2 100644 --- a/common/models/story.json +++ b/common/models/story.json @@ -4,6 +4,10 @@ "idInjection": true, "trackChanges": false, "properties": { + "id": { + "type": "string", + "id": true + }, "name": { "type": "string", "index": {