From dbf8443430127fa30904bc670edec19b78189ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Floty=C5=84ski?= Date: Tue, 4 Aug 2015 15:00:22 +0200 Subject: [PATCH 01/18] Small Fix of Bootstrap waypoint challenge - Issue 1502 Changed second check for second class - 'btn-default' --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index c0b4014f93..8a796f709a 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -1743,7 +1743,7 @@ ], "tests": [ "assert($('.btn').length > 5, 'Apply the \"btn\" class to each of your button elements.')", - "assert($('.btn').length > 5, 'Apply the \"btn-default\" class to each of your button elements.')" + "assert($('.btn-default').length > 5, 'Apply the \"btn-default\" class to each of your button elements.')" ], "challengeSeed": [ "
", From c8488c84193f0f1592fc242cdfe7b1c774242184 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 4 Aug 2015 06:28:10 -0700 Subject: [PATCH 02/18] reremove extra middlewares from server file --- server/server.js | 169 ++--------------------------------------------- 1 file changed, 6 insertions(+), 163 deletions(-) diff --git a/server/server.js b/server/server.js index f8f6955e97..3c047934e5 100755 --- a/server/server.js +++ b/server/server.js @@ -3,30 +3,11 @@ var pmx = require('pmx'); pmx.init(); var assign = require('lodash').assign, - loopback = require('loopback'), - boot = require('loopback-boot'), - accepts = require('accepts'), - cookieParser = require('cookie-parser'), - compress = require('compression'), - session = require('express-session'), - expressState = require('express-state'), - logger = require('morgan'), - errorHandler = require('errorhandler'), - methodOverride = require('method-override'), - bodyParser = require('body-parser'), - helmet = require('helmet'), - MongoStore = require('connect-mongo')(session), - flash = require('express-flash'), - path = require('path'), - expressValidator = require('express-validator'), - lessMiddleware = require('less-middleware'), - - passportProviders = require('./passport-providers'), - rxMiddleware = require('./utils/rx').rxMiddleware, - /** - * API keys and Passport configuration. - */ - secrets = require('./../config/secrets'); + loopback = require('loopback'), + boot = require('loopback-boot'), + expressState = require('express-state'), + path = require('path'), + passportProviders = require('./passport-providers'); var generateKey = require('loopback-component-passport/lib/models/utils').generateKey; @@ -45,147 +26,9 @@ var passportConfigurator = new PassportConfigurator(app); app.set('port', process.env.PORT || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'jade'); - -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(expressValidator({ - customValidators: { - matchRegex: function(param, regex) { - return regex.test(param); - } - } -})); -app.use(methodOverride()); -app.use(cookieParser(secrets.cookieSecret)); -app.use(session({ - resave: true, - saveUninitialized: true, - secret: secrets.sessionSecret, - store: new MongoStore({ - url: secrets.db, - 'autoReconnect': true - }) -})); - -app.use(flash()); app.disable('x-powered-by'); + // adds passport initialization after session middleware phase is complete - -app.use(helmet.xssFilter()); -app.use(helmet.noSniff()); -app.use(helmet.frameguard()); -app.use(function(req, res, next) { - res.header('Access-Control-Allow-Origin', '*'); - res.header('Access-Control-Allow-Headers', - 'Origin, X-Requested-With, Content-Type, Accept' - ); - next(); -}); - -var trusted = [ - "'self'", - 'blob:', - '104.236.218.15', - '*.freecodecamp.com', - 'http://www.freecodecamp.com', - 'https://www.freecodecamp.com', - 'https://freecodecamp.com', - 'https://freecodecamp.org', - '*.freecodecamp.org', - // NOTE(berks): add the following as the blob above was not covering www - 'http://www.freecodecamp.org', - 'ws://freecodecamp.com/', - 'ws://www.freecodecamp.com/', - '*.gstatic.com', - '*.google-analytics.com', - '*.googleapis.com', - '*.google.com', - '*.gstatic.com', - '*.doubleclick.net', - '*.twitter.com', - '*.twitch.tv', - '*.twimg.com', - "'unsafe-eval'", - "'unsafe-inline'", - '*.bootstrapcdn.com', - '*.cloudflare.com', - 'https://*.cloudflare.com', - 'localhost:3001', - 'ws://localhost:3001/', - 'http://localhost:3001', - 'localhost:3000', - 'ws://localhost:3000/', - 'http://localhost:3000', - '127.0.0.1', - '127.0.0.1:3000', - 'ws://127.0.0.1:3000/', - 'http://127.0.0.1:3000', - '*.ionicframework.com', - 'https://syndication.twitter.com', - '*.youtube.com', - '*.jsdelivr.net', - 'https://*.jsdelivr.net', - '*.ytimg.com', - '*.bitly.com', - 'http://cdn.inspectlet.com/', - 'https://cdn.inspeclet.com/', - 'wss://inspectletws.herokuapp.com/', - 'http://hn.inspectlet.com/', - '*.googleapis.com', - '*.gstatic.com', - 'https://hn.inspectlet.com/', - 'http://*.github.com' -]; - -app.use(helmet.csp({ - defaultSrc: trusted, - scriptSrc: [ - '*.optimizely.com', - '*.aspnetcdn.com', - '*.d3js.org', - 'https://cdn.inspectlet.com/inspectlet.js', - 'http://cdn.inspectlet.com/inspectlet.js', - 'http://beta.freecodecamp.com' - ].concat(trusted), - 'connect-src': [ - 'vimeo.com' - ].concat(trusted), - styleSrc: [ - '*.googleapis.com', - '*.gstatic.com' - ].concat(trusted), - imgSrc: [ - /* allow all input since we have user submitted images for public profile*/ - '*' - ].concat(trusted), - fontSrc: [ - '*.googleapis.com', - '*.gstatic.com' - ].concat(trusted), - mediaSrc: [ - '*.amazonaws.com', - '*.twitter.com' - ].concat(trusted), - frameSrc: [ - '*.gitter.im', - '*.gitter.im https:', - '*.vimeo.com', - '*.twitter.com', - '*.ghbtns.com' - ].concat(trusted), - // set to true if you only want to report errors - reportOnly: false, - // set to true if you want to set all headers - setAllHeaders: false, - // set to true if you want to force buggy CSP in Safari 5 - safari5: false -})); - passportConfigurator.init(); boot(app, { From c05a936c8710e91f726f9504899d254046a3cba4 Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Tue, 4 Aug 2015 20:47:25 +0530 Subject: [PATCH 03/18] Update main.less to fix #1510 Update main.less to fix #1510. There was an alignment issue on Safari because of missing vendor prefix ```-webkit``` on ```transform``` on the ```.points-on-top``` class. --- public/css/main.less | 1 + 1 file changed, 1 insertion(+) diff --git a/public/css/main.less b/public/css/main.less index 68ffd44dc0..21e225994f 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -577,6 +577,7 @@ thead { margin: 0 auto; position: relative; top: 50%; + -webkit-transform: translateY(-50%); transform: translateY(-50%); } From ad46b72bd0d6ea2fdf22cdb5ff0c48eeabe15fb1 Mon Sep 17 00:00:00 2001 From: Nic Galluzzo Date: Tue, 4 Aug 2015 08:54:21 -0700 Subject: [PATCH 04/18] Update bootstrap.json --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index c0b4014f93..32b069f30d 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -12,7 +12,7 @@ "Bootstrap will figure out how wide your screen is and respond by resizing your HTML elements - hence the name Responsive Design.", "With responsive design, there is no need to design a mobile version of your website. It will look good on devices with screens of any width.", "You can add Bootstrap to any app just by including it with <link rel='stylesheet' href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'/> at the top of your HTML. But we've gone ahead and automatically added it to your Cat Photo App for you.", - "To get started, we should nest all of our HTML in a div element with the class \"fluid-container\"." + "To get started, we should nest all of our HTML in a div element with the class \"container-fluid\"." ], "tests": [ "assert($('div').hasClass('container-fluid'), 'Your div element should have the class \"row\"')", From 70c5bcea209bcf9037e29526d5005efe60557bc1 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 4 Aug 2015 10:52:41 -0700 Subject: [PATCH 05/18] fix error message string --- common/models/user.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/models/user.js b/common/models/user.js index e4f5360444..3c7e54cbb3 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -161,9 +161,9 @@ module.exports = function(User) { if (!username) { // Zalgo!! return nextTick(() => { - cb( - new TypeError('FCC: username should be a string but got %s', username) - ); + cb(new TypeError( + `username should be a string but got ${ username }` + )); }); } User.findOne({ where: { username } }, (err, user) => { @@ -171,7 +171,7 @@ module.exports = function(User) { return cb(err); } if (!user || user.username !== username) { - return cb(new Error('FCC: no user found for %s', username)); + return cb(new Error(`no user found for ${ username }`)); } const aboutUser = getAboutProfile(user); return cb(null, aboutUser); From ecacbc623391a9b7227d78eeb9b28701bfb30d42 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 4 Aug 2015 14:03:19 -0500 Subject: [PATCH 06/18] Update bootstrap.json fixed typo (misspelled 'container') --- seed/challenges/bootstrap.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seed/challenges/bootstrap.json b/seed/challenges/bootstrap.json index c0b4014f93..a54c808017 100644 --- a/seed/challenges/bootstrap.json +++ b/seed/challenges/bootstrap.json @@ -1566,7 +1566,7 @@ "difficulty": 2.18, "description": [ "Now let's make sure all the content on your page is mobile-responsive.", - "Let's nest your h3 element within a div element with the class \"containter-fluid\"." + "Let's nest your h3 element within a div element with the class \"container-fluid\"." ], "tests": [ "assert($('div').hasClass('container-fluid'), 'Your div element should have the class \"container-fluid\"')", From 2dc9934da2b5f5d66bf63d5e012cd9a58bc25e92 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 4 Aug 2015 13:39:59 -0700 Subject: [PATCH 07/18] add user.isGithubCool check if user signs up with github, they become GithubCool. --- common/models/user.json | 43 ++++------------------------------------- server/server.js | 3 +++ 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/common/models/user.json b/common/models/user.json index aeb02b6397..940777a5a4 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -19,28 +19,14 @@ "password": { "type": "string" }, - "facebook": { - "type": "string" - }, - "twitter": { - "type": "string" - }, - "google": { - "type": "string" - }, - "github": { - "type": "string" - }, - "linkedin": { - "type": "string" - }, - "tokens": { - "type": "array" - }, "progressTimestamps": { "type": "array", "default": [] }, + "isGithubCool": { + "type": "boolean", + "default": false + }, "username": { "type": "string", "lowercase": true, @@ -123,12 +109,6 @@ "type": "string", "default": "" }, - "resetPasswordToken": { - "type": "string" - }, - "resetPasswordExpires": { - "type": "string" - }, "completedBonfires": { "type": [ { @@ -170,21 +150,10 @@ "type": "number", "default": 0 }, - "needsSomeDataModeled": { - "type": "boolean", - "default": false - }, - "needsMigration": { - "type": "boolean", - "default": true - }, "sendMonthlyEmail": { "type": "boolean", "default": true }, - "challengesHash": { - "type": {} - }, "currentChallenge": { "type": {} }, @@ -205,10 +174,6 @@ } ], "default": [] - }, - "uncompletedChallenges": { - "type": "array", - "default": [] } }, "validations": [], diff --git a/server/server.js b/server/server.js index 3c047934e5..93b0a1a322 100755 --- a/server/server.js +++ b/server/server.js @@ -65,6 +65,9 @@ var passportOptions = { if (email) { userObj.email = email; } + if (provider === 'github-login') { + userObj.isGithubCool = true; + } return userObj; } }; From 0682857236b921251e5c8097b1016ab746eda1c9 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 14:40:47 -0700 Subject: [PATCH 08/18] remove learn link from navbar --- server/views/partials/navbar.jade | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/views/partials/navbar.jade b/server/views/partials/navbar.jade index b0667a59f3..3c5b4c4d05 100644 --- a/server/views/partials/navbar.jade +++ b/server/views/partials/navbar.jade @@ -7,10 +7,6 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height img.img-responsive.nav-logo(src='https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg.gz', alt='learn to code javascript at Free Code Camp logo') .collapse.navbar-collapse ul.nav.navbar-nav.navbar-right.hamburger-dropdown - - if user - li - a(href='/challenges') Learn li a(href='/map') Map li @@ -18,7 +14,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height li a(href='/news') News li - a(href='//github.com/FreeCodeCamp/freecodecamp/wiki/Home') Wiki + a(href='//github.com/FreeCodeCamp/freecodecamp/wiki/Home', taregt='_blank') Wiki if !user li       li From 9196d1c48ececf281e767cfbcb566571e9b4653a Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 4 Aug 2015 14:52:06 -0700 Subject: [PATCH 09/18] add github check on login with github. --- common/models/User-Identity.js | 38 ++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/common/models/User-Identity.js b/common/models/User-Identity.js index 720e98b44a..781ea7d0ac 100644 --- a/common/models/User-Identity.js +++ b/common/models/User-Identity.js @@ -1,14 +1,16 @@ -var debug = require('debug')('freecc:models:userIdent'); +import debugFactory from 'debug'; -var defaultProfileImage = - require('../utils/constantStrings.json').defaultProfileImage; +const debug = debugFactory('freecc:models:userIdent'); + +const { defaultProfileImage } = require('../utils/constantStrings.json'); function getFirstImageFromProfile(profile) { return profile && profile.photos && profile.photos[0] ? profile.photos[0].value : null; } -module.exports = function(UserIdent) { + +export default function(UserIdent) { UserIdent.observe('before save', function(ctx, next) { var userIdent = ctx.currentInstance || ctx.instance; if (!userIdent) { @@ -16,13 +18,14 @@ module.exports = function(UserIdent) { return next(); } userIdent.user(function(err, user) { + let userChanged = false; if (err) { return next(err); } if (!user) { debug('no user attached to identity!'); return next(); } - var picture = getFirstImageFromProfile(userIdent.profile); + const picture = getFirstImageFromProfile(userIdent.profile); debug('picture', picture, user.picture); // check if picture was found @@ -34,15 +37,32 @@ module.exports = function(UserIdent) { (!user.picture || user.picture === defaultProfileImage) ) { debug('setting user picture'); - user.picture = userIdent.profile.photos[0].value; + user.picture = picture; + userChanged = true; + } + + // if user is not github cool + // and user signed in with github + // then make them github cool + // and set their username from their github profile. + if (!user.isGithubCool && userIdent.provider === 'github-login') { + debug(` + user isn't github cool yet but signed in with github + lets make them cool! + `); + user.isGithubCool = true; + user.username = userIdent.profile.username.toLowerCase(); + userChanged = true; + } + + if (userChanged) { return user.save(function(err) { if (err) { return next(err); } next(); }); } - - debug('exiting after user ident'); + debug('exiting after user identity before save'); next(); }); }); -}; +} From c573caf2e22acc2fa50fa4c353c852ea91bda19f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 14:57:34 -0700 Subject: [PATCH 10/18] remove website links from user model and account view --- common/models/user.json | 36 ----------- server/views/account/account.jade | 99 ------------------------------- 2 files changed, 135 deletions(-) diff --git a/common/models/user.json b/common/models/user.json index 940777a5a4..d055e431ff 100644 --- a/common/models/user.json +++ b/common/models/user.json @@ -73,42 +73,6 @@ "type": "string", "default": "" }, - "website1Link": { - "type": "string", - "default": "" - }, - "website1Title": { - "type": "string", - "default": "" - }, - "website1Image": { - "type": "string", - "default": "" - }, - "website2Link": { - "type": "string", - "default": "" - }, - "website2Title": { - "type": "string", - "default": "" - }, - "website2Image": { - "type": "string", - "default": "" - }, - "website3Link": { - "type": "string", - "default": "" - }, - "website3Title": { - "type": "string", - "default": "" - }, - "website3Image": { - "type": "string", - "default": "" - }, "completedBonfires": { "type": [ { diff --git a/server/views/account/account.jade b/server/views/account/account.jade index 436651c1e0..266ff57fbf 100644 --- a/server/views/account/account.jade +++ b/server/views/account/account.jade @@ -158,105 +158,6 @@ block content span.ion-edit | Update my Social Links - .col-sm-4.col-sm-offset-5.negative-bottom - h2 Portfolio - - .col-sm-4.col-sm-offset-5.flat-top - h3 First Portfolio Project - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website1Title') Title - .col-sm-4 - input.form-control(type='text', name='website1Title', id='website1Title', autocomplete="off", ng-model='user.website1Title', ng-maxlength='140') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.website1Title.$error.maxlength && !profileForm.website1Title.$pristine") - alert(type='danger') - span.ion-close-circled - | Portfolio project title must be fewer than 140 characters. - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website1Link') Link - .col-sm-4 - input.form-control(type='url', name='website1Link', id='website1Link', autocomplete="off", ng-model='user.website1Link', placeholder='http://') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.website1Link.$error.url && !profileForm.website1Link.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com). - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website1Image') Image Link (4:3 ratio) - .col-sm-4 - input.form-control(type='url', name='website1Image', id='website1Image', autocomplete="off", ng-model='user.website1Image', placeholder='http://www.example.com/image.jpg') - .col-sm-4.col-sm-offset-5(ng-show="profileForm.website1Image.$error.url && !profileForm.website1Image.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com/image.jpg). - - .col-sm-4.col-sm-offset-5.flat-top - h3 Second Portfolio Project - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website2Title') Title - .col-sm-4 - input.form-control(type='text', name='website2Title', id='website2Title', autocomplete="off", ng-model='user.website2Title', ng-maxlength='140') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.website2Title.$error.maxlength && !profileForm.website2Title.$pristine") - alert(type='danger') - span.ion-close-circled - | Portfolio project title must be fewer than 140 characters. - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website2Link') Link - .col-sm-4 - input.form-control(type='url', name='website2Link', id='website2Link', autocomplete="off", ng-model='user.website2Link', placeholder='http://') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.website2Link.$error.url && !profileForm.website2Link.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com). - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website2Image') Image Link (4:3 ratio) - .col-sm-4 - input.form-control(type='url', name='website2Image', id='website2Image', autocomplete="off", ng-model='user.website2Image', placeholder='http://www.example.com/image.jpg') - .col-sm-4.col-sm-offset-5(ng-show="profileForm.website2Image.$error.url && !profileForm.website2Image.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com/image.jpg). - - .col-sm-4.col-sm-offset-5.flat-top - h3 Third Portfolio Project - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website3Title') Title - .col-sm-4 - input.form-control(type='text', name='website3Title', id='website3Title', autocomplete="off", ng-model='user.website3Title', ng-maxlength='140') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.website3Title.$error.maxlength && !profileForm.website3Title.$pristine") - alert(type='danger') - span.ion-close-circled - | Portfolio project title must be fewer than 140 characters. - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website3Link') Link - .col-sm-4 - input.form-control(type='url', name='website3Link', id='website3Link', autocomplete="off", ng-model='user.website3Link', placeholder='http://') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.website3Link.$error.url && !profileForm.website3Link.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com). - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='website3Image') Image Link (4:3 ratio) - .col-sm-4 - input.form-control(type='url', name='website3Image', id='website3Image', autocomplete="off", ng-model='user.website3Image', placeholder='http://www.example.com/image.jpg', ng-pattern='/[\.](jpg|png|jpeg|gif)(\s+)?$/') - .col-sm-4.col-sm-offset-5(ng-show="profileForm.website3Image.$error.url && !profileForm.website3Image.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com/image.jpg). - - .form-group - .col-sm-offset-5.col-sm-4 - button.btn.btn-primary.btn-block(type='submit', ng-disabled='profileForm.$invalid') - span.ion-edit - | Update my Portfolio - br - .panel.panel-info .panel-heading.text-center Manage your account here: .panel-body From 041abd10654a1ae5102ecb42ec24c529f14ce68f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 14:58:04 -0700 Subject: [PATCH 11/18] fix beta warning --- public/css/main.less | 5 +++++ server/views/challengeMap/show.jade | 3 +++ server/views/home.jade | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/css/main.less b/public/css/main.less index 21e225994f..7773265028 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -613,6 +613,11 @@ thead { color: #009900 } +.default-border-radius { + border-radius: 5px; +} + + .testimonial-copy { font-size: 20px; text-align: center; diff --git a/server/views/challengeMap/show.jade b/server/views/challengeMap/show.jade index 1d3f91dfe7..77b42ca672 100644 --- a/server/views/challengeMap/show.jade +++ b/server/views/challengeMap/show.jade @@ -3,6 +3,9 @@ block content script. var completedChallenges = !{JSON.stringify(completedChallengeList)}; var challengeList = !{JSON.stringify(challengeList)}; + .bg-danger.default-border-radius + p      + a(href='https://github.com/FreeCodeCamp/freecodecamp/wiki/beta' target='_blank') You're using our experimental beta site. None of your progress here will be saved. Please click this to learn more. .panel.panel-info .panel-heading.text-center h1 Challenge Map diff --git a/server/views/home.jade b/server/views/home.jade index 4e7a8f9c73..e5e09f19bb 100644 --- a/server/views/home.jade +++ b/server/views/home.jade @@ -1,8 +1,8 @@ extends layout block content - .bg-danger - a(href='https://github.com/FreeCodeCamp/freecodecamp/wiki/beta before continuing') - h3 Warning! You are on beta! Please read this link before continuing! https://github.com/freecodecamp/freecodecamp/wiki/beta + .bg-danger.default-border-radius + p      + a(href='https://github.com/FreeCodeCamp/freecodecamp/wiki/beta' target='_blank') You're using our experimental beta site. None of your progress here will be saved. Please click this to learn more. .jumbotron .text-center h1.hug-top Code with Us From 73f0dcf7324185a1eb1caa54e375e721deceaa7f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 14:58:24 -0700 Subject: [PATCH 12/18] make wiki open in new tab --- server/views/partials/navbar.jade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/views/partials/navbar.jade b/server/views/partials/navbar.jade index 3c5b4c4d05..8d310d8846 100644 --- a/server/views/partials/navbar.jade +++ b/server/views/partials/navbar.jade @@ -14,7 +14,7 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height li a(href='/news') News li - a(href='//github.com/FreeCodeCamp/freecodecamp/wiki/Home', taregt='_blank') Wiki + a(href='//github.com/FreeCodeCamp/freecodecamp/wiki/Home', target='_blank') Wiki if !user li       li From e01876f3ab435d99b48f6ad78e6574a2c8fbb23b Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 4 Aug 2015 15:03:33 -0700 Subject: [PATCH 13/18] disable username updating when camper is githubCool --- server/views/account/account.jade | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/views/account/account.jade b/server/views/account/account.jade index 436651c1e0..81798a9511 100644 --- a/server/views/account/account.jade +++ b/server/views/account/account.jade @@ -32,7 +32,7 @@ block content .form-group label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (path to public profile) * .col-sm-4 - input.form-control(type='text', placeholder='username' name='username', autocomplete="off", id='username', ng-model='user.username', required='required', ng-minlength='5', ng-maxlength='20', ng-keypress='', unique-username='', ng-pattern="/^[A-z0-9_]+$/") + input.form-control(type='text', placeholder='username' name='username', autocomplete="off", id='username', ng-model='user.username', required='required', ng-minlength='5', ng-maxlength='20', ng-keypress='', unique-username='', ng-pattern="/^[A-z0-9_]+$/", ng-disabled='user.isGithubCool') .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.username.$error.pattern") alert(type='danger') span.ion-close-circled @@ -53,6 +53,10 @@ block content alert(type='danger') span.ion-close-circled | That username is already in use. + .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="user.isGithubCool") + alert(type='info') + span.ion-close-circled + | You are GithubCool! Your username cannot be changed. .form-group label.col-sm-3.col-sm-offset-2.control-label(for='email') Email * From 7246945b4235ca5f7bb9e2c08ce7f36f9ab546e2 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 15:09:20 -0700 Subject: [PATCH 14/18] remove bonfires from campers' public portfolios --- server/boot/user.js | 12 ------------ server/views/account/show.jade | 18 ------------------ 2 files changed, 30 deletions(-) diff --git a/server/boot/user.js b/server/boot/user.js index f2a91552d9..0d96a71295 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -214,19 +214,7 @@ module.exports = function(app) { bio: user.bio, picture: user.picture, progressTimestamps: user.progressTimestamps, - website1Link: user.website1Link, - website1Title: user.website1Title, - website1Image: user.website1Image, - website2Link: user.website2Link, - website2Title: user.website2Title, - website2Image: user.website2Image, - website3Link: user.website3Link, - website3Title: user.website3Title, - website3Image: user.website3Image, challenges: challenges, - bonfires: user.completedChallenges.filter(function(challenge) { - return challenge.challengeType === 5; - }), calender: data, moment: moment, longestStreak: user.longestStreak + diff --git a/server/views/account/show.jade b/server/views/account/show.jade index f1edc4d3c7..9463f78fc9 100644 --- a/server/views/account/show.jade +++ b/server/views/account/show.jade @@ -96,21 +96,3 @@ block content td.col-xs-2= moment(challenge.completedDate, 'x').format("MMM DD, YYYY") td.col-xs-6 a(href=challenge.solution, target='_blank') View my solution - - br - if (bonfires.length > 0) - .col-sm-12 - table.table.table-striped - thead - tr - th.col-xs-4 Bonfire - th.col-xs-2 Completed - th.col-xs-6 Solution - for bonfire in bonfires - tr - td.col-xs-4 - a(href='/challenges/' + bonfire.name, target='_blank')= bonfire.name - td.col-xs-2= moment(bonfire.completedDate, 'x').format("MMM DD, YYYY") - td.col-xs-6 - pre.wrappable= bonfire.solution - br From d752e5b4874cbf6af4e63fb562782336a13ef1bb Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Tue, 4 Aug 2015 15:09:42 -0700 Subject: [PATCH 15/18] on login double check that github username if different, assign user to new name --- common/models/User-Identity.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/common/models/User-Identity.js b/common/models/User-Identity.js index 781ea7d0ac..3df7f01400 100644 --- a/common/models/User-Identity.js +++ b/common/models/User-Identity.js @@ -41,20 +41,23 @@ export default function(UserIdent) { userChanged = true; } - // if user is not github cool - // and user signed in with github + // if user signed in with github + // and user is not github cool + // or username is different from github username // then make them github cool // and set their username from their github profile. - if (!user.isGithubCool && userIdent.provider === 'github-login') { - debug(` - user isn't github cool yet but signed in with github - lets make them cool! - `); + if ( + userIdent.provider === 'github-login' && + (!user.isGithubCool || + user.username !== userIdent.provider.username.toLowerCase()) + ) { + debug("user isn't github cool or username from github is different"); user.isGithubCool = true; user.username = userIdent.profile.username.toLowerCase(); userChanged = true; } + if (userChanged) { return user.save(function(err) { if (err) { return next(err); } From 989cb87c00738a245ac10a5165d8a58e06278cb5 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 18:00:01 -0700 Subject: [PATCH 16/18] add redirect for now vanished field guide articles --- server/boot/redirects.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/boot/redirects.js b/server/boot/redirects.js index 12d3c171ae..d0816d6a69 100644 --- a/server/boot/redirects.js +++ b/server/boot/redirects.js @@ -4,7 +4,7 @@ module.exports = function(app) { router.get('/nonprofit-project-instructions', function(req, res) { res.redirect( 301, - "https://github.com/FreeCodeCamp/freecodecamp/wiki/How-Free-Code-Camp's-Nonprofit-Projects-work" + "//github.com/FreeCodeCamp/freecodecamp/wiki/How-Free-Code-Camp's-Nonprofit-Projects-work" ); }); @@ -14,7 +14,7 @@ module.exports = function(app) { router.get('/privacy', function(req, res) { res.redirect( - 301, "https://github.com/FreeCodeCamp/freecodecamp/wiki/Free-Code-Camp's-Privacy-Policy" + 301, "//github.com/FreeCodeCamp/freecodecamp/wiki/Free-Code-Camp's-Privacy-Policy" ); }); @@ -22,6 +22,10 @@ module.exports = function(app) { res.redirect(301, '/map'); }); + router.get('/field-guide/*', function(req, res) { + res.redirect(302, '//github.com/freecodecamp/freecodecamp/wiki') + }); + router.get('/about', function(req, res) { res.redirect(301, '/map'); }); From 3551cefb3dce007d14e83224877026251936c147 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 18:29:05 -0700 Subject: [PATCH 17/18] simplify account.jade view for github integration --- server/views/account/account.jade | 130 ++++-------------------------- 1 file changed, 15 insertions(+), 115 deletions(-) diff --git a/server/views/account/account.jade b/server/views/account/account.jade index 81fc693860..25051caf25 100644 --- a/server/views/account/account.jade +++ b/server/views/account/account.jade @@ -2,112 +2,27 @@ extends ../layout block content script. var challengeName = 'Account View' - .panel.panel-info.min-height-1000(ng-controller="profileValidationController") + .panel.panel-info(ng-controller="profileValidationController") .panel-heading.text-center Update your portfolio here: .panel-body - .container.text-center + if (!user.github) + .col-xs-12 + a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/auth/github') + i.fa.fa-github + | Link GitHub with my account + .col-xs-12 form.form-horizontal(action='/account/profile', method='POST', novalidate='novalidate', name='profileForm' ng-show="asyncComplete") input(type='hidden', name='_csrf', value=_csrf) - - .col-sm-4.col-sm-offset-5 - h2 Bio - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='name') Name * - .col-sm-4 - input.form-control(type='text', placeholder='Name', name='name', autocomplete="off", ng-model='user.name', ng-minlength='3', ng-maxlength='50', required='required', id='name') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.name.$invalid && profileForm.name.$error.required") - alert(type='danger') - span.ion-close-circled(id='#name-error') - | Your name is required. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show='profileForm.name.$error.minlength && !profileForm.name.$pristine') - alert(type='danger') - span.ion-close-circled - | Your name must be at least 3 characters. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show='profileForm.name.$error.maxlength && !profileForm.name.$pristine') - alert(type='danger') - span.ion-close-circled - | Your name must be fewer than 50 characters. - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='username') Username (path to public profile) * - .col-sm-4 - input.form-control(type='text', placeholder='username' name='username', autocomplete="off", id='username', ng-model='user.username', required='required', ng-minlength='5', ng-maxlength='20', ng-keypress='', unique-username='', ng-pattern="/^[A-z0-9_]+$/", ng-disabled='user.isGithubCool') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.username.$error.pattern") - alert(type='danger') - span.ion-close-circled - | Your username should only contain letters, numbers and underscores (az10_). - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.username.$error.required") - alert(type='danger') - span.ion-close-circled - | Your username is required. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.username.$error.minlength && !profileForm.username.$pristine") - alert(type='danger') - span.ion-close-circled - | Your username must be at least 5 characters. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.username.$error.maxlength && !profileForm.username.$pristine") - alert(type='danger') - span.ion-close-circled - | Your username must be fewer than 15 characters. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.username.$error.unique && !profileForm.username.$pristine && $scope.storedUsername !== user.username") - alert(type='danger') - span.ion-close-circled - | That username is already in use. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="user.isGithubCool") - alert(type='info') - span.ion-close-circled - | You are GithubCool! Your username cannot be changed. - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') Email * - .col-sm-4 - input.form-control(type='email', name='email', id='email', autocomplete="off", ng-model='user.email', required='required', ng-keypress='', unique-email='') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.email.$error.required") - alert(type='danger') - span.ion-close-circled - | Your email address is required. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.$error.email && !profileForm.email.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid email format. - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.email.$error.unique && !profileForm.email.$pristine") - alert(type='danger') - span.ion-close-circled - | That email is already in use. - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='location') Location - .col-sm-4 - input.form-control(type='text', name='location', autocomplete="off", id='location', ng-model='user.location') - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') Link to Profile Photo (1:1 ratio) - .col-sm-4 - input.form-control(type='url', name='picture', id='picture', ng-model='user.picture', placeholder='http://www.example.com/image.jpg') - .col-sm-4.col-sm-offset-5(ng-show="profileForm.picture.$error.url && !profileForm.picture.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com/image.jpg). - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='bio') Bio (140 characters) + label.col-sm-3.col-sm-offset-1.control-label(for='bio') Bio (140 characters) .col-sm-4 input.form-control(type='text', name='bio', autocomplete="off", ng-model='user.bio', ng-maxlength='140', id='bio') .col-sm-4.col-sm-offset-5(ng-cloak, ng-show='profileForm.bio.$error.maxlength && !profileForm.bio.$pristine') alert(type='danger') span.ion-close-circled | Your bio must be fewer than 140 characters. - .form-group - .col-sm-offset-5.col-sm-4 - button.btn.btn-primary.btn-block(type='submit', ng-disabled='profileForm.$invalid') - span.ion-edit - | Update my Bio - - .col-sm-4.col-sm-offset-5 - h2 Social Profiles - - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter + label.col-sm-3.col-sm-offset-1.control-label(for='email') Twitter .col-sm-4 .input-group.twitter-input span.input-group-addon @ @@ -120,17 +35,9 @@ block content alert(type='danger') span.ion-close-circled | Your name must be fewer than 15 characters. - .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') GitHub - .col-sm-4 - input.form-control(type='url', name='githubProfile', id='githubProfile', autocomplete="off", ng-model='user.githubProfile', placeholder='http://') - .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.githubProfile.$error.url && !profileForm.githubProfile.$pristine") - alert(type='danger') - span.ion-close-circled - | Please enter a valid URL format (http://www.example.com). .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') CodePen + label.col-sm-3.col-sm-offset-1.control-label(for='email') CodePen .col-sm-4 input.form-control(type='url', name='codepenProfile', id='codepenProfile', autocomplete="off", ng-model='user.codepenProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.codepenProfile.$error.url && !profileForm.codepenProfile.$pristine") @@ -139,7 +46,7 @@ block content | Please enter a valid URL format (http://www.example.com). .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') LinkedIn + label.col-sm-3.col-sm-offset-1.control-label(for='email') LinkedIn .col-sm-4 input.form-control(type='url', name='linkedinProfile', id='linkedinProfile', autocomplete="off", ng-model='user.linkedinProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.linkedinProfile.$error.url && !profileForm.linkedinProfile.$pristine") @@ -148,7 +55,7 @@ block content | Please enter a valid URL format (http://www.example.com). .form-group - label.col-sm-3.col-sm-offset-2.control-label(for='email') Facebook + label.col-sm-3.col-sm-offset-1.control-label(for='email') Facebook .col-sm-4 input.form-control(type='url', name='facebookProfile', id='facebookProfile', autocomplete="off", ng-model='user.facebookProfile', placeholder='http://') .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.facebookProfile.$error.url && !profileForm.facebookProfile.$pristine") @@ -156,21 +63,14 @@ block content span.ion-close-circled | Please enter a valid URL format (http://www.example.com). - .form-group - .col-sm-offset-5.col-sm-4 - button.btn.btn-primary.btn-block(type='submit', ng-disabled='profileForm.$invalid') - span.ion-edit - | Update my Social Links + a.btn.btn-lg.btn-block.btn-primary.btn-link-social(type='submit', ng-disabled='profileForm.$invalid') + i.fa.fa-submit + | Update my info .panel.panel-info .panel-heading.text-center Manage your account here: .panel-body if (!user.google || !user.facebook || !user.linkedin || !user.twitter) - if (!user.github) - .col-xs-12 - a.btn.btn-lg.btn-block.btn-github.btn-link-social(href='/auth/github') - i.fa.fa-github - | Link GitHub with my account if (!user.twitter) .col-xs-12 a.btn.btn-lg.btn-block.btn-twitter.btn-link-social.disabled(href='#') From 3c4142c92c5400bb6401af6b2ceb3b04c17bd2f5 Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Tue, 4 Aug 2015 18:43:40 -0700 Subject: [PATCH 18/18] fix profile update button --- server/boot/user.js | 23 ----------------------- server/views/account/account.jade | 4 ++-- 2 files changed, 2 insertions(+), 25 deletions(-) diff --git a/server/boot/user.js b/server/boot/user.js index 0d96a71295..7278e0a07d 100644 --- a/server/boot/user.js +++ b/server/boot/user.js @@ -278,35 +278,12 @@ module.exports = function(app) { return res.redirect('/account'); } var body = req.body || {}; - user.email = body.email.trim() || ''; - user.name = body.name.trim() || ''; - user.username = body.username.trim() || ''; - user.location = body.location.trim() || ''; - - user.githubProfile = body.githubProfile.trim() || ''; user.facebookProfile = body.facebookProfile.trim() || ''; user.linkedinProfile = body.linkedinProfile.trim() || ''; - user.codepenProfile = body.codepenProfile.trim() || ''; user.twitterHandle = body.twitterHandle.trim() || ''; user.bio = body.bio.trim() || ''; - user.picture = body.picture.trim() || - 'https://s3.amazonaws.com/freecodecamp/' + - 'camper-image-placeholder.png'; - user.website1Title = body.website1Title.trim() || ''; - user.website1Link = body.website1Link.trim() || ''; - user.website1Image = body.website1Image.trim() || ''; - - user.website2Title = body.website2Title.trim() || ''; - user.website2Link = body.website2Link.trim() || ''; - user.website2Image = body.website2Image.trim() || ''; - - user.website3Title = body.website3Title.trim() || ''; - user.website3Link = body.website3Link.trim() || ''; - user.website3Image = body.website3Image.trim() || ''; - - user.save(function(err) { if (err) { return next(err); diff --git a/server/views/account/account.jade b/server/views/account/account.jade index 25051caf25..b1204b264e 100644 --- a/server/views/account/account.jade +++ b/server/views/account/account.jade @@ -63,8 +63,8 @@ block content span.ion-close-circled | Please enter a valid URL format (http://www.example.com). - a.btn.btn-lg.btn-block.btn-primary.btn-link-social(type='submit', ng-disabled='profileForm.$invalid') - i.fa.fa-submit + button.btn.btn-lg.btn-block.btn-primary.btn-link-social(type='submit', ng-disabled='profileForm.$invalid') + span.ion-edit | Update my info .panel.panel-info