Merge branch 'master' of github.com:FreeCodeCamp/freecodecamp

This commit is contained in:
Quincy Larson
2015-05-26 09:08:43 -07:00
18 changed files with 61 additions and 44 deletions

View File

@ -110,7 +110,7 @@ Project Structure
| **models**/Challenge.js | Mongoose schema and model for Challenge. | | **models**/Challenge.js | Mongoose schema and model for Challenge. |
| **public**/ | Static assets (fonts, css, js, img). | | **public**/ | Static assets (fonts, css, js, img). |
| **public**/**js**/application.js | Specify client-side JavaScript dependencies. | | **public**/**js**/application.js | Specify client-side JavaScript dependencies. |
| **public**/**js**/main.js | Place your client-side JavaScript here. | | **public**/**js**/main_0.0.2.js | Place your client-side JavaScript here. |
| **public**/**css**/main.less | Main stylesheet for the app. | | **public**/**css**/main.less | Main stylesheet for the app. |
| **views/account**/ | Templates for *login, password reset, signup, profile*. | | **views/account**/ | Templates for *login, password reset, signup, profile*. |
| **views/partials**/flash.jade | Error, info and success flash notifications. | | **views/partials**/flash.jade | Error, info and success flash notifications. |

View File

@ -147,10 +147,12 @@ exports.returnCurrentChallenge = function(req, res, next) {
exports.returnIndividualChallenge = function(req, res, next) { exports.returnIndividualChallenge = function(req, res, next) {
var dashedName = req.params.challengeName; var dashedName = req.params.challengeName;
var challengeName = dashedName.replace(/\-/g, ' ') var challengeName = /^(bonfire|waypoint|zipline|basejump)/i.test(dashedName) ? dashedName
.replace(/\-/g, ' ')
.split(' ') .split(' ')
.slice(1) .slice(1)
.join(' '); .join(' ')
: dashedName.replace(/\-/g, ' ');
Challenge.find({'name': new RegExp(challengeName, 'i')}, Challenge.find({'name': new RegExp(challengeName, 'i')},
function(err, challengeFromMongo) { function(err, challengeFromMongo) {
@ -455,6 +457,8 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
var solutionLink = req.body.challengeInfo.publicURL; var solutionLink = req.body.challengeInfo.publicURL;
var githubLink = req.body.challengeInfo.challengeType === '4' var githubLink = req.body.challengeInfo.challengeType === '4'
? req.body.challengeInfo.githubURL : true; ? req.body.challengeInfo.githubURL : true;
var challengeType = req.body.challengeInfo.challengeType === '4' ?
4 : 3;
if (!solutionLink || !githubLink) { if (!solutionLink || !githubLink) {
req.flash('errors', { req.flash('errors', {
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' + msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
@ -485,6 +489,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
completedDate: isCompletedDate, completedDate: isCompletedDate,
solution: solutionLink, solution: solutionLink,
githubLink: githubLink, githubLink: githubLink,
challengeType: challengeType,
verified: false verified: false
}); });
@ -510,6 +515,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
completedDate: isCompletedDate, completedDate: isCompletedDate,
solution: solutionLink, solution: solutionLink,
githubLink: githubLink, githubLink: githubLink,
challengeType: challengeType,
verified: false verified: false
}); });
pairedWith.save(function (err, paired) { pairedWith.save(function (err, paired) {
@ -532,6 +538,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
completedDate: isCompletedDate, completedDate: isCompletedDate,
solution: solutionLink, solution: solutionLink,
githubLink: githubLink, githubLink: githubLink,
challengeType: challengeType,
verified: false verified: false
}); });

View File

@ -398,8 +398,8 @@ exports.returnUser = function(req, res, next) {
user.currentStreak = user.currentStreak || 1; user.currentStreak = user.currentStreak || 1;
user.longestStreak = user.longestStreak || 1; user.longestStreak = user.longestStreak || 1;
var challenges = user.completedCoursewares.filter(function ( obj ) { var challenges = user.completedChallenges.filter(function ( obj ) {
return !!obj.solution; return obj.challengeType === 3 || obj.challengeType === 4;
}); });
res.render('account/show', { res.render('account/show', {

View File

@ -56,7 +56,7 @@ var allTests = '';
}); });
})(); })();
var otherTestsForNow = "<script src='/js/lib/coursewares/iFrameScripts_0.0.1.js'></script>"; var otherTestsForNow = "<script src='/js/lib/coursewares/iFrameScripts_0.0.2.js'></script>";
var delay; var delay;
// Initialize CodeMirror editor with a nice html5 canvas demo. // Initialize CodeMirror editor with a nice html5 canvas demo.

View File

@ -194,7 +194,7 @@ var createTestDisplay = function() {
var expect = chai.expect; var expect = chai.expect;
var assert = chai.assert; var assert = chai.assert;
var should = chai.should; var should = chai.should();
var reassembleTest = function(test, data) { var reassembleTest = function(test, data) {

View File

@ -17,6 +17,7 @@ $(document).ready(function() {
setCSRFToken($('meta[name="csrf-token"]').attr('content')); setCSRFToken($('meta[name="csrf-token"]').attr('content'));
$('#i-want-help').on('click', function() { $('#i-want-help').on('click', function() {
/*
var editorValue = editor.getValue(); var editorValue = editor.getValue();
var currentLocation = window.location.href; var currentLocation = window.location.href;
$.post( $.post(
@ -33,9 +34,11 @@ $(document).ready(function() {
} }
} }
); );
*/
}); });
$('#i-want-help-editorless').on('click', function() { $('#i-want-help-editorless').on('click', function() {
/*
var currentLocation = window.location.href; var currentLocation = window.location.href;
$.post( $.post(
'/get-help', '/get-help',
@ -50,6 +53,7 @@ $(document).ready(function() {
} }
} }
); );
*/
}); });
$('#report-issue').on('click', function() { $('#report-issue').on('click', function() {

View File

@ -836,7 +836,7 @@
"expect(smallestCommons([1,5])).to.be.a('number');", "expect(smallestCommons([1,5])).to.be.a('number');",
"expect(smallestCommons([1,5])).to.equal(60);", "expect(smallestCommons([1,5])).to.equal(60);",
"expect(smallestCommons([5,1])).to.equal(60);", "expect(smallestCommons([5,1])).to.equal(60);",
"(smallestCommons([1,13])).should.equal(360360);" "expect(smallestCommons([1,13])).to.equal(360360);"
], ],
"MDNlinks" : ["Smallest Common Multiple"], "MDNlinks" : ["Smallest Common Multiple"],
"challengeType": 5 "challengeType": 5
@ -866,7 +866,7 @@
}, },
{ {
"_id": "a5deed1811a43193f9f1c841", "_id": "a5deed1811a43193f9f1c841",
"name": "Bonfire: Drop it like it's hot", "name": "Bonfire: Drop it",
"difficulty": "2.13", "difficulty": "2.13",
"description": [ "description": [
"Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.", "Drop the elements of an array (first argument), starting from the front, until the predicate (second argument) returns true.",

View File

@ -3,10 +3,20 @@ require('dotenv').load();
var User = require('../models/User.js'), var User = require('../models/User.js'),
secrets = require('../config/secrets'), secrets = require('../config/secrets'),
mongoose = require('mongoose'), mongoose = require('mongoose'),
R = require('ramda'); R = require('ramda'),
ziplines = require('./challenges/ziplines.json'),
basejumps = require('./challenges/basejumps.json');
mongoose.connect(secrets.db); mongoose.connect(secrets.db);
var ziplineIds = ziplines.challenges.map(function(elem) {
return elem._id;
});
var basejumpIds = basejumps.challenges.map(function(elem) {
return elem._id;
});
var ziplineAndBaseJumpIds = R.concat(ziplineIds, basejumpIds);
function userModelAssurity(cb) { function userModelAssurity(cb) {
console.log('userModelAssurity'); console.log('userModelAssurity');
var i = 1; var i = 1;
@ -91,23 +101,22 @@ function userModelMigration(cb) {
} }
*/ */
user.needsMigration = false; user.needsMigration = false;
user.completedChallenges = R.filter(function(elem) { user.completedChallenges = user.completedChallenges.map(function(elem) {
return elem; // getting rid of undefined if (ziplineAndBaseJumpIds.indexOf(elem._id) > 0) {
}, R.concat(
user.completedCoursewares,
user.completedBonfires.map(function(bonfire) {
return ({ return ({
completedDate: bonfire.completedDate, _id: elem._id,
_id: bonfire._id, name: elem.name,
name: bonfire.name, completedWith: elem.completedWith,
completedWith: bonfire.completedWith, completedDate: elem.completedDate,
solution: bonfire.solution, solution: elem.solution,
githubLink: '', githubLink: elem.githubLink,
verified: false, verified: elem.verified,
challengeType: 5 challengeType: typeof elem.githubLink === 'boolean' ? 4 : 3
});
} else {
return elem;
}
}); });
})
));
var self = this; var self = this;
user.save(function (err) { user.save(function (err) {

View File

@ -150,7 +150,7 @@ block content
td.col-xs-4= challenge.name td.col-xs-4= challenge.name
td.col-xs-2= moment(challenge.completedDate, 'x').format("MMM DD, YYYY") td.col-xs-2= moment(challenge.completedDate, 'x').format("MMM DD, YYYY")
td.col-xs-6 td.col-xs-6
a(href=challenge.solution, target='_blank') View my solution a(href="http://" + challenge.solution, target='_blank') View my solution
br br
- if (bonfires.length > 0) - if (bonfires.length > 0)

View File

@ -1,9 +1,6 @@
extends ../layout extends ../layout
block content block content
script. script.
var waypointList = !{JSON.stringify(waypoints)};
var ziplineList = !{JSON.stringify(ziplines)};
var basejumpList = !{JSON.stringify(basejumps)};
var completedChallenges = !{JSON.stringify(completedChallengeList)}; var completedChallenges = !{JSON.stringify(completedChallengeList)};
.panel.panel-info .panel.panel-info
.panel-heading.text-center .panel-heading.text-center

View File

@ -94,9 +94,9 @@ block content
if (user && user.sentSlackInvite) if (user && user.sentSlackInvite)
.button-spacer .button-spacer
.btn-group.input-group.btn-group-justified .btn-group.input-group.btn-group-justified
label.btn.btn-success#i-want-help label.btn.btn-success#i-want-help(disabled)
i.fa.fa-medkit i.fa.fa-medkit
| &nbsp; Help | &nbsp; Help(disabled)
label.btn.btn-success#i-want-to-pair label.btn.btn-success#i-want-to-pair
i.fa.fa-user-plus i.fa.fa-user-plus
| &nbsp; Pair | &nbsp; Pair
@ -125,7 +125,7 @@ block content
form.code form.code
.form-group.codeMirrorView .form-group.codeMirrorView
textarea#codeEditor(autofocus=true, style='display: none;') textarea#codeEditor(autofocus=true, style='display: none;')
script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.2.js') script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.4.js')
#complete-courseware-dialog.modal(tabindex='-1') #complete-courseware-dialog.modal(tabindex='-1')
.modal-dialog.animated.zoomIn.fast-animation .modal-dialog.animated.zoomIn.fast-animation

View File

@ -46,9 +46,9 @@ block content
if (user.sentSlackInvite) if (user.sentSlackInvite)
.button-spacer .button-spacer
.btn-group.input-group.btn-group-justified .btn-group.input-group.btn-group-justified
label.btn.btn-success#i-want-help label.btn.btn-success#i-want-help(disabled)
i.fa.fa-medkit i.fa.fa-medkit
| &nbsp; Help | &nbsp; Help(disabled)
label.btn.btn-success#report-issue label.btn.btn-success#report-issue
i.fa.fa-bug i.fa.fa-bug
| &nbsp; Bug | &nbsp; Bug
@ -91,4 +91,4 @@ block content
.animated.zoomInDown.delay-half .animated.zoomInDown.delay-half
span.completion-icon.ion-checkmark-circled.text-primary span.completion-icon.ion-checkmark-circled.text-primary
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script(src="/js/lib/coursewares/coursewaresHCJQFramework_0.1.2.js") script(src="/js/lib/coursewares/coursewaresHCJQFramework_0.1.3.js")

View File

@ -67,7 +67,7 @@ block content
form.code form.code
.form-group.codeMirrorView .form-group.codeMirrorView
textarea#codeEditor(autofocus=true, style='display: none;') textarea#codeEditor(autofocus=true, style='display: none;')
script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.2.js') script(src='/js/lib/coursewares/coursewaresJSFramework_0.0.4.js')
#complete-courseware-dialog.modal(tabindex='-1') #complete-courseware-dialog.modal(tabindex='-1')
.modal-dialog.animated.zoomIn.fast-animation .modal-dialog.animated.zoomIn.fast-animation
.modal-content .modal-content

View File

@ -23,9 +23,9 @@ block content
.button-spacer .button-spacer
if (user.sentSlackInvite) if (user.sentSlackInvite)
.btn-group.input-group.btn-group-justified .btn-group.input-group.btn-group-justified
.btn.btn-success.btn-big#i-want-help-editorless .btn.btn-success.btn-big#i-want-help-editorless(disabled)
i.fa.fa-medkit i.fa.fa-medkit
| &nbsp; Get help | &nbsp; Get help(disabled)
.btn.btn-success.btn-big#report-issue .btn.btn-success.btn-big#report-issue
i.fa.fa-bug i.fa.fa-bug
| &nbsp; Report a bug | &nbsp; Report a bug

View File

@ -21,9 +21,9 @@ block content
if (user.sentSlackInvite) if (user.sentSlackInvite)
.button-spacer .button-spacer
.btn-group.input-group.btn-group-justified .btn-group.input-group.btn-group-justified
.btn.btn-success.btn-big#i-want-help-editorless .btn.btn-success.btn-big#i-want-help-editorless(disabled)
i.fa.fa-medkit i.fa.fa-medkit
| &nbsp; Help | &nbsp; Help(disabled)
.btn.btn-success.btn-big#i-want-to-pair .btn.btn-success.btn-big#i-want-to-pair
i.fa.fa-user-plus i.fa.fa-user-plus
| &nbsp; Pair | &nbsp; Pair

View File

@ -23,7 +23,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
a(href='/chat', target='_blank') Chat a(href='/chat', target='_blank') Chat
else else
li li
a(href='/challenges/join-our-chat-room') Chat a(href='/challenges/waypoint-join-our-chat-room') Chat
li li
a(href='/news') News a(href='/news') News
li li

View File

@ -32,7 +32,7 @@ script.
window.moment || document.write('<script src="/bower_components/moment/min/moment.min.js"><\/script>'); window.moment || document.write('<script src="/bower_components/moment/min/moment.min.js"><\/script>');
// Leave the below lines alone! // Leave the below lines alone!
script(src="/js/main.js") script(src="/js/main_0.0.2.js")
script(src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js") script(src="/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js")