Tab now inserts two spaces, the path "coursewares/" is no longer broken
This commit is contained in:
2
app.js
2
app.js
@ -289,7 +289,7 @@ app.post('/completed-bonfire/', bonfireController.completedBonfire);
|
||||
* Courseware related routes
|
||||
*/
|
||||
|
||||
app.get('/coursewares', coursewareController.returnNextCourseware);
|
||||
app.get('/coursewares/', coursewareController.returnNextCourseware);
|
||||
app.get(
|
||||
'/coursewares/:coursewareName',
|
||||
coursewareController.returnIndividualCourseware
|
||||
|
@ -58,33 +58,39 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
||||
next(err);
|
||||
}
|
||||
courseware = courseware.pop();
|
||||
|
||||
// Handle not found
|
||||
if (courseware.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a challenge with that name. Please double check the name."
|
||||
});
|
||||
return res.redirect('/coursewares')
|
||||
}
|
||||
|
||||
// Redirect to full name if the user only entered a partial
|
||||
var dashedNameFull = courseware.name.toLowerCase().replace(/\s/g, '-');
|
||||
if (dashedNameFull != dashedName) {
|
||||
return res.redirect('../coursewares/' + dashedNameFull);
|
||||
}
|
||||
if (courseware.length < 1) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a challenge with that name. Please double check the name."
|
||||
});
|
||||
return res.redirect('/coursewares')
|
||||
} else {
|
||||
res.render('coursewares/show', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
brief: courseware.description[0],
|
||||
details: courseware.description.slice(1),
|
||||
tests: courseware.tests,
|
||||
challengeSeed: courseware.challengeSeed,
|
||||
cc: !!req.user,
|
||||
points: req.user ? req.user.points : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id
|
||||
|
||||
});
|
||||
}
|
||||
// Render the view for the user
|
||||
res.render('coursewares/show', {
|
||||
title: courseware.name,
|
||||
dashedName: dashedName,
|
||||
name: courseware.name,
|
||||
brief: courseware.description[0],
|
||||
details: courseware.description.slice(1),
|
||||
tests: courseware.tests,
|
||||
challengeSeed: courseware.challengeSeed,
|
||||
cc: !!req.user,
|
||||
points: req.user ? req.user.points : undefined,
|
||||
verb: resources.randomVerb(),
|
||||
phrase: resources.randomPhrase(),
|
||||
compliment: resources.randomCompliment(),
|
||||
coursewareHash: courseware._id
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,15 @@ var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor")
|
||||
var editor = myCodeMirror;
|
||||
editor.setSize("100%", "auto");
|
||||
|
||||
// Hijack tab key to enter two spaces intead
|
||||
editor.setOption("extraKeys", {
|
||||
Tab: function(cm) {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
var attempts = 0;
|
||||
if (attempts) {
|
||||
|
@ -23,14 +23,22 @@ var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor")
|
||||
}
|
||||
});
|
||||
var editor = myCodeMirror;
|
||||
|
||||
|
||||
// Hijack tab key to insert two spaces instead
|
||||
editor.setOption("extraKeys", {
|
||||
Tab: function(cm) {
|
||||
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
});
|
||||
|
||||
editor.setSize("100%", "auto");
|
||||
|
||||
var libraryIncludes = "<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>" +
|
||||
"<script>document.domain = 'localhost'</script>" +
|
||||
"<script src='/js/lib/chai/chai.js'></script>" +
|
||||
"<script src='/js/lib/chai/chai-jquery.js'></script>" +
|
||||
"<script src='//ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js'></script>" +
|
||||
"<script src='//cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.0/ui-bootstrap-tpls.min.js'></script>" +
|
||||
"<script src='//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js'></script>" +
|
||||
"<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/animate.css/3.2.0/animate.min.css'/>" +
|
||||
"<link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'/>" +
|
||||
|
Reference in New Issue
Block a user