Refactor routing, minor display tweaks

This commit is contained in:
Nathan Leniz
2015-01-27 20:12:51 -05:00
parent 547b9757b1
commit 3844542651
6 changed files with 132 additions and 120 deletions

80
app.js
View File

@ -265,7 +265,16 @@ app.get(
);
app.all('/account', passportConf.isAuthenticated);
app.get('/account/api', userController.getAccountAngular);
/**
* Bonfire related routes
*/
app.get('/playground', bonfireController.index);
app.get('/bonfires', bonfireController.returnNextBonfire);
app.get('/bonfire-json-generator', bonfireController.returnGenerator);
app.post('/bonfire-json-generator', bonfireController.generateChallenge);
app.get('/bonfire-challenge-generator', bonfireController.publicGenerator);
app.post('/bonfire-challenge-generator', bonfireController.testBonfire)
app.get(
'/bonfires/:bonfireName',
bonfireController.returnIndividualBonfire
@ -273,48 +282,8 @@ app.get(
app.get('/bonfire', function(req, res) {
res.redirect(301, '/playground');
});
app.get('/bonfires', bonfireController.returnNextBonfire);
app.get('/bonfire/generator', bonfireController.returnGenerator);
app.post('/bonfire/generator', bonfireController.generateChallenge);
app.get('/bonfire/public-generator', bonfireController.publicGenerator);
app.post('/bonfire/public-generator', bonfireController.testBonfire)
// Unique Check API route
app.get('/api/checkUniqueUsername/:username', userController.checkUniqueUsername);
app.get('/api/checkExistingUsername/:username', userController.checkExistingUsername);
app.get('/api/checkUniqueEmail/:email', userController.checkUniqueEmail);
app.get('/account', userController.getAccount);
app.post('/account/profile', userController.postUpdateProfile);
app.post('/account/password', userController.postUpdatePassword);
app.post('/account/delete', userController.postDeleteAccount);
app.get('/account/unlink/:provider', userController.getOauthUnlink);
/**
* API examples routes.
* accepts a post request. the challenge id req.body.challengeNumber
* and updates user.challengesHash & user.challengesCompleted
*
*/
app.post('/completed-challenge', function (req, res) {
req.user.challengesHash[parseInt(req.body.challengeNumber)] =
Math.round(+new Date() / 1000);
var timestamp = req.user.challengesHash;
var points = 0;
for (var key in timestamp) {
if (timestamp[key] > 0) {
points += 1;
}
}
req.user.points = points;
req.user.save();
});
app.post('/completed-bonfire/', function (req, res) {
// TODO: remove debug statement
debug(req.body.bonfireInfo, 'This is bonfire info we got from posted');
var isCompletedWith = req.body.bonfireInfo.completedWith || undefined;
var isCompletedDate = Math.round(+new Date() / 1000);
var bonfireHash = req.body.bonfireInfo.bonfireHash;
@ -376,6 +345,37 @@ app.post('/completed-bonfire/', function (req, res) {
});
// Unique Check API route
app.get('/api/checkUniqueUsername/:username', userController.checkUniqueUsername);
app.get('/api/checkExistingUsername/:username', userController.checkExistingUsername);
app.get('/api/checkUniqueEmail/:email', userController.checkUniqueEmail);
app.get('/account', userController.getAccount);
app.post('/account/profile', userController.postUpdateProfile);
app.post('/account/password', userController.postUpdatePassword);
app.post('/account/delete', userController.postDeleteAccount);
app.get('/account/unlink/:provider', userController.getOauthUnlink);
/**
* API examples routes.
* accepts a post request. the challenge id req.body.challengeNumber
* and updates user.challengesHash & user.challengesCompleted
*
*/
app.post('/completed-challenge', function (req, res) {
req.user.challengesHash[parseInt(req.body.challengeNumber)] =
Math.round(+new Date() / 1000);
var timestamp = req.user.challengesHash;
var points = 0;
for (var key in timestamp) {
if (timestamp[key] > 0) {
points += 1;
}
}
req.user.points = points;
req.user.save();
});
/**
* OAuth sign-in routes.
*/

View File

@ -39,8 +39,7 @@ body.top-and-bottom-margins {
}
body.no-top-and-bottom-margins {
padding-top: 50px;
margin-bottom: 40px;
margin: 70px 20px 50px 20px;
}
h1, h2 {
@ -624,13 +623,25 @@ form.code span {
}
div.CodeMirror-scroll {
padding-bottom: 40px;
padding-bottom: 30px;
}
.test-vertical-center {
margin-top: 15px;
}
.cm-s-monokai.CodeMirror {
border-radius: 5px;
}
.bonfire-flames {
margin-top: -20px;
margin-bottom: -2px;
}
.bonfire-top {
margin-top: -30px;
}
//uncomment this to see the dimensions of all elements outlined in red

View File

@ -1,6 +1,6 @@
/* Based on Sublime Text's Monokai theme */
.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2; border-radius: 5px; height: auto;}
.cm-s-monokai.CodeMirror {background: #272822; color: #f8f8f2; height: auto;}
.cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
.cm-s-monokai .CodeMirror-gutters {background: #272822; border-right: 0px;}
.cm-s-monokai .CodeMirror-guttermarker { color: white; }

View File

@ -4,9 +4,9 @@ block content
.col-md-offset-2.col-md-8.col-lg-offset-2.col-lg-8.text-center
h1 JSON generator for bonfire challenges - just fill the form out and get the correct format back
.col-xs-12.col-sm-12.col-md-offset-3.col-md-6.col-lg-offset-3-col-lg-6
.col-xs-12.col-sm-12.col-md-offset-1.col-md-10.col-lg-offset-1-col-lg-10
.panel
form.form-horizontal(method="POST", action="/bonfire/generator", name="bonfireInfo")
form.form-horizontal(method="POST", action="/bonfire-json-generator", name="bonfireInfo")
.form-group
label.col-sm-2.control-label(for='name') name:
.col-sm-10

View File

@ -2,10 +2,10 @@ extends ../layout
block content
.row
.col-md-offset-2.col-md-8.col-lg-offset-2.col-lg-8.text-center
h1 JSON generator for bonfire challenges - just fill the form out and get the correct format back
.col-xs-12.col-sm-12.col-md-offset-3.col-md-6.col-lg-offset-3-col-lg-6
h1 Welcome to the challenge generator. Test your ideas out and see them live in bonfire!
.col-xs-12.col-sm-12.col-md-offset-1.col-md-10.col-lg-offset-1-col-lg-10
.panel
form.form-horizontal(method="POST", action="/bonfire/public-generator", name="bonfireInfo")
form.form-horizontal(method="POST", action="/bonfire-challenge-generator", name="bonfireInfo")
.form-group
label.col-sm-2.control-label(for='name') name:
.col-sm-10

View File

@ -18,10 +18,11 @@ block content
.row
.col-xs-12.col-sm-12.col-md-3
.col-xs-12.col-sm-12.col-md-4.bonfire-top
#testCreatePanel
h2.text-center #{name}
h2.text-center
h2.text-center= name
h2.text-center.bonfire-flames
if (difficulty == "0")
i.ion-ios-flame-outline
i.ion-ios-flame-outline
@ -89,7 +90,7 @@ block content
var challengeSeed = !{JSON.stringify(challengeSeed)};
var challengeEntryPoint = !{JSON.stringify(challengeEntryPoint)};
var passedBonfireHash = !{JSON.stringify(bonfireHash)};
.col-xs-12.col-sm-12.col-md-9
.col-xs-12.col-sm-12.col-md-8
#mainEditorPanel
form.code
.form-group.codeMirrorView