diff --git a/app.js b/app.js index bd36ff727c..5f730fe264 100755 --- a/app.js +++ b/app.js @@ -299,9 +299,9 @@ app.get('/nodeschool-challenges', function(req, res) { app.get('/news', function(req, res) { res.redirect(301, '/stories/hot'); }); -app.get('/learn-to-code', resourcesController.about); +app.get('/learn-to-code', challengeMapController.challengeMap); app.get('/about', function(req, res) { - res.redirect(301, '/learn-to-code'); + res.redirect(301, '/map'); }); app.get('/signin', userController.getSignin); diff --git a/controllers/challengeMap.js b/controllers/challengeMap.js index b858bf7385..c6418b41c7 100644 --- a/controllers/challengeMap.js +++ b/controllers/challengeMap.js @@ -52,14 +52,36 @@ module.exports = { if (challenge.challengeType === 4) { return challenge } }); - res.render('challengeMap/show', { - title: "A map of all Free Code Camp's Challenges", - bonfires: bonfireList, - waypoints: waypoints, - ziplines: ziplines, - basejumps: basejumps, - completedBonfireList: completedBonfireList, - completedCoursewareList: completedCoursewareList + if (!req.user.profile.picture || req.user.profile.picture === "https://s3.amazonaws.com/freecodecamp/favicons/apple-touch-icon-180x180.png") { + req.user.profile.picture = "https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png"; + req.user.save(); + } + + function numberWithCommas(x) { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); + } + + var date1 = new Date("10/15/2014"); + var date2 = new Date(); + var timeDiff = Math.abs(date2.getTime() - date1.getTime()); + var daysRunning = Math.ceil(timeDiff / (1000 * 3600 * 24)); + + User.count({}, function (err, camperCount) { + if (err) { + debug('User err: ', err); + return next(err); + } + res.render('challengeMap/show', { + daysRunning: daysRunning, + camperCount: numberWithCommas(camperCount), + title: "A map of all Free Code Camp's Challenges", + bonfires: bonfireList, + waypoints: waypoints, + ziplines: ziplines, + basejumps: basejumps, + completedBonfireList: completedBonfireList, + completedCoursewareList: completedCoursewareList + }); }); } }; diff --git a/controllers/challenges.js b/controllers/challenges.js deleted file mode 100644 index 463edda920..0000000000 --- a/controllers/challenges.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * GET / - * Challenges. - */ -var _ = require('lodash'), - debug = require('debug')('freecc:cntr:challenges'), - Challenge = require('./../models/Challenge'), - resources = require('./resources'); - -var highestChallengeNumber = 53; - - -exports.returnNextChallenge = function(req, res) { - if (req.user) { - ch = req.user.challengesHash; - if (req.user.challengesHash[0] > 0) { - var max = Object.keys(ch).reduce(function(max, key) { - return (max === undefined || ch[key] > ch[max]) ? +key : max; - }); - nextChallenge = max + 1; - res.redirect('challenges/' + nextChallenge); - } else { - res.redirect('challenges/0'); - } - } else { - return res.redirect('../challenges/0'); - } -}; - -exports.returnChallenge = function(req, res, next) { - var challengeNumber = parseInt(req.params.challengeNumber) || 0; - - if (challengeNumber > highestChallengeNumber) { - req.flash('errors', { - msg: "It looks like you've either completed all the challenges we have available or requested a challenge we don't have." - }); - return res.redirect('../challenges/0'); - } - Challenge.find({}, null, { sort: { challengeNumber: 1 } }, function(err, c) { - if (err) { - debug('Challenge err: ', err); - return next(err); - } - res.render('challenges/show', { - title: 'Challenge: ' + c[challengeNumber].name, - name: c[challengeNumber].name, - video: c[challengeNumber].video, - time: c[challengeNumber].time, - steps: c[challengeNumber].steps, - number: challengeNumber, - cc: req.user ? req.user.challengesHash : undefined, - points: req.user ? req.user.points : undefined, - verb: resources.randomVerb(), - phrase: resources.randomPhrase(), - compliment: resources.randomCompliment(), - challenges: c - }); - }); -}; diff --git a/public/js/main.js b/public/js/main.js index 59905c18e3..ee6c9e1cb8 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -4,13 +4,6 @@ $(document).ready(function() { ga('send', 'event', 'Challenge', 'load', challengeName); } - // When introducing a new announcement, change the localStorage attribute - // and the HTML located in the footer - if (!localStorage || !localStorage.nodeSchoolAnnouncement) { - $('#announcementModal').modal('show'); - localStorage.fccShowAnnouncement = "true"; - } - var CSRF_HEADER = 'X-CSRF-Token'; var setCSRFToken = function(securityToken) { @@ -204,10 +197,6 @@ $(document).ready(function() { } }); - $('.all-challenges').on('click', function() { - $('#show-all-dialog').modal('show'); - }); - $('#showAllButton').on('click', function() { $('#show-all-dialog').modal('show'); }); @@ -217,7 +206,7 @@ $(document).ready(function() { window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1); }); -// Bonfire instructions functions + // Bonfire instructions functions $('#more-info').on('click', function() { ga('send', 'event', 'Challenge', 'more-info', challengeName); $('#brief-instructions').hide(); diff --git a/views/challengeMap/show.jade b/views/challengeMap/show.jade index 5c230072df..bd4a76ea7b 100644 --- a/views/challengeMap/show.jade +++ b/views/challengeMap/show.jade @@ -5,10 +5,19 @@ block content .panel-heading.text-center h1 Challenge Map .panel-body - .row - .col-xs-12.col-sm-12.col-md-10.col-md-offset-2 - h3 Complete all of these challenges from top to bottom. - h3 Then we'll assign you to your first nonprofit project. + .col-xs-12 + if (Math.random() > 0.99) + img.img-responsive.img-center(src='https://s3.amazonaws.com/freecodecamp/wide-social-banner-dino.png') + else + img.img-responsive.img-center(src='https://s3.amazonaws.com/freecodecamp/wide-social-banner.png') + .col-xs-12.col-md-8.col-md-offset-2 + h2.text-center + span.text-primary #{camperCount}   + | campers have joined our community + br + | since we launched   + span.text-primary #{daysRunning}   + | days ago. h2 span.fa.fa-flag |   Waypoints (200 hours of lessons) @@ -92,7 +101,7 @@ block content li a(href="/challenges/#{basejump.name}")= basejump.name h2 - span.ion-ios-heart   Nonprofit Projects (800 hours of real-world experience) + span.ion-ios-heart   Nonprofit Projects (800 hours of real-world experience)* h3.negative-15 ul .row @@ -101,3 +110,23 @@ block content .col-xs-12.col-sm-9.col-md-10 li a(href="/nonprofits/directory") Browse our nonprofit projects + p * Complete all Waypoints, Bonfires, Ziplines and Basejumps to be assigned your first nonprofit project + + //#announcementModal.modal(tabindex='-1') + // .modal-dialog + // .modal-content + // .modal-header.challenge-list-header We've updated our curriculum + // a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + // .modal-body + // h3.text-left We now have a 1,600 hour curriculum and tons of new challenges. Read more about it + // a(href='http://blog.freecodecamp.com', target='_blank') here + // | . + // a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='http://blog.freecodecamp.com/', target='_blank') Take me to the blog post. + // a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up! + //script. + // $(document).ready(function () { + // if (!localStorage || !localStorage.newCurriculum) { + // $('#announcementModal').modal('show'); + // localStorage.campWideMeeting = "true"; + // } + // }); diff --git a/views/challenges/show.jade b/views/challenges/show.jade deleted file mode 100644 index c2843bb107..0000000000 --- a/views/challenges/show.jade +++ /dev/null @@ -1,50 +0,0 @@ -extends ../layout -block content - .row - .col-sm-12.col-md-12.col-xs-12 - .panel.panel-primary - .panel-heading.text-center - h1 #{name} (takes #{time} minutes) - script. - var challengeName = null; - .panel.panel-body - .embed-responsive.embed-responsive-16by9 - iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}') - .col-xs-12.col-sm-10.col-sm-offset-1.col-md-8.col-md-offset-2 - h3 Steps: - h4 - ol - for step in steps - li!= step - .btn.btn-primary.btn-big.btn-block.completed-challenge I've completed this challenge - .ten-pixel-break - .btn.btn-success.btn-big.btn-block.all-challenges Show me all the challenges - #complete-challenge-dialog.modal(tabindex='-1') - .modal-dialog.animated.zoomIn.fast-animation - .modal-content - .modal-header.challenge-list-header= compliment - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - .modal-body - .text-center - .animated.zoomInDown.delay-half - span.completion-icon.ion-checkmark-circled.text-primary - - if (cc) - a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-challenge-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge - - if (points && points > 2) - a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank") - i.fa.fa-twitter   - = phrase - - else - a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress - - script. - $.ajax({ - url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fchallenges%2F' + !{JSON.stringify(number)} + '&format=txt' - }) - .success( - function (data) { - console.log(data); - url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Challenge:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript"; - $('.btn-twitter').attr('href', url); - } - ); diff --git a/views/partials/footer.jade b/views/partials/footer.jade index 3004dcbcf1..de503bde8f 100644 --- a/views/partials/footer.jade +++ b/views/partials/footer.jade @@ -4,7 +4,6 @@ a.ion-social-twitch-outline(href="/twitch")  Twitch  a.ion-social-github(href="http://github.com/freecodecamp", target='_blank')  Github   a.ion-social-twitter(href="http://twitter.com/freecodecamp", target='_blank')  Twitter   - a.ion-information-circled(href="/learn-to-code")  About   a.ion-locked(href="/privacy")  Privacy   .col-xs-12.visible-xs.visible-sm a.ion-speakerphone(href='http://blog.freecodecamp.com', target='_blank') @@ -15,7 +14,5 @@ span.sr-only Free Code Camp on GitHub a.ion-social-twitter(href="http://twitter.com/freecodecamp", target='_blank') span.sr-only Free Code Camp on Twitter - a.ion-information-circled(href="/learn-to-code") - span.sr-only About Free Code Camp a.ion-locked(href="/privacy") span.sr-only Free Code Camp's Privacy Policy diff --git a/views/partials/navbar-narrow.jade b/views/partials/navbar-narrow.jade index b8ff7267f9..8b13789179 100644 --- a/views/partials/navbar-narrow.jade +++ b/views/partials/navbar-narrow.jade @@ -1,3 +1 @@ -nav.navbar.navbar-default.navbar-fixed-top.nav-height - .container - include ./navbar \ No newline at end of file + diff --git a/views/resources/learn-to-code.jade b/views/resources/learn-to-code.jade index 9c87cf1a7a..59b9586ecc 100644 --- a/views/resources/learn-to-code.jade +++ b/views/resources/learn-to-code.jade @@ -63,21 +63,3 @@ block content .col-xs-12.github-and-twitter-button-text html. - //#announcementModal.modal(tabindex='-1') - // .modal-dialog - // .modal-content - // .modal-header.challenge-list-header Camp-wide Meeting on Saturday at Noon EST - // a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - // .modal-body - // h3.text-left We'll live-stream some of Free Code Camp's new features, and campers will show what they're building. Live Saturday, March 28 at Noon EST on our   - // a(href='http://twitch.tv/freecodecamp', target='_blank') Twitch.tv channel - // | . - // a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='http://twitch.tv/freecodecamp', target='_blank') Take me to Twitch so I can follow Free Code Camp - // a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up! - //script. - // $(document).ready(function () { - // if (!localStorage || !localStorage.campWideMeeting) { - // $('#announcementModal').modal('show'); - // localStorage.campWideMeeting = "true"; - // } - // });