Merge branch 'ux-improvements' of https://github.com/terakilobyte/freecodecamp into terakilobyte-ux-improvements
Conflicts: controllers/bonfire.js controllers/resources.js public/js/main.js views/bonfire/show.jade
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
@ -440,6 +440,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);
|
||||
|
@ -3,6 +3,7 @@ var _ = require('lodash'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources'),
|
||||
MDNlinks = require('./../seed_data/bonfireMDNlinks'),
|
||||
R = require('ramda');
|
||||
MDNlinks = require('./../seed_data/bonfireMDNlinks');
|
||||
|
||||
@ -161,7 +162,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) {
|
||||
@ -275,6 +285,27 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
}
|
||||
pairedWith = pairedWith.pop();
|
||||
|
||||
|
||||
|
||||
req.user.completedCoursewares.push({
|
||||
_id: coursewareHash,
|
||||
completedWith: pairedWith._id,
|
||||
completedDate: isCompletedDate,
|
||||
solution: solutionLink,
|
||||
githubLink: githubLink
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
debug('this is the user object returned %s,' +
|
||||
' this is the req.user._id %s, ' +
|
||||
'this is the pairedWith._id %s', user, req.user._id, pairedWith._id);
|
||||
debug(req.user._id.toString() === pairedWith._id.toString());
|
||||
if (req.user._id.toString() === pairedWith._id.toString()) {
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
index = pairedWith.uncompletedCoursewares.indexOf(coursewareHash);
|
||||
if (index > -1) {
|
||||
pairedWith.progressTimestamps.push(Date.now() || 0);
|
||||
@ -286,26 +317,15 @@ 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
|
||||
});
|
||||
|
||||
req.user.save(function (err, user) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
pairedWith.save(function (err, paired) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if (user && paired) {
|
||||
return res.send(true);
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -317,10 +337,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 +352,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||
return next(err);
|
||||
}
|
||||
if (user) {
|
||||
debug('Saving user');
|
||||
return res.send(true);
|
||||
return res.sendStatus(200);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -176,6 +176,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") {
|
||||
@ -183,8 +198,9 @@ 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;
|
||||
|
||||
@ -231,6 +247,7 @@ module.exports = {
|
||||
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;
|
||||
@ -259,6 +276,7 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
randomPhrase: function() {
|
||||
var phrases = resources.phrases;
|
||||
return phrases[Math.floor(Math.random() * phrases.length)];
|
||||
|
@ -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,10 +79,8 @@ $(document).ready(function() {
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
});
|
||||
|
||||
$('#complete-courseware-dialog').on('keypress', function(e) {
|
||||
if (e.ctrlKey && e.keyCode == 13) {
|
||||
$('#next-courseware-button').click();
|
||||
}
|
||||
$('#completed-zipline-or-basejump').on('click', function() {
|
||||
$('#complete-zipline-or-basejump-dialog').modal('show');
|
||||
});
|
||||
|
||||
$('#complete-bonfire-dialog').on('hidden.bs.modal', function() {
|
||||
@ -101,13 +99,16 @@ $(document).ready(function() {
|
||||
editor.focus();
|
||||
});
|
||||
|
||||
|
||||
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
||||
editor.focus();
|
||||
});
|
||||
$('#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 +123,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 +188,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();
|
||||
@ -154,10 +201,6 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
var upvoteHandler = function () {
|
||||
if (typeof user == "undefined" || !user) {
|
||||
window.location.href = '/signin';
|
||||
return;
|
||||
}
|
||||
var _id = storyId;
|
||||
$('#upvote').unbind('click');
|
||||
var alreadyUpvoted = false;
|
||||
|
@ -15,7 +15,7 @@ block content
|
||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||
script(src='/js/lib/jailed/jailed.js')
|
||||
script(src='/js/lib/bonfire/bonfireInit.js')
|
||||
script(src="https://cdn.jsdelivr.net/ramda/0.10.0/ramda.min.js")
|
||||
script(src='/js/lib/ramda/ramda.min.js')
|
||||
|
||||
|
||||
.row
|
||||
@ -147,16 +147,6 @@ block content
|
||||
.modal-body
|
||||
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,8 +55,8 @@ 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)
|
||||
|
||||
if (user)
|
||||
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)
|
||||
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank")
|
||||
@ -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');
|
||||
}
|
||||
});
|
@ -1,5 +1,6 @@
|
||||
h3
|
||||
ol#bonfireList
|
||||
script(src='/js/lib/ramda/ramda.min.js')
|
||||
script.
|
||||
var getLinkedName = function getLinkedName(name) {
|
||||
return name.toLowerCase().replace(/\s/g, '-');
|
||||
|
Reference in New Issue
Block a user