merge master in ux-improvements
This commit is contained in:
@ -1,9 +1,17 @@
|
||||
var _ = require('lodash'),
|
||||
<<<<<<< HEAD
|
||||
debug = require('debug')('freecc:cntr:bonfires'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources'),
|
||||
R = require('ramda');
|
||||
=======
|
||||
debug = require('debug')('freecc:cntr:bonfires'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources'),
|
||||
MDNlinks = require('./../seed_data/bonfireMDNlinks');
|
||||
>>>>>>> upstream/master
|
||||
|
||||
/**
|
||||
* Bonfire controller
|
||||
@ -95,11 +103,33 @@ exports.returnIndividualBonfire = function(req, res, next) {
|
||||
return res.redirect('/bonfires');
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
bonfire = bonfire.pop();
|
||||
var dashedNameFull = bonfire.name.toLowerCase().replace(/\s/g, '-');
|
||||
if (dashedNameFull != dashedName) {
|
||||
return res.redirect('../bonfires/' + dashedNameFull);
|
||||
}
|
||||
=======
|
||||
res.render('bonfire/show', {
|
||||
completedWith: null,
|
||||
title: bonfire.name,
|
||||
dashedName: dashedName,
|
||||
name: bonfire.name,
|
||||
difficulty: Math.floor(+bonfire.difficulty),
|
||||
brief: bonfire.description[0],
|
||||
details: bonfire.description.slice(1),
|
||||
tests: bonfire.tests,
|
||||
challengeSeed: bonfire.challengeSeed,
|
||||
cc: !!req.user,
|
||||
points: req.user ? req.user.points : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
bonfires: bonfire,
|
||||
bonfireHash: bonfire._id,
|
||||
MDNkeys: bonfire.MDNlinks,
|
||||
MDNlinks: getMDNlinks(bonfire.MDNlinks)
|
||||
>>>>>>> upstream/master
|
||||
|
||||
res.render('bonfire/show', {
|
||||
completedWith: null,
|
||||
@ -157,6 +187,23 @@ function randomString() {
|
||||
return randomstring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to populate the MDN links array.
|
||||
*/
|
||||
|
||||
function getMDNlinks(links) {
|
||||
// takes in an array of links, which are strings
|
||||
var populatedLinks = [];
|
||||
|
||||
// for each key value, push the corresponding link from the MDNlinks object into a new array
|
||||
links.forEach(function(value, index) {
|
||||
populatedLinks.push(MDNlinks[value]);
|
||||
});
|
||||
|
||||
return populatedLinks;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -161,6 +161,21 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
trelloCalls: function(req, res, next) {
|
||||
request('https://trello.com/1/boards/BA3xVpz9/cards?key=' + secrets.trello.key, function(err, status, trello) {
|
||||
if (err) { return next(err); }
|
||||
trello = (status && status.statusCode === 200) ? (JSON.parse(trello)) : "Can't connect to to Trello";
|
||||
res.end(JSON.stringify(trello));
|
||||
});
|
||||
},
|
||||
bloggerCalls: function(req, res, next) {
|
||||
request('https://www.googleapis.com/blogger/v3/blogs/2421288658305323950/posts?key=' + secrets.blogger.key, function (err, status, blog) {
|
||||
if (err) { return next(err); }
|
||||
blog = (status && status.statusCode === 200) ? JSON.parse(blog) : "Can't connect to Blogger";
|
||||
res.end(JSON.stringify(blog));
|
||||
});
|
||||
},
|
||||
|
||||
about: function(req, res, next) {
|
||||
if (req.user) {
|
||||
if (!req.user.profile.picture || req.user.profile.picture === "https://s3.amazonaws.com/freecodecamp/favicons/apple-touch-icon-180x180.png") {
|
||||
@ -168,54 +183,8 @@ module.exports = {
|
||||
req.user.save();
|
||||
}
|
||||
}
|
||||
var date1 = new Date('10/15/2014');
|
||||
var date1 = new Date("10/15/2014");
|
||||
var date2 = new Date();
|
||||
var progressTimestamps = req.user.progressTimestamps;
|
||||
var now = Date.now() || 0;
|
||||
|
||||
if (req.user.pointsNeedMigration) {
|
||||
var challengesHash = req.user.challengesHash;
|
||||
for (var key in challengesHash) {
|
||||
if (challengesHash[key] > 0) {
|
||||
req.user.progressTimestamps.push(challengesHash[key]);
|
||||
}
|
||||
}
|
||||
|
||||
var oldChallengeKeys = R.keys(req.user.challengesHash);
|
||||
|
||||
var updatedTimesFromOldChallenges = oldChallengeKeys.map(function(timeStamp) {
|
||||
if (timeStamp.toString().length !== 13) {
|
||||
timeStamp *= 1000;
|
||||
}
|
||||
return timeStamp;
|
||||
});
|
||||
|
||||
var newTimeStamps = R.map(function(timeStamp) {
|
||||
if (timeStamp.toString().length !== 13) {
|
||||
timeStamp *= 1000;
|
||||
}
|
||||
return timeStamp;
|
||||
}, req.user.progressTimestamps);
|
||||
|
||||
req.user.progressTimestamps = newTimeStamps;
|
||||
|
||||
|
||||
req.user.completedCoursewares = Array.zip(updatedTimesFromOldChallenges, coursewares,
|
||||
function(left, right) {
|
||||
return ({
|
||||
completedDate: left.timeStamp,
|
||||
_id: right._id,
|
||||
name: right.name
|
||||
});
|
||||
}).filter(function(elem) {
|
||||
return elem.completedDate !== 0;
|
||||
});
|
||||
req.user.pointsNeedMigration = false;
|
||||
req.user.save();
|
||||
}
|
||||
if (progressTimestamps[progressTimestamps.length - 1] <= (now - 43200)) {
|
||||
req.user.progressTimestamps.push(now);
|
||||
}
|
||||
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
|
||||
var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||
var announcements = resources.announcements;
|
||||
@ -244,6 +213,7 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
randomPhrase: function() {
|
||||
var phrases = resources.phrases;
|
||||
return phrases[Math.floor(Math.random() * phrases.length)];
|
||||
|
@ -1,6 +1,5 @@
|
||||
{
|
||||
"announcements": [
|
||||
["We'll live-stream our Camp-wide Meeting Saturday, March 27 at Noon EST. We'll show some of Free Code Camp's new features, and campers will show what they're building.", "http://twitch.tv/freecodecamp"],
|
||||
["Some of Code School's courses are no longer free. We're switching to NodeSchool.io for our Node.js and Express.js challenges.", "http://freecodecamp.com/nodeschool-challenges"],
|
||||
["Screen Hero is now free on Windows and Mac! Follow these special instructions to install it.", "http://freecodecamp.com/install-screenhero"]
|
||||
],
|
||||
|
Reference in New Issue
Block a user