Add .editorconfig to enforce certain automatic behavior on all editors,
Add logic for ziplines and basejumps completion.
This commit is contained in:
15
.editorconfig
Normal file
15
.editorconfig
Normal file
@ -0,0 +1,15 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[package.json]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
2
app.js
2
app.js
@ -438,6 +438,8 @@ app.get(
|
||||
coursewareController.returnIndividualCourseware
|
||||
);
|
||||
app.post('/completed-courseware/', coursewareController.completedCourseware);
|
||||
app.post('/completed-zipline-or-basejump',
|
||||
coursewareController.completedZiplineOrBasejump);
|
||||
|
||||
// Unique Check API route
|
||||
app.get('/api/checkUniqueUsername/:username', userController.checkUniqueUsername);
|
||||
|
@ -1,17 +1,9 @@
|
||||
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
|
||||
@ -103,13 +95,11 @@ 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,
|
||||
@ -129,25 +119,6 @@ exports.returnIndividualBonfire = function(req, res, next) {
|
||||
bonfireHash: bonfire._id,
|
||||
MDNkeys: bonfire.MDNlinks,
|
||||
MDNlinks: getMDNlinks(bonfire.MDNlinks)
|
||||
>>>>>>> upstream/master
|
||||
|
||||
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,
|
||||
progressTimestamps: req.user ? req.user.progressTimestamps : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
bonfires: bonfire,
|
||||
bonfireHash: bonfire._id
|
||||
});
|
||||
});
|
||||
};
|
||||
@ -189,7 +160,7 @@ function randomString() {
|
||||
|
||||
/**
|
||||
* Helper function to populate the MDN links array.
|
||||
*/
|
||||
*/
|
||||
|
||||
function getMDNlinks(links) {
|
||||
// takes in an array of links, which are strings
|
||||
|
@ -100,7 +100,8 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
environment: resources.whichEnvironment()
|
||||
environment: resources.whichEnvironment(),
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
@ -117,7 +118,7 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
@ -133,7 +134,7 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id,
|
||||
challengeType: 'video'
|
||||
challengeType: courseware.challengeType
|
||||
});
|
||||
},
|
||||
|
||||
@ -233,7 +234,9 @@ exports.completedCourseware = function (req, res, next) {
|
||||
req.user.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
completedDate: isCompletedDate,
|
||||
name: req.body.coursewareInfo.coursewareName
|
||||
name: req.body.coursewareInfo.coursewareName,
|
||||
solution: null,
|
||||
githubLink: null
|
||||
});
|
||||
var index = req.user.completedCoursewares.indexOf(coursewareHash);
|
||||
|
||||
@ -247,19 +250,26 @@ exports.completedCourseware = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
res.send(true);
|
||||
res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
var isCompletedWith = req.body.bonfireInfo.completedWith || false;
|
||||
debug('Inside controller for completed zipline or basejump with data %s',
|
||||
req.body.coursewareInfo);
|
||||
var isCompletedWith = req.body.coursewareInfo.completedWith || false;
|
||||
var isCompletedDate = Math.round(+new Date());
|
||||
var coursewareHash = req.body.coursewareInfo.coursewareHash;
|
||||
var solutionLink = req.body.coursewareInfo.solutionLink;
|
||||
if (!solutionLink) {
|
||||
// flash error and redirect
|
||||
return next(new Error('No solution provided'));
|
||||
var solutionLink = req.body.coursewareInfo.publicURL;
|
||||
var githubLink = req.body.coursewareInfo.challengeType === 4
|
||||
? req.body.coursewareInfo.githubURL : true;
|
||||
if (!solutionLink || !githubLink) {
|
||||
req.flash('errors', {
|
||||
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
||||
'your work.'
|
||||
});
|
||||
return res.sendStatus(403);
|
||||
}
|
||||
|
||||
if (isCompletedWith) {
|
||||
@ -286,14 +296,16 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
_id: coursewareHash,
|
||||
completedWith: req.user._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink
|
||||
});
|
||||
|
||||
req.user.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
completedWith: pairedWith._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
@ -305,7 +317,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
if (user && paired) {
|
||||
return res.send(true);
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -317,10 +329,11 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
_id: coursewareHash,
|
||||
completedWith: null,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink
|
||||
});
|
||||
|
||||
var index = req.user.uncompletedCourse.indexOf(coursewareHash);
|
||||
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
||||
if (index > -1) {
|
||||
req.user.progressTimestamps.push(Date.now() || 0);
|
||||
req.user.uncompletedCoursewares.splice(index, 1);
|
||||
@ -331,8 +344,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
debug('Saving user');
|
||||
return res.send(true);
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -347,7 +347,10 @@ var userSchema = new mongoose.Schema({
|
||||
{
|
||||
completedDate: Long,
|
||||
_id: String,
|
||||
name: String
|
||||
name: String,
|
||||
completedWith: String,
|
||||
solution: String,
|
||||
githubLink: String
|
||||
}
|
||||
],
|
||||
currentStreak: {
|
||||
|
@ -79,8 +79,13 @@ $(document).ready(function() {
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
});
|
||||
|
||||
$('#completed-zipline-or-basejump').on('click', function() {
|
||||
$('#complete-zipline-or-basejump-dialog').modal('show');
|
||||
});
|
||||
|
||||
|
||||
$('#complete-courseware-dialog').on('keypress', function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
if (e.ctrlKey && e.keyCode === 13) {
|
||||
$('#next-courseware-button').click();
|
||||
}
|
||||
});
|
||||
@ -108,6 +113,10 @@ $(document).ready(function() {
|
||||
$('#next-courseware-button').on('click', function() {
|
||||
console.log(passedCoursewareHash);
|
||||
if ($('.signup-btn-nav').length < 1) {
|
||||
switch (challengeType) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
$.post(
|
||||
'/completed-courseware/',
|
||||
{
|
||||
@ -122,6 +131,52 @@ $(document).ready(function() {
|
||||
}
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
var publicURL = $('#public-url').val() || null;
|
||||
$.post(
|
||||
'/completed-zipline-or-basejump/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName,
|
||||
completedWith: didCompleteWith,
|
||||
publicURL: publicURL,
|
||||
challengeType: challengeType
|
||||
}
|
||||
}).success(
|
||||
function() {
|
||||
window.location.href = '/challenges';
|
||||
}).fail(
|
||||
function() {
|
||||
window.location.href = '/challenges';
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
var publicURL = $('#public-url').val() || null;
|
||||
var githubURL = $('#github-url').val() || null;
|
||||
$.post(
|
||||
'/completed-zipline-or-basejump/',
|
||||
{
|
||||
coursewareInfo: {
|
||||
coursewareHash: passedCoursewareHash,
|
||||
coursewareName: passedCoursewareName,
|
||||
completedWith: didCompleteWith,
|
||||
publicURL: publicURl,
|
||||
githubURL: githubURL,
|
||||
challengeType: challengeType
|
||||
}
|
||||
}).success(function() {
|
||||
window.location.href = '/challenges';
|
||||
}).fail(function() {
|
||||
window.location.replace(window.location.href);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
@ -141,7 +196,7 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
|
||||
// Bonfire instructions functions
|
||||
// Bonfire instructions functions
|
||||
$('#more-info').on('click', function() {
|
||||
ga('send', 'event', 'Challenge', 'more-info', challengeName);
|
||||
$('#brief-instructions').hide();
|
||||
|
@ -148,16 +148,6 @@ block content
|
||||
include ../partials/bonfires
|
||||
|
||||
script.
|
||||
$.ajax({
|
||||
url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fbonfires%2F' + dashed + '&format=txt'
|
||||
})
|
||||
.success(
|
||||
function (data) {
|
||||
console.log(data);
|
||||
url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript";
|
||||
$('.btn-twitter').attr('href', url);
|
||||
}
|
||||
);
|
||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||
if (!MDNlinks.length) {
|
||||
$('#MDN-links').addClass('collapse');
|
||||
|
@ -60,6 +60,7 @@ block content
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var prodOrDev = !{JSON.stringify(environment)};
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var started = Math.floor(Date.now());
|
||||
.col-xs-12.col-sm-12.col-md-5.col-lg-6
|
||||
#mainEditorPanel
|
||||
|
@ -47,6 +47,7 @@ block content
|
||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var started = Math.floor(Date.now());
|
||||
|
||||
|
@ -27,6 +27,7 @@ block content
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var started = Math.floor(Date.now());
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
#complete-courseware-dialog.modal(tabindex='-1')
|
||||
.modal-dialog.animated.zoomIn.fast-animation
|
||||
.modal-content
|
||||
@ -46,8 +47,6 @@ block content
|
||||
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
|
||||
h1 #{name}
|
||||
script.
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
$('body').on('keypress', function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
|
@ -13,7 +13,7 @@ block content
|
||||
iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}')
|
||||
br
|
||||
- if (user)
|
||||
a.btn.btn-primary.btn-lg.btn-block#completed-courseware I've completed this challenge (ctrl + enter)
|
||||
a.btn.btn-primary.btn-lg.btn-block#completed-zipline-or-basejump I've completed this challenge (ctrl + enter)
|
||||
script.
|
||||
var userLoggedIn = true;
|
||||
- else
|
||||
@ -26,6 +26,7 @@ block content
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareName = challengeName;
|
||||
var started = Math.floor(Date.now());
|
||||
var challengeType = !{JSON.stringify(challengeType)};
|
||||
#complete-zipline-or-basejump-dialog.modal(tabindex='-1')
|
||||
.modal-dialog.animated.zoomIn.fast-animation
|
||||
.modal-content
|
||||
@ -42,7 +43,7 @@ block content
|
||||
|
||||
// extra field to distract password tools like lastpass from injecting css into our username field
|
||||
input.form-control(ng-show="false")
|
||||
if (challengeType === 'zipline')
|
||||
if (challengeType === 3)
|
||||
input.form-control#public-url(name="codepenUrl", placeholder="http://codepen.io/your-pen-here", autofocus)
|
||||
else
|
||||
input.form-control#public-url(name="depoloymentUrl", placeholder="http://yourapp.com", autofocus)
|
||||
@ -54,7 +55,7 @@ block content
|
||||
span.ion-close-circled
|
||||
| Username not found
|
||||
|
||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-bonfire-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next bonfire (ctrl + enter)
|
||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter)
|
||||
|
||||
|
||||
- if (user.progressTimestamps.length > 2)
|
||||
@ -64,10 +65,8 @@ block content
|
||||
- else
|
||||
a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress
|
||||
script.
|
||||
var challengeName = !{JSON.stringify(name)};
|
||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||
$('body').on('keypress', function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
$('#complete-zipline-or-basejump-dialog').modal('show');
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user