From 41abdae46fbc8e6ef3d959ea7ce6c6dd6b77332b Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Mon, 5 Jan 2015 17:29:37 -0800 Subject: [PATCH] further progress on the form and add angular inline --- app.js | 17 +++++++++-------- controllers/user.js | 9 ++++++++- models/User.js | 8 ++++++++ views/account/profile.jade | 36 ++++++++++++++++++++++++++++++++---- views/layout.jade | 5 +++-- 5 files changed, 60 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index d6459bee35d..7711b8cbb6a 100644 --- a/app.js +++ b/app.js @@ -108,17 +108,18 @@ var trusted = [ "'self'", '*.freecodecamp.com', '*.gstatic.com', - "*.google-analytics.com", - "*.googleapis.com", - "*.google.com", - "*.gstatic.com", - "*.doubleclick.net", - "*.twitter.com", + '*.google-analytics.com', + '*.googleapis.com', + '*.google.com', + '*.gstatic.com', + '*.doubleclick.net', + '*.twitter.com', '*.twimg.com', "'unsafe-eval'", "'unsafe-inline'", - "*.rafflecopter.com", - "localhost:3001" + '*.rafflecopter.com', + '*.cloudflare.com', + 'localhost:3001' ]; debug(trusted); diff --git a/controllers/user.js b/controllers/user.js index c95d68669c6..0740141de2b 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -169,6 +169,8 @@ exports.returnUser = function(req, res, next) { coderbyteProfile: user.profile.linkedinProfile, githubProfile: user.profile.githubProfile, linkedinProfile: user.profile.linkedinProfile, + codepenProfile: user.codepenProfile, + twitterHandle: user.twitterHandle, website1: user.portfolio.website1Link, website1Title: user.portfolio.website1Title, website1Image: user.portfolio.website1Image, @@ -229,6 +231,7 @@ exports.postUpdateProfile = function(req, res, next) { req.assert('email', 'Please enter a valid email address.').isEmail(); req.assert('username', 'Your username cannot be longer than 20 characters').len(1, 20); req.assert('username', 'Your username can only use letters, numbers or underscores').matchRegex(/^[A-z0-9_]+$/); + req.assert('githubProfile', 'Please enter a valid URL (www.example.com)').matchRegex(/^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/); var errors = req.validationErrors(); if (errors) { req.flash('errors', errors); @@ -262,7 +265,11 @@ exports.postUpdateProfile = function(req, res, next) { user.profile.name = req.body.name || ''; user.profile.username = req.body.username || ''; user.profile.location = req.body.location || ''; - user.profile.website = req.body.website || ''; + user.profile.githubProfile = req.body.githubProfile || ''; + user.profile.coderbyteProfile = req.body.coderbyteProfile || ''; + user.profile.linkedinProfile = req.body.linkedinProfile || ''; + user.profile.codepenProfile = req.body.codepenProfile || ''; + user.profile.twitterHandle = req.body.twitterHandle || ''; user.portfolio.website1Title = req.body.website1Title || ''; user.portfolio.website1Link = req.body.website1Link || ''; user.portfolio.website1Image = req.body.website1Image || ''; diff --git a/models/User.js b/models/User.js index 4c54cd336cb..9b37019cb9c 100644 --- a/models/User.js +++ b/models/User.js @@ -293,6 +293,14 @@ var userSchema = new mongoose.Schema({ coderbyteProfile: { type: String, default: '' + }, + codepenProfile: { + type: String, + default: '' + }, + twitterHandle: { + type: String, + default: '' } }, portfolio: { diff --git a/views/account/profile.jade b/views/account/profile.jade index 0221bcaaf16..ee5fc45c147 100644 --- a/views/account/profile.jade +++ b/views/account/profile.jade @@ -1,7 +1,15 @@ extends ../layout +script. + var freecodecamp = angular.module('freecodecamp',[]); + freecodecamp.controller('freecodecampController', ['$scope', + function($scope) { + $scope.twitterHandle = '@yournamehere' + } + ]); + block content - .panel + .panel(ng-controller="freecodecampController") .container.text-center h1 Update your profile here: form.form-horizontal(action='/account/profile', method='POST') @@ -22,9 +30,28 @@ block content label.col-sm-3.col-sm-offset-2.control-label(for='location') Location .col-sm-4 input.form-control(type='text', name='location', id='location', value='#{user.profile.location}') - - - + .form-group + label.col-sm-3.col-sm-offset-2.control-label(for='email') Twitter Handle + .col-sm-4 + input.form-control(type='text', name='twitterHandle', id='twitterHandle', ng-model="twitterHandle" value='#{user.profile.twitterHandle}') + span + {{twitterHandle}} + .form-group + label.col-sm-3.col-sm-offset-2.control-label(for='email') Github Profile Link + .col-sm-4 + input.form-control(type='text', name='githubProfile', id='githubProfile', value='#{user.profile.githubProfile}') + .form-group + label.col-sm-3.col-sm-offset-2.control-label(for='email') CodePen Profile Link + .col-sm-4 + input.form-control(type='text', name='codepenProfile', id='codepenProfile', value='#{user.profile.codepenProfile}') + .form-group + label.col-sm-3.col-sm-offset-2.control-label(for='email') CoderByte Profile Link + .col-sm-4 + input.form-control(type='text', name='coderbyteProfile', id='coderbyteProfile', value='#{user.profile.coderbyteProfile}') + .form-group + label.col-sm-3.col-sm-offset-2.control-label(for='email') LinkedIn Profile Link + .col-sm-4 + input.form-control(type='text', name='linkedinProfile', id='linkedinProfile', value='#{user.profile.linkedinProfile}') .form-group label.col-sm-3.col-sm-offset-2.control-label(for='website1Title') 1st Portfolio Website Title .col-sm-4 @@ -153,3 +180,4 @@ block content button.btn.btn-danger.btn-block(type='submit') span.ion-trash-b | Yes, Delete my account + diff --git a/views/layout.jade b/views/layout.jade index 38d29b19fd9..9d99ff173d6 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -1,7 +1,8 @@ doctype html -html +html(ng-app='freecodecamp') head - script(src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js") + script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js") + script(src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.8/angular.min.js") link(rel='shortcut icon', href='https://s3.amazonaws.com/freecodecamp/favicon.ico') include partials/meta title #{title} | Free Code Camp