From f3646b0aae58521dbef5d8cc8d6ff98bf6b2c30f Mon Sep 17 00:00:00 2001 From: Quincy Larson Date: Sat, 9 May 2015 16:23:45 -0700 Subject: [PATCH] give points for upvoting, add facebook profile attribute, improve social profile icons --- controllers/story.js | 14 ++++++++++++-- controllers/user.js | 2 ++ models/User.js | 4 ++++ public/css/main.less | 4 ++++ views/account/account.jade | 9 +++++++++ views/account/show.jade | 12 +++++++----- 6 files changed, 38 insertions(+), 7 deletions(-) diff --git a/controllers/story.js b/controllers/story.js index f317bef7b0..cfde5345ef 100755 --- a/controllers/story.js +++ b/controllers/story.js @@ -235,8 +235,18 @@ exports.upvote = function(req, res, next) { return next(err); } user = user.pop(); - user.progressTimestamps.push(Date.now()); - user.save(); + user.progressTimestamps.push(Date.now() || 0); + user.save(function (err, user) { + req.user.save(function (err, user) { + if (err) { + return next(err); + } + }); + req.user.progressTimestamps.push(Date.now() || 0); + if (err) { + return next(err); + } + }); }); return res.send(story); }); diff --git a/controllers/user.js b/controllers/user.js index ddb3ae7030..3b8fdb3cbd 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -358,6 +358,7 @@ exports.returnUser = function(req, res, next) { githubProfile: user.profile.githubProfile, linkedinProfile: user.profile.linkedinProfile, codepenProfile: user.profile.codepenProfile, + facebookProfile: user.profile.facebookProfile, twitterHandle: user.profile.twitterHandle, bio: user.profile.bio, picture: user.profile.picture, @@ -453,6 +454,7 @@ exports.postUpdateProfile = function(req, res, next) { user.profile.username = req.body.username.trim() || ''; user.profile.location = req.body.location.trim() || ''; user.profile.githubProfile = req.body.githubProfile.trim() || ''; + user.profile.facebookProfile = req.body.facebookProfile.trim() || ''; user.profile.linkedinProfile = req.body.linkedinProfile.trim() || ''; user.profile.codepenProfile = req.body.codepenProfile.trim() || ''; user.profile.twitterHandle = req.body.twitterHandle.trim() || ''; diff --git a/models/User.js b/models/User.js index 74bbfa31bd..38c073a2ba 100644 --- a/models/User.js +++ b/models/User.js @@ -64,6 +64,10 @@ var userSchema = new mongoose.Schema({ twitterHandle: { type: String, default: '' + }, + facebookProfile: { + type: String, + default: '' } }, portfolio: { diff --git a/public/css/main.less b/public/css/main.less index d6c88ca896..4b632e2dbc 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -1065,6 +1065,10 @@ hr { margin-right: -20px; } +.profile-social-icons { + margin-left: 8px; +} + .border-radius-5 { border-radius: 5px; } diff --git a/views/account/account.jade b/views/account/account.jade index 72a1f60281..a50f98645b 100644 --- a/views/account/account.jade +++ b/views/account/account.jade @@ -143,6 +143,15 @@ block content 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') Facebook + .col-sm-4 + input.form-control(type='url', name='facebookProfile', id='facebookProfile', autocomplete="off", ng-model='user.profile.facebookProfile', placeholder='http://') + .col-sm-4.col-sm-offset-5(ng-cloak, ng-show="profileForm.facebookProfile.$error.url && !profileForm.facebookProfile.$pristine") + alert(type='danger') + 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') diff --git a/views/account/show.jade b/views/account/show.jade index 73af6cdea4..6f031d1ec3 100644 --- a/views/account/show.jade +++ b/views/account/show.jade @@ -22,15 +22,17 @@ block content img.img-center.img-responsive.public-profile-img(src=picture) else img.img-center.img-responsive.public-profile-img(src='https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png') - h1.text-center.negative-5 + h1.text-center.negative-5.profile-social-icons - if (twitterHandle) - a.ion-social-twitter.text-primary(title="@#{username}'s Twitter Profile", href="http://twitter.com/#{twitterHandle}", target='_blank') + a.fa.fa-twitter-square.text-primary(title="@#{username}'s Twitter Profile", href="http://twitter.com/#{twitterHandle}", target='_blank') - if (githubProfile) - a.ion-social-github.text-primary(title="@#{username}'s GitHub Profile", href=githubProfile, target='_blank') - - if (linkedinProfile) - a.ion-social-linkedin.text-primary(title="@#{username}'s LinkedIn Profile", href=linkedinProfile, target='_blank') + a.fa.fa-github-square.text-primary(title="@#{username}'s GitHub Profile", href=githubProfile, target='_blank') - if (codepenProfile) a.ion-social-codepen.text-primary(title="@#{username}'s CodePen Profile", href=codepenProfile, target='_blank') + - if (linkedinProfile) + a.fa.fa-linkedin-square.text-primary(title="@#{username}'s LinkedIn Profile", href=linkedinProfile, target='_blank') + - if (facebookProfile) + a.fa.fa-facebook-square.text-primary(title="@#{username}'s Facebook Profile", href=facebookProfile, target='_blank') .visible-md.visible-lg .col-xs-12.col-sm-12.col-md-4.text-justify h1.flat-top.wrappable= name