Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -27,3 +27,4 @@ bower_components
|
||||
main.css
|
||||
bundle.js
|
||||
coverage
|
||||
.remote-sync.json
|
||||
|
@ -7,9 +7,9 @@ Welcome to Free Code Camp's open source codebase!
|
||||
=======================
|
||||
|
||||
#Note
|
||||
We're currently very close to moving from express to loopback. As such, please keep in mind that the instructions here for setting up and running the project do not directly translate to the staging branch. Additionally, the file structure is quite a bit different. As always, the staging branch is the appropriate place to branch off of to fix/add something!
|
||||
We're currently very close to moving from Express to Loopback. As such, please keep in mind that the instructions here for setting up and running the project do not directly translate to the staging branch. Additionally, the file structure is quite a bit different. As always, the staging branch is the appropriate place to branch off of to fix/add something!
|
||||
|
||||
Free Code Camp is an open-source community of busy people who learn to code, then build projects for nonprofits.
|
||||
Free Code Camp is an open-source community of busy people who learn to code, then build projects for nonprofits.
|
||||
|
||||
Our campers (students) start by working through our free, self-paced, browser-based curriculum. Next, they build several practice projects. Finally, we pair two campers together with a stakeholder from a nonprofit organization, and help them build the solution the nonprofit has requested.
|
||||
|
||||
@ -17,7 +17,7 @@ Our campers (students) start by working through our free, self-paced, browser-ba
|
||||
|
||||
80% of our campers are over 25, and nearly a fifth of our campers are women.
|
||||
|
||||
This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Slack](http://freecodecamp.slack.com), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp).
|
||||
This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We also have [Slack](http://freecodecamp.slack.com), a [blog](http://blog.freecodecamp.com), and even a [Twitch.tv channel](http://twitch.tv/freecodecamp).
|
||||
|
||||
[Join our community](http://www.freecodecamp.com/signin)!
|
||||
|
||||
@ -28,7 +28,7 @@ We welcome pull requests from Free Code Camp campers (our students) and seasoned
|
||||
|
||||
1. Check our [public Waffle Board](https://waffle.io/freecodecamp/freecodecamp).
|
||||
2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Slack](http://freecodecamp.slack.com).
|
||||
3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy.
|
||||
3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy.
|
||||
4. Create a branch specific to the issue or feature you are working on. Push your work to that branch. ([Need help with branching?](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches))
|
||||
5. Name the branch something like `user-xxx` where user is your username and xxx is the issue number you are addressing.
|
||||
6. You should have [ESLint running in your editor](http://eslint.org/docs/user-guide/integrations.html), and it will highlight anything doesn't conform to [AirBnB's JavaScript Style Guide](https://github.com/airbnb/javascript). Please do not ignore any linting errors, as they are meant to **help** you. Make sure none of your JavaScript is longer than 80 characters per line.
|
||||
|
@ -78,6 +78,8 @@ gulp.task('less', function() {
|
||||
.pipe(gulp.dest('./public/css/'));
|
||||
});
|
||||
|
||||
gulp.task('build', ['less']);
|
||||
|
||||
gulp.task('watch', ['less', 'serve', 'sync'], function() {
|
||||
gulp.watch('./public/css/*.less', ['less']);
|
||||
});
|
||||
|
@ -59,7 +59,7 @@
|
||||
"less": "~1.7.5",
|
||||
"less-middleware": "~2.0.1",
|
||||
"lodash": "^3.9.3",
|
||||
"loopback": "^2.18.0",
|
||||
"loopback": "https://github.com/FreeCodeCamp/loopback.git#fix/no-password",
|
||||
"loopback-boot": "^2.8.0",
|
||||
"loopback-component-passport": "git://github.com/FreeCodeCamp/loopback-component-passport.git#feature/emailOptional",
|
||||
"loopback-connector-mongodb": "^1.10.0",
|
||||
|
@ -2,9 +2,7 @@ require('dotenv').load();
|
||||
require('pmx').init();
|
||||
// handle uncaught exceptions. Forever will restart process on shutdown
|
||||
|
||||
var https = require('https'),
|
||||
sslConfig = require('./ssl-config'),
|
||||
R = require('ramda'),
|
||||
var R = require('ramda'),
|
||||
assign = require('lodash').assign,
|
||||
loopback = require('loopback'),
|
||||
boot = require('loopback-boot'),
|
||||
@ -54,10 +52,12 @@ app.use(compress());
|
||||
app.use(lessMiddleware(path.join(__dirname, '/public')));
|
||||
app.use(logger('dev'));
|
||||
app.use(bodyParser.json());
|
||||
app.use(bodyParser.urlencoded({ extended: true }));
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: true
|
||||
}));
|
||||
app.use(expressValidator({
|
||||
customValidators: {
|
||||
matchRegex: function (param, regex) {
|
||||
matchRegex: function(param, regex) {
|
||||
return regex.test(param);
|
||||
}
|
||||
}
|
||||
@ -145,8 +145,7 @@ app.use(helmet.csp({
|
||||
'https://cdn.inspectlet.com/inspectlet.js',
|
||||
'http://cdn.inspectlet.com/inspectlet.js'
|
||||
].concat(trusted),
|
||||
'connect-src': [
|
||||
].concat(trusted),
|
||||
'connect-src': [].concat(trusted),
|
||||
styleSrc: [
|
||||
'*.googleapis.com',
|
||||
'*.gstatic.com'
|
||||
@ -180,14 +179,16 @@ app.use(helmet.csp({
|
||||
|
||||
passportConfigurator.init();
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
app.use(function(req, res, next) {
|
||||
// Make user object available in templates.
|
||||
res.locals.user = req.user;
|
||||
next();
|
||||
});
|
||||
|
||||
app.use(
|
||||
loopback.static(path.join(__dirname, '../public'), { maxAge: 86400000 })
|
||||
loopback.static(path.join(__dirname, '../public'), {
|
||||
maxAge: 86400000
|
||||
})
|
||||
);
|
||||
|
||||
boot(app, {
|
||||
@ -195,7 +196,7 @@ boot(app, {
|
||||
dev: process.env.NODE_ENV
|
||||
});
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
app.use(function(req, res, next) {
|
||||
// Remember original destination before login.
|
||||
var path = req.path.split('/')[1];
|
||||
if (/auth|login|logout|signin|signup|fonts|favicon/i.test(path)) {
|
||||
@ -224,7 +225,8 @@ var passportOptions = {
|
||||
null;
|
||||
|
||||
var username = (profile.username || profile.id);
|
||||
username = typeof username === 'string' ? username.toLowerCase() : username;
|
||||
username = typeof username === 'string' ? username.toLowerCase() :
|
||||
username;
|
||||
var password = generateKey('password');
|
||||
var userObj = {
|
||||
username: username,
|
||||
@ -256,7 +258,9 @@ R.keys(passportProviders).map(function(strategy) {
|
||||
*/
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
app.use(errorHandler({ log: true }));
|
||||
app.use(errorHandler({
|
||||
log: true
|
||||
}));
|
||||
} else {
|
||||
app.use(pmx.expressErrorHandler());
|
||||
// error handling in production disabling eslint due to express parity rules
|
||||
@ -279,12 +283,16 @@ if (process.env.NODE_ENV === 'development') {
|
||||
|
||||
var message = 'opps! Something went wrong. Please try again later';
|
||||
if (type === 'html') {
|
||||
req.flash('errors', { msg: message });
|
||||
req.flash('errors', {
|
||||
msg: message
|
||||
});
|
||||
return res.redirect('/');
|
||||
// json
|
||||
} else if (type === 'json') {
|
||||
res.setHeader('Content-Type', 'application/json');
|
||||
return res.send({ message: message });
|
||||
return res.send({
|
||||
message: message
|
||||
});
|
||||
// plain text
|
||||
} else {
|
||||
res.setHeader('Content-Type', 'text/plain');
|
||||
@ -297,31 +305,14 @@ if (process.env.NODE_ENV === 'development') {
|
||||
* Start Express server.
|
||||
*/
|
||||
|
||||
var options = {
|
||||
key: sslConfig.privateKey,
|
||||
cert: sslConfig.certificate
|
||||
};
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
var server = https.createServer(options, app);
|
||||
console.log('https://' + process.env.HOST + ':' + process.env.PORT);
|
||||
server.listen(app.get('port'), function () {
|
||||
console.log(
|
||||
'FreeCodeCamp server listening on port %d in %s mode',
|
||||
app.get('port'),
|
||||
app.get('env')
|
||||
);
|
||||
app.emit('started', 'https://' + process.env.HOST + ':' + app.get('port'));
|
||||
});
|
||||
} else {
|
||||
app.listen(app.get('port'), function () {
|
||||
console.log(
|
||||
'FreeCodeCamp server listening on port %d in %s mode',
|
||||
app.get('port'),
|
||||
app.get('env')
|
||||
);
|
||||
});
|
||||
}
|
||||
app.listen(app.get('port'), function() {
|
||||
console.log(
|
||||
'FreeCodeCamp server listening on port %d in %s mode',
|
||||
app.get('port'),
|
||||
app.get('env')
|
||||
);
|
||||
});
|
||||
|
||||
// start the server if `$ node server.js`
|
||||
|
||||
|
Reference in New Issue
Block a user