From 3eb09ab63778ddb97eb69a4ef7f9374ac6297f04 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Mon, 22 Dec 2014 21:07:50 -0800 Subject: [PATCH] start reworking challenge views --- app.js | 1 - controllers/challenges.js | 15 +-- views/challenges/show.jade | 2 +- views/partials/challenges.jade | 185 +-------------------------------- 4 files changed, 14 insertions(+), 189 deletions(-) diff --git a/app.js b/app.js index 769101f0f31..976ab9b713c 100644 --- a/app.js +++ b/app.js @@ -195,7 +195,6 @@ app.post( app.get( '/challenges/:challengeNumber', - passportConf.isAuthenticated, challengesController.returnChallenge); app.all('/account', passportConf.isAuthenticated); app.get('/account', userController.getAccount); diff --git a/controllers/challenges.js b/controllers/challenges.js index 382aa369a53..83e5b09c58e 100644 --- a/controllers/challenges.js +++ b/controllers/challenges.js @@ -8,18 +8,19 @@ var _ = require('lodash'); exports.returnChallenge = function(req, res, next) { var challengeNumber = parseInt(req.params.challengeNumber) || 0; if (challengeNumber > 59) { challengeNumber = 0; } - Challenge.findOne({challengeNumber: challengeNumber}, function (err, c) { + Challenge.find({}, function (err, c) { if (err) { console.error('Challenge err: ', err); next(err); } res.render('challenges/show', { - title: 'Challenge: ' + c.name, - name: c.name, - video: c.video, - time: c.time, - steps: c.steps, - cc: req.user.challengesHash + title: 'Challenge: ' + c[challengeNumber].name, + name: c[challengeNumber].name, + video: c[challengeNumber].video, + time: c[challengeNumber].time, + steps: c[challengeNumber].steps, + cc: req.user ? req.user.challengesHash : undefined, + challenges: c }); }); }; \ No newline at end of file diff --git a/views/challenges/show.jade b/views/challenges/show.jade index 902730d664e..33f15599c92 100644 --- a/views/challenges/show.jade +++ b/views/challenges/show.jade @@ -15,7 +15,7 @@ block content .btn.btn-primary.btn-big.btn-block.completed-challenge I've completed this challenge .ten-pixel-break .btn.btn-success.btn-large.btn-block.skip-challenge I want to skip this challenge for now - - if (cc[2] > 0) + - if (cc && cc[2] > 0) .panel-footer.text-center span Need a break? Check out our:  a(href="https://gitter.im/FreeCodeCamp/FreeCodeCamp", target="_blank") Chat Room diff --git a/views/partials/challenges.jade b/views/partials/challenges.jade index 789a3eea865..d6a42bc96af 100644 --- a/views/partials/challenges.jade +++ b/views/partials/challenges.jade @@ -2,185 +2,10 @@ .panel-heading Challenges .panel-body ol(start='0') + for challenge in challenges li - a(href="/challenges/0", class="#{ cc[0] > 0 ? 'strikethrough' : '' }") Learn how Free Code Camp Works - |   (2 minutes) - li - a(href="/challenges/1", class="#{ cc[1] > 0 ? 'strikethrough' : '' }") Join Our Chat Room - |   (5 minutes) - li - a(href="/challenges/2", class="#{ cc[2] > 0 ? 'strikethrough' : '' }") Subscribe to Our Subreddit - |   (5 minutes) - li - a(href="/challenges/3", class="#{ cc[3] > 0 ? 'strikethrough' : '' }") Build a Personal Website - |   (60 minutes) - li - a(href="/challenges/4", class="#{ cc[4] > 0 ? 'strikethrough' : '' }") Build a Responsive Blog Theme - |   (60 minutes) - li - a(href="/challenges/5", class="#{ cc[5] > 0 ? 'strikethrough' : '' }") Build a Small Business Website - |   (60 minutes) - li - a(href="/challenges/6", class="#{ cc[6] > 0 ? 'strikethrough' : '' }") Tweak HTML and CSS in CodePen - |   (10 minutes) - li - a(href="/challenges/7", class="#{ cc[7] > 0 ? 'strikethrough' : '' }") Build a CSS Robot - |   (60 minutes) - li - a(href="/challenges/8", class="#{ cc[8] > 0 ? 'strikethrough' : '' }") Get Started with jQuery - |   (30 minutes) - li - a(href="/challenges/9", class="#{ cc[9] > 0 ? 'strikethrough' : '' }") Traverse the DOM - |   (30 minutes) - li - a(href="/challenges/10", class="#{ cc[10] > 0 ? 'strikethrough' : '' }") Work with the DOM - |   (30 minutes) - li - a(href="/challenges/11", class="#{ cc[11] > 0 ? 'strikethrough' : '' }") Listen for DOM Events - |   (30 minutes) - li - a(href="/challenges/12", class="#{ cc[12] > 0 ? 'strikethrough' : '' }") Use jQuery for Styling - |   (30 minutes) - li - a(href="/challenges/13", class="#{ cc[13] > 0 ? 'strikethrough' : '' }") Build a MadLibs Game - |   (60 minutes) - li - a(href="/challenges/14", class="#{ cc[14] > 0 ? 'strikethrough' : '' }") Discover Chrome's DevTools - |   (90 minutes) - li - a(href="/challenges/15", class="#{ cc[15] > 0 ? 'strikethrough' : '' }") Tackle jQuery Exercises - |   (60 minutes) - li - a(href="/challenges/16", class="#{ cc[16] > 0 ? 'strikethrough' : '' }") Customize Bootstrap - |   (10 minutes) - li - a(href="/challenges/17", class="#{ cc[17] > 0 ? 'strikethrough' : '' }") Inject Animation into CSS - |   (15 minutes) - li - a(href="/challenges/18", class="#{ cc[18] > 0 ? 'strikethrough' : '' }") Learn Basic Computer Science - |   (120 minutes) - li - a(href="/challenges/19", class="#{ cc[19] > 0 ? 'strikethrough' : '' }") Learn Loops - |   (120 minutes) - li - a(href="/challenges/20", class="#{ cc[20] > 0 ? 'strikethrough' : '' }") Learn Computer Hardware - |   (120 minutes) - li - a(href="/challenges/21", class="#{ cc[21] > 0 ? 'strikethrough' : '' }") Learn Computer Networking - |   (120 minutes) - li - a(href="/challenges/22", class="#{ cc[22] > 0 ? 'strikethrough' : '' }") Learn Boolean Logic - |   (120 minutes) - li - a(href="/challenges/23", class="#{ cc[23] > 0 ? 'strikethrough' : '' }") Learn Computer Security - |   (120 minutes) - li - a(href="/challenges/24", class="#{ cc[24] > 0 ? 'strikethrough' : '' }") Build an Adventure Game - |   (60 minutes) - li - a(href="/challenges/25", class="#{ cc[25] > 0 ? 'strikethrough' : '' }") Build Rock Paper Scissors - |   (60 minutes) - li - a(href="/challenges/26", class="#{ cc[26] > 0 ? 'strikethrough' : '' }") Learn JavaScript For Loops - |   (60 minutes) - li - a(href="/challenges/27", class="#{ cc[27] > 0 ? 'strikethrough' : '' }") Learn JavaScript While Loops - |   (60 minutes) - li - a(href="/challenges/28", class="#{ cc[28] > 0 ? 'strikethrough' : '' }") Learn Control Flow - |   (60 minutes) - li - a(href="/challenges/29", class="#{ cc[29] > 0 ? 'strikethrough' : '' }") Build a Contact List - |   (60 minutes) - li - a(href="/challenges/30", class="#{ cc[30] > 0 ? 'strikethrough' : '' }") Build an Address Book - |   (60 minutes) - li - a(href="/challenges/31", class="#{ cc[31] > 0 ? 'strikethrough' : '' }") Build a Cash Register - |   (60 minutes) - li - a(href="/challenges/32", class="#{ cc[32] > 0 ? 'strikethrough' : '' }") Get Help the Hacker Way - |   (30 minutes) - li - a(href="/challenges/33", class="#{ cc[33] > 0 ? 'strikethrough' : '' }") Learn Regular Expressions - |   (60 minutes) - li - a(href="/challenges/34", class="#{ cc[34] > 0 ? 'strikethrough' : '' }") Pair Program on CoderByte - |   (60 minutes) - li - a(href="/challenges/35", class="#{ cc[35] > 0 ? 'strikethrough' : '' }") Learn Relational Database Theory - |   (30 minutes) - li - a(href="/challenges/36", class="#{ cc[36] > 0 ? 'strikethrough' : '' }") Pair Program to Query SQL pt 1 - |   (90 minutes) - li - a(href="/challenges/37", class="#{ cc[37] > 0 ? 'strikethrough' : '' }") Pair Program to Query SQL pt 2 - |   (60 minutes) - li - a(href="/challenges/38", class="#{ cc[38] > 0 ? 'strikethrough' : '' }") Pair Program to modify SQL pt 1 - |   (90 minutes) - li - a(href="/challenges/39", class="#{ cc[39] > 0 ? 'strikethrough' : '' }") Pair Program to modify SQL pt 2 - |   (60 minutes) - li - a(href="/challenges/40", class="#{ cc[40] > 0 ? 'strikethrough' : '' }") Learn JSON - |   (30 minutes) - li - a(href="/challenges/41", class="#{ cc[41] > 0 ? 'strikethrough' : '' }") Manage Source Code with Git - |   (30 minutes) - li - a(href="/challenges/42", class="#{ cc[42] > 0 ? 'strikethrough' : '' }") Get Started with Node.js - |   (45 minutes) - li - a(href="/challenges/43", class="#{ cc[43] > 0 ? 'strikethrough' : '' }") Try Node.js Events - |   (45 minutes) - li - a(href="/challenges/44", class="#{ cc[44] > 0 ? 'strikethrough' : '' }") Try Node.js Streams - |   (45 minutes) - li - a(href="/challenges/45", class="#{ cc[45] > 0 ? 'strikethrough' : '' }") Learn how Node.js Modules Work - |   (45 minutes) - li - a(href="/challenges/46", class="#{ cc[46] > 0 ? 'strikethrough' : '' }") Start an Express.js Server - |   (45 minutes) - li - a(href="/challenges/47", class="#{ cc[47] > 0 ? 'strikethrough' : '' }") Use Socket.io - |   (45 minutes) - li - a(href="/challenges/48", class="#{ cc[48] > 0 ? 'strikethrough' : '' }") Use Redis to Persist Data - |   (45 minutes) - li - a(href="/challenges/49", class="#{ cc[49] > 0 ? 'strikethrough' : '' }") Dive Deeper into Express.js - |   (45 minutes) - li - a(href="/challenges/50", class="#{ cc[50] > 0 ? 'strikethrough' : '' }") Set up Express.js Middleware - |   (45 minutes) - li - a(href="/challenges/51", class="#{ cc[51] > 0 ? 'strikethrough' : '' }") Take Advantage of Parameters - |   (45 minutes) - li - a(href="/challenges/52", class="#{ cc[52] > 0 ? 'strikethrough' : '' }") Add the Body Parser - |   (45 minutes) - li - a(href="/challenges/53", class="#{ cc[53] > 0 ? 'strikethrough' : '' }") Configure Routes in Express.js - |   (45 minutes) - li - a(href="/challenges/54", class="#{ cc[54] > 0 ? 'strikethrough' : '' }") Try MongoDB - |   (30 minutes) - li - a(href="/challenges/55", class="#{ cc[55] > 0 ? 'strikethrough' : '' }") Get Started with Angular.js - |   (45 minutes) - li - a(href="/challenges/56", class="#{ cc[56] > 0 ? 'strikethrough' : '' }") Apply Angular.js Directives - |   (45 minutes) - li - a(href="/challenges/57", class="#{ cc[57] > 0 ? 'strikethrough' : '' }") Power Forms with Angular.js - |   (45 minutes) - li - a(href="/challenges/58", class="#{ cc[58] > 0 ? 'strikethrough' : '' }") Customize Angular.js Directives - |   (45 minutes) - li - a(href="/challenges/59", class="#{ cc[59] > 0 ? 'strikethrough' : '' }") Create Angular.js Services - |   (45 minutes) + a(href="/challenges/#{challenge.challengeNumber}", class="#{ (cc && cc[challenge.challengeNumber] > 0) ? 'strikethrough' : '' }") #{challenge.name} + |   (#{challenge.time} mins) - a.btn.btn-primary(href="/done-with-first-100-hours", class="#{ cc[59] > 0 ? '' : 'disabled' }") I've finished all Free Code Camp challenges and all the Easy and Medium CoderByte Challenges \ No newline at end of file + + a.btn.btn-primary(href="/done-with-first-100-hours", class="#{ cc && cc[59] > 0 ? 'disabled' : '' }") I've finished all Free Code Camp challenges and all the Easy and Medium CoderByte Challenges \ No newline at end of file