diff --git a/seed/challenges/getting-started.json b/seed/challenges/getting-started.json index c35c3541f8..23b43e6b59 100644 --- a/seed/challenges/getting-started.json +++ b/seed/challenges/getting-started.json @@ -242,7 +242,7 @@ [ "", "", - "Free Code Camp will always be free. If you want to feel more motivated to earn our certificates faster, we encourage you to instead donate each month to a nonprofit.", + "Free Code Camp will always be free. If you want to feel more motivated to earn our certificates faster, we encourage you to instead pledge to donate to a nonprofit each day.", "" ] ], diff --git a/server/boot/challenge.js b/server/boot/challenge.js index 6a056b705d..745f8be876 100644 --- a/server/boot/challenge.js +++ b/server/boot/challenge.js @@ -180,9 +180,9 @@ module.exports = function(app) { 'could not find challenge block for ' + challenge.block ); } - const nextBlock$ = blocks$.elementAt(blockIndex + 1); - const firstChallengeOfNextBlock$ = nextBlock$ - .map(block => block.challenges[0]); + const firstChallengeOfNextBlock$ = blocks$ + .elementAtOrDefault(blockIndex + 1, {}) + .map(({ challenges = [] }) => challenges[0]); return blocks$ .elementAt(blockIndex) @@ -211,6 +211,9 @@ module.exports = function(app) { }); }) .map(nextChallenge => { + if (!nextChallenge) { + return null; + } nextChallengeName = nextChallenge.dashedName; return nextChallengeName; }) @@ -267,12 +270,13 @@ module.exports = function(app) { } if (dasherize(challenge.name) !== origChallengeName) { - return Observable.just( - '/challenges/' + - dasherize(challenge.name) + - '?solution=' + - encodeURIComponent(solutionCode) - ); + let redirectUrl = `/challenges/${dasherize(challenge.name)}`; + + if (solutionCode) { + redirectUrl += `?solution=${encodeURIComponent(solutionCode)}`; + } + + return Observable.just(redirectUrl); } // save user does nothing if user does not exist diff --git a/server/boot/commit.js b/server/boot/commit.js new file mode 100644 index 0000000000..a54dc19506 --- /dev/null +++ b/server/boot/commit.js @@ -0,0 +1,15 @@ +export default function commit(app) { + const router = app.loopback.Router(); + router.get( + '/commit', + commitToNonprofit + ); + + app.use(router); + + function commitToNonprofit(req, res) { + res.render('commit/', { + title: 'Commit to a nonprofit. Commit to your goal.' + }); + } +} diff --git a/server/views/commit/index.jade b/server/views/commit/index.jade new file mode 100644 index 0000000000..ba15d37fc1 --- /dev/null +++ b/server/views/commit/index.jade @@ -0,0 +1,54 @@ +extends ../layout +block content + .panel.panel-info + .panel-body + h3.text-center Commit to yourself. Commit to a nonprofit. + .col-xs-12.col-sm-6.col-sm-offset-3 + p Are you looking for a burst of motivation? Do you want to help nonprofits before you’re ready to code for them? You can do both by pledging a monthly donation to a nonprofit until you've earned either your Front End or Full Stack Development certificate. Join Commit below or click "maybe later". + .col-xs-12.col-sm-6.col-sm-offset-3 + h4 Step 1: Choose your goal + .radio + label + input(type='radio' id='front-end-development-certificate' name='goal') + | Front End Development Certificate (takes about 400 hours) + .radio + label + input(type='radio' id='full-stack-development-certificate' name='goal') + | Full Stack Development Certificate (takes about 800 hours) + .spacer + h4 Step 2: Choose one of our nonprofits + .row + .col-xs-12.col-sm-6 + a(href="http://i.imgur.com/U1CyEuA.jpg" data-lightbox="img-enlarge") + img.img-responsive(src='http://i.imgur.com/U1CyEuA.jpg' alt="Girl Develop It participants coding at tables.") + .radio + label + input(type='radio' id='girl-develop-it' name='nonprofit') + | Girl Develop It is a nonprofit that provides in-person classes for women to learn to code. + .col-xs-12.col-sm-6 + a(href="http://i.imgur.com/NERytFF.jpg" data-lightbox="img-enlarge") + img.img-responsive(src='http://i.imgur.com/NERytFF.jpg' alt="Vets in Tech participants standing together at a conference.") + .radio + label + input(type='radio' id='vets-in-tech' name='nonprofit') + | Vets in Tech is a nonprofit that helps veterans prepare for tech jobs. + .spacer + h4 Step 3: Choose your monthly pledge + .radio + label + input(type='radio' id='5-dollar-pledge' name='pledge-amount') + | $5 per month + .radio + label + input(type='radio' id='10-dollar-pledge' name='pledge-amount') + | $10 per month + .radio + label + input(type='radio' id='50-dollar-pledge' name='pledge-amount') + | $50 per month + + .spacer + a.button.btn.btn-block.btn-primary(href='https://www.paypal.com/us/cgi-bin/webscr?cmd=_flow&SESSION=T3x0DY-bLMFXuhmjYZXs-BhmDoiXfuNh5BWad5VBcMomkkDSZY0b_-_W3HS&dispatch=5885d80a13c0db1f8e263663d3faee8d0b9dcb01a9b6dc564e45f62871326a5e') Commit + .button-spacer + a.button.btn.btn-block.btn-warning(href='/') Maybe later + .spacer