diff --git a/app.js b/app.js index 1cd47c6a8e..3d6e59fcc9 100644 --- a/app.js +++ b/app.js @@ -351,6 +351,16 @@ app.get('/nonprofits/your-nonprofit-project-application-has-been-submitted', non app.get('/nonprofits/other-solutions', nonprofitController.otherSolutions); +app.get( + '/nonprofits/:nonprofitName', + nonprofitController.returnIndividualNonprofit +); + +app.get( + '/nonprofits', + nonprofitController.showAllNonprofits +); + app.get( '/done-with-first-100-hours', passportConf.isAuthenticated, @@ -496,6 +506,8 @@ app.get('/bonfire', function(req, res) { res.redirect(301, '/playground'); }); +app.post('/completed-bonfire/', bonfireController.completedBonfire); + /** * Wiki related routes */ @@ -507,10 +519,9 @@ app.get( app.get( '/wiki', - wikiController.showAllWikis + wikiController.returnHomeWiki ); -app.post('/completed-bonfire/', bonfireController.completedBonfire); /** * Courseware related routes @@ -548,6 +559,7 @@ app.post('/account/delete', userController.postDeleteAccount); app.get('/account/unlink/:provider', userController.getOauthUnlink); app.get('/sitemap.xml', resourcesController.sitemap); + /** * OAuth sign-in routes. */ diff --git a/controllers/nonprofits.js b/controllers/nonprofits.js index 4ceda4de1e..502dd05b56 100644 --- a/controllers/nonprofits.js +++ b/controllers/nonprofits.js @@ -1,17 +1,8 @@ var async = require('async'), - User = require('../models/User'), - Challenge = require('./../models/Challenge'), - Bonfire = require('./../models/Bonfire'), - Story = require('./../models/Story'), - Comment = require('./../models/Comment'), resources = require('./resources.json'), - steps = resources.steps, secrets = require('./../config/secrets'), moment = require('moment'), - https = require('https'), debug = require('debug')('freecc:cntr:resources'), - cheerio = require('cheerio'), - request = require('request'), R = require('ramda'); exports.nonprofitsHome = function(req, res) { @@ -99,3 +90,39 @@ exports.otherSolutions = function(req, res) { title: 'Here are some other possible solutions for you' }); }; + +exports.returnIndividualNonprofit = function(req, res, next) { + var dashedName = req.params.nonprofitName; + + var nonprofitName = dashedName.replace(/\-/g, ' '); + + Nonprofit.find({'name': new RegExp(nonprofitName, 'i')}, function(err, nonprofit) { + if (err) { + next(err); + } + + if (nonprofit.length < 1) { + req.flash('errors', { + msg: "404: We couldn't find a nonprofit with that name. Please double check the name." + }); + + return res.redirect('/nonprofits'); + } + + nonprofit = nonprofit.pop(); + var dashedNameFull = nonprofit.name.toLowerCase().replace(/\s/g, '-'); + if (dashedNameFull != dashedName) { + return res.redirect('../nonprofit/' + dashedNameFull); + } + res.render('nonprofits/show', { + title: nonprofit.name, + description: nonprofit.description.join('') + }); + }); +}; + +exports.showAllNonprofits = function(req, res) { + var data = {}; + data.nonprofitList = resources.allNonprofitNames(); + res.send(data); +}; diff --git a/controllers/wiki.js b/controllers/wiki.js index f7bf1a22c4..360b748409 100644 --- a/controllers/wiki.js +++ b/controllers/wiki.js @@ -23,7 +23,7 @@ exports.returnIndividualWiki = function(req, res, next) { } wiki = wiki.pop(); - var dashedNameFull = wiki.name.toLowerCase().replace(/\s/g, '-'); + var dashedNameFull = wiki.name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, ''); if (dashedNameFull != dashedName) { return res.redirect('../wiki/' + dashedNameFull); } @@ -39,3 +39,31 @@ exports.showAllWikis = function(req, res) { data.wikiList = resources.allWikiNames(); res.send(data); }; + +exports.returnHomeWiki = function(req, res) { + var dashedName = req.params.wikiName; + + Wiki.find({'name': 'A Guide to our Wiki'}, function(err, wiki) { + if (err) { + next(err); + } + + if (wiki.length < 1) { + req.flash('errors', { + msg: "404: We couldn't find a wiki entry with that name. Please double check the name." + }); + + return res.redirect('/wiki'); + } + + wiki = wiki.pop(); + var dashedNameFull = wiki.name.toLowerCase().replace(/\s/g, '-'); + if (dashedNameFull != dashedName) { + return res.redirect('../wiki/' + dashedNameFull); + } + res.render('wiki/show', { + title: wiki.name, + description: wiki.description.join('') + }); + }); +}; diff --git a/package.json b/package.json index b535c5739b..f3209e0e29 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "method-override": "^2.3.0", "moment": "^2.8.4", "mongodb": "^1.4.33", - "mongoose": "^4.0.0", + "mongoose": "^4.0.1", "mongoose-long": "0.0.2", "morgan": "^1.5.0", "newrelic": "^1.13.3", diff --git a/seed_data/wikis.json b/seed_data/wikis.json index 853b3391bd..1236041247 100644 --- a/seed_data/wikis.json +++ b/seed_data/wikis.json @@ -1,4 +1,138 @@ [ + { + "_id": "bd7158d9c441eddfaeb5bdef", + "name": "A Guide to our Wiki", + "description": [ + "
", + "

We have a variety of resources to answer your many questions.

", + "

Click the \"Show all Wiki Articles\" button below and browse the topics we cover

" + ] + }, + { + "_id": "bd7158d9c440eddfaeb5bdef", + "name": "What will I learn, and in what sequence?", + "description": [ + "
", + "

First, you'll learn basic web design tools like:", + "

", + "

", + "

Then you'll learn computer science and the art of programming:", + "

", + "

", + "

You'll spend the last half of Free Code Camp using Agile Methodologies and Full Stack JavaScript to build projects for nonprofits:", + "

", + "

", + "
" + ] + }, + { + "_id": "bd7158d9c439eddfaeb5bdef", + "name": "Will I be ready to get a software engineer job after this?", + "description": [ + "
", + "

At the end of Free Code Camp, you will have pair programmed around 1,000 hours with dozens of other students, built a portfolio of projects that people are actively using, and a roster of glowing references from nonprofits you've helped. This is more coding than most coding bootcamps provide, and on average, 75% of bootcamp graduates get software engineering jobs within 6 months, and earn an average annual salary of $76,000.

", + " \"A", + "
", + "
" + ] + }, + { + "_id": "bd7158d9c434eddfaeb5bdef", + "name": "How long does Free Code Camp take?", + "description": [ + "
", + "

It takes about 1,000 hours of coding to develop the skills you'll need to get an entry level software engineering job. Most coding bootcamps try to jam all this into 12 weeks of intensive study. Free Code Camp is fully online, and there will always be other people at your skill level that you can pair program with, so you can learn at your own pace. Here are some example coding schedules:

", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "
Time budgetedHours per weekWeeks to complete
Weekends10 hours/week100 weeks (2 years)
Nights and Weekends20 hours/week50 weeks (1 year)
Full time40 hours/week25 weeks (6 months)
Traditional Bootcamp Pacing80 hours/week12 weeks (3 months)
", + "
", + "
" + ] + }, + { + "_id": "bd7158d9c438eddfaeb5bdef", + "name": "Why does Free Code Camp use JavaScript instead of Ruby or Python?", + "description": [ + "
", + "

Like JavaScript, Ruby and Python are high-level scripting languages that can be used for full stack web development. But even if you learned these languages, you'd still need to learn JavaScript. That's because JavaScript is the only language that runs in web browsers. JavaScript has been around for 20 years, and it is still growing in popularity. Because of this, JavaScript has more tools and online learning resources than any other language.

", + " \"A", + "
", + "
" + ] + }, + { + "_id": "bd7158d9c437eddfaeb5bdef", + "name": "What's pair programming, and what's so special about it?", + "description": [ + "
", + "

Pair programming is where two people code together on one computer. You discuss different approaches to solving problems, and keep each other motivated. The result is better code than either of you could have written by yourselves. Because of its benefits, many engineers pair program full time. And it's the best way to learn coding. Thanks to tools that allow two people to share mouse and keyboard inputs, you can pair program with a friend without needing to be in the same room.

", + "

By pair programming with other Free Code Camp students on our coding challenges. Eventually, you'll work with people at nonprofits to build real-life software solutions.

", + "
" + ] + }, + { + "_id": "bd7158d9c436eddfaeb5bdef", + "name": "If Free Code Camp is free, how does it make money?", + "description": [ + "
", + "

We are completely free for both students and for nonprofits.

", + "

Our name is Free Code Camp. We are a free code camp. If you had to pay us (or sign over future earnings), we'd have to change our name. And we are not going to do that.

", + "

We don't make any money at all. Everyone working on our community and our open source projects is a volunteer.

", + "

We plan to eventually cover our operational costs by earning job placement bonuses from companies who hire our graduates. Note that we will not actually garnish any wages from our graduates - employers are already paying recruiters thousands of dollars to find successful candidates. Employers will simply pay the recruitment bonus to Free Code Camp instead of paying a recruiter.

", + "
" + ] + }, + { + "_id": "bd7158d9c435eddfaeb5bdef", + "name": "Does Free Code Camp have an application process?", + "description": [ + "
", + "

Unlike coding bootcamps, anyone can study at Free Code Camp. We're not going to tell you that you can't become a software engineer. We believe the only person who should be able to tell you that is you.

", + "

If you persevere, and keep working through our challenges and nonprofit projects, you will become an employable software engineer.

", + "
" + ] + }, { "_id": "bd7158d9c442eddfaeb5bdef", "name": "Global Control Shortcuts for Mac", diff --git a/views/nonprofits/show.jade b/views/nonprofits/show.jade new file mode 100644 index 0000000000..d5628c415b --- /dev/null +++ b/views/nonprofits/show.jade @@ -0,0 +1,26 @@ +extends ../layout +block content + script. + var challengeName = 'Nonprofits View'; + .col-xs-12.col-sm-12.col-md-12 + .panel.panel-info + .panel-heading.text-center + h1= title + .panel-body + div!= description + .spacer + .text-center + #showAllButton.btn.btn-info.btn-big Show all Nonprofits Projects + .spacer + .row + .col-xs-12.text-center + if !user + a.btn.btn-cta.signup-btn.btn-primary(href="/login") Start learning to code (it's free) + .spacer + #all-challenges-dialog.modal(tabindex='-1') + .modal-dialog.animated.fadeInUp.fast-animation + .modal-content + .modal-header.all-list-header Nonprofit Projects + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body + include ../partials/nonprofits diff --git a/views/partials/nonprofits.jade b/views/partials/nonprofits.jade new file mode 100644 index 0000000000..1ffcb445c8 --- /dev/null +++ b/views/partials/nonprofits.jade @@ -0,0 +1,24 @@ +h3 + ol#nonprofitsList + script(src='/js/lib/ramda/ramda.min.js') + script. + var getLinkedName = function getLinkedName(name) { + // ensure name is a string + name = name + ''; + return name.toLowerCase().replace(/\s/g, '-'); + } + $.ajax({ + url: '/wiki/getNonprofitsList', + type: 'GET' + }) + .success( + function(data) { + var docfrag = document.createDocumentFragment(); + for (var i = 0; i < data.nonprofitsList.length; i++) { + var li = document.createElement("li"); + var linkedName = getLinkedName(data.nonprofitsList[i].name); + $(li).html("" + data.wikiList[i].name + ""); + docfrag.appendChild(li); + }; + $('#nonprofitsList').append(docfrag); + }); diff --git a/views/partials/wikis.jade b/views/partials/wikis.jade index be4fd2b3cd..99ec5c00b9 100644 --- a/views/partials/wikis.jade +++ b/views/partials/wikis.jade @@ -1,11 +1,11 @@ h3 - ol#bonfireList + ol#wikiList script(src='/js/lib/ramda/ramda.min.js') script. var getLinkedName = function getLinkedName(name) { // ensure name is a string name = name + ''; - return name.toLowerCase().replace(/\s/g, '-'); + return name.toLowerCase().replace(/\s/g, '-').replace(/\?/g, ''); } $.ajax({ url: '/wiki/getWikiList', @@ -20,5 +20,5 @@ h3 $(li).html("" + data.wikiList[i].name + ""); docfrag.appendChild(li); }; - $('#bonfireList').append(docfrag); + $('#wikiList').append(docfrag); });