Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging

This commit is contained in:
Quincy Larson
2015-08-11 23:54:15 -07:00
12 changed files with 68 additions and 31 deletions

View File

@ -98,7 +98,6 @@ TWITTER_TOKEN=stuff
TWITTER_TOKEN_SECRET=stuff TWITTER_TOKEN_SECRET=stuff
BLOGGER_KEY=stuff BLOGGER_KEY=stuff
SLACK_WEBHOOK=stuff
SESSION_SECRET=secretstuff SESSION_SECRET=secretstuff
COOKIE_SECRET='this is a secret' COOKIE_SECRET='this is a secret'

View File

@ -79,7 +79,7 @@ export default function(UserIdent) {
} }
// if user signed in with github refresh their info // 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"); debug("user isn't github cool or username from github is different");
setProfileFromGithub(user, profile, profile._json); setProfileFromGithub(user, profile, profile._json);
userChanged = true; userChanged = true;

View File

@ -4,6 +4,10 @@
"idInjection": true, "idInjection": true,
"trackChanges": false, "trackChanges": false,
"properties": { "properties": {
"id": {
"type": "string",
"id": true
},
"name": { "name": {
"type": "string", "type": "string",
"index": { "index": {
@ -22,6 +26,9 @@
"order": { "order": {
"type": "number" "type": "number"
}, },
"suborder": {
"type": "number"
},
"dashedName": { "dashedName": {
"type": "string" "type": "string"
}, },

View File

@ -4,6 +4,10 @@
"idInjection": true, "idInjection": true,
"trackChanges": false, "trackChanges": false,
"properties": { "properties": {
"id": {
"type": "string",
"id": true
},
"position": { "position": {
"type": "string" "type": "string"
}, },

View File

@ -4,6 +4,10 @@
"idInjection": true, "idInjection": true,
"trackChanges": false, "trackChanges": false,
"properties": { "properties": {
"id": {
"type": "string",
"id": true
},
"name": { "name": {
"type": "string", "type": "string",
"index": { "index": {

View File

@ -4,6 +4,10 @@
"idInjection": true, "idInjection": true,
"trackChanges": false, "trackChanges": false,
"properties": { "properties": {
"id": {
"type": "string",
"id": true
},
"name": { "name": {
"type": "string", "type": "string",
"index": { "index": {

View File

@ -1071,17 +1071,17 @@
"title": "Create a JavaScript Slot Machine", "title": "Create a JavaScript Slot Machine",
"difficulty":"9.988", "difficulty":"9.988",
"description":[ "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 <code>1</code> and <code>5</code> to represent the possible values of each individual slot", "For this we will need to generate three random numbers between <code>1</code> and <code>5</code> to represent the possible values of each individual slot",
"Store the three random numbers in <code>slotOne</code>, <code>slotTwo</code> and <code>slotThree</code>", "Store the three random numbers in <code>slotOne</code>, <code>slotTwo</code> and <code>slotThree</code>",
"Generate the random numbers by using the system we used earlier in /challenges/random-whole-numbers-in-a-range", "Generate the random numbers by using the system we used earlier in /challenges/random-whole-numbers-in-a-range",
"<code>Math.floor(Math.random() * (5 - 1 + 1)) + 1; </code>" "<code>Math.floor(Math.random() * (5 - 1 + 1)) + 1; </code>"
], ],
"tests":[ "tests":[
"assert(typeof(runSlots($('.slot'))[0]) == 'number', 'SlotOne 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'))[1]) == 'number', 'slotTwo should be a random number');",
"assert(typeof(runSlots($('.slot'))[2]) == 'number', 'SlotThree 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":[ "challengeSeed":[
"fccss", "fccss",

View File

@ -63,7 +63,8 @@ Challenge.destroyAll(function(err, info) {
.toLowerCase() .toLowerCase()
.replace(/\:/g, '') .replace(/\:/g, '')
.replace(/\s/g, '-'); .replace(/\s/g, '-');
challenge.order = +('' + order + (index + 1)); challenge.order = order;
challenge.suborder = index + 1;
challenge.block = block; challenge.block = block;
return challenge; return challenge;

View File

@ -38,9 +38,10 @@ function updateUserProgress(user, challengeId, completedChallenge) {
return id === challengeId; return id === challengeId;
}); });
if (alreadyCompleted) { if (!alreadyCompleted) {
user.progressTimestamps.push({ user.progressTimestamps.push({
timestamp: Date.now() timestamp: Date.now(),
completedChallenge
}); });
} }
user.completedChallenges.push(completedChallenge); user.completedChallenges.push(completedChallenge);
@ -458,7 +459,10 @@ module.exports = function(app) {
.map(camperCount => numberWithCommas(camperCount)); .map(camperCount => numberWithCommas(camperCount));
const query = { const query = {
order: 'order ASC' order: [
'order ASC',
'suborder ASC'
]
}; };
// create a stream of all the challenges // create a stream of all the challenges

View File

@ -1,29 +1,29 @@
var defaultProfileImage = import { defaultProfileImage } from '../../common/utils/constantStrings.json';
require('../../common/utils/constantStrings.json').defaultProfileImage;
var message = const message =
'Learn to Code JavaScript and get a Coding Job by Helping Nonprofits'; 'Learn to Code JavaScript and get a Coding Job by Helping Nonprofits';
module.exports = function(app) { module.exports = function(app) {
var router = app.loopback.Router(); var router = app.loopback.Router();
router.get('/', index); router.get('/', addDefaultImage, index);
app.use(router); app.use(router);
function index(req, res, next) { function addDefaultImage(req, res, next) {
if (req.user) if (!req.user || req.user.picture) {
if (!req.user.picture) { return next();
req.user.picture = defaultProfileImage;
req.user.save(function (err) {
if (err) {
return next(err);
} }
res.render('get-started', {title: message}); req.user.picture = defaultProfileImage;
req.user.save(function(err) {
if (err) { return next(err); }
next();
}); });
} else { }
res.render('resources/get-started', {title: message});
} else { function index(req, res) {
if (req.user) {
return res.render('resources/get-started', { title: message });
}
res.render('home', { title: message }); res.render('home', { title: message });
} }
}
}; };

View File

@ -141,5 +141,19 @@ module.exports = {
clientSecret: process.env.GITHUB_SECRET, clientSecret: process.env.GITHUB_SECRET,
scope: ['email'], scope: ['email'],
failureFlash: true 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
} }
}; };

View File

@ -102,7 +102,7 @@ var passportOptions = {
userObj.email = email; userObj.email = email;
} }
if (provider === 'github-login') { if (/github/.test(provider)) {
setProfileFromGithub(userObj, profile, profile._json); setProfileFromGithub(userObj, profile, profile._json);
} }
return userObj; return userObj;