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
BLOGGER_KEY=stuff
SLACK_WEBHOOK=stuff
SESSION_SECRET=secretstuff
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 (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;

View File

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

View File

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

View File

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

View File

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

View File

@ -1071,17 +1071,17 @@
"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 <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>",
"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>"
],
"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((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(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\\(\\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",

View File

@ -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;

View File

@ -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);
@ -458,7 +459,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

View File

@ -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 });
}
};

View File

@ -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
}
};

View File

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