add jQuery to check for broken images and replace them with standard image. Remove gravatar logic.

This commit is contained in:
Michael Q Larson
2015-04-02 13:42:15 -07:00
parent 1248cde97f
commit 36c43cc73a
6 changed files with 23 additions and 48 deletions

View File

@ -3,7 +3,7 @@ var async = require('async'),
resources = require('./resources'),
secrets = require('./../config/secrets'),
moment = require('moment'),
debug = require('debug')('freecc:cntr:resources'),
debug = require('debug')('freecc:cntr:nonprofits'),
R = require('ramda');
exports.nonprofitsHome = function(req, res) {

View File

@ -346,7 +346,8 @@ var userSchema = new mongoose.Schema({
name: String,
completedWith: String,
solution: String,
githubLink: String
githubLink: String,
verified: Boolean
}
],
currentStreak: {
@ -390,23 +391,4 @@ userSchema.methods.comparePassword = function(candidatePassword, cb) {
});
};
/**
* Helper method for getting user's gravatar.
*/
userSchema.methods.gravatar = function(size) {
if (!size) { size = 200; }
if (!this.email) {
return 'https://gravatar.com/avatar/?s=' + size + '&d=retro';
}
var md5 = crypto
.createHash('md5')
.update(this.email)
.digest('hex');
return 'https://gravatar.com/avatar/' + md5 + '?s=' + size + '&d=retro';
};
module.exports = mongoose.model('User', userSchema);

View File

@ -75,6 +75,10 @@ $(document).ready(function() {
});
$("img").error(function () {
$(this).unbind("error").attr("src", "https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png");
});
$('#completed-courseware').on('click', function() {
$('#complete-courseware-dialog').modal('show');
});
@ -114,7 +118,8 @@ $(document).ready(function() {
{
coursewareInfo: {
coursewareHash: passedCoursewareHash,
coursewareName: passedCoursewareName
coursewareName: passedCoursewareName,
verified: true
}
}).success(
function(res) {
@ -135,7 +140,8 @@ $(document).ready(function() {
coursewareName: passedCoursewareName,
completedWith: didCompleteWith,
publicURL: publicURL,
challengeType: challengeType
challengeType: challengeType,
verified: false
}
}).success(
function() {
@ -158,7 +164,8 @@ $(document).ready(function() {
completedWith: didCompleteWith,
publicURL: publicURL,
githubURL: githubURL,
challengeType: challengeType
challengeType: challengeType,
verified: false
}
}).success(function() {
window.location.href = '/challenges';

View File

@ -176,15 +176,11 @@ block content
.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.portfolio.website1Image', placeholder='http://www.example.com/image.jpg', ng-pattern="/[\.](jpg|png|jpeg|gif)\s?$/")
input.form-control(type='url', name='website1Image', id='website1Image', autocomplete="off", ng-model='user.portfolio.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(ng-show="profileForm.website1Image.$error.pattern")
alert(type='danger')
span.ion-close-circled
| The image URL must end in .jpg, .png, .jpeg or .gif.
.col-sm-4.col-sm-offset-5.flat-top
h3 Second Portfolio Project
@ -209,15 +205,11 @@ block content
.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.portfolio.website2Image', placeholder='http://www.example.com/image.jpg', ng-pattern="/[\.](jpg|png|jpeg|gif)\s?$/")
input.form-control(type='url', name='website2Image', id='website2Image', autocomplete="off", ng-model='user.portfolio.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(ng-show="profileForm.website2Image.$error.pattern")
alert(type='danger')
span.ion-close-circled
| The image URL must end in .jpg, .png, .jpeg or .gif.
.col-sm-4.col-sm-offset-5.flat-top
h3 Third Portfolio Project
@ -248,10 +240,6 @@ block content
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(ng-show="profileForm.website3Image.$error.pattern")
alert(type='danger')
span.ion-close-circled
| The image URL must end in .jpg, .png, .jpeg or .gif.
.form-group
.col-sm-offset-5.col-sm-4

View File

@ -49,7 +49,7 @@ block content
if (website1Title && website1Link && website1Image)
.row
.col-xs-12.col-md-5
img.img-center.img-responsive.portfolio-image(src=website1Image, alt="@#{username}'s #{website1Title")
img.img-center.img-responsive.portfolio-image(src=website1Image, alt="@#{username}'s #{website1Title}")
.col-xs-12.col-md-7
h3.text-center.wrappable.flat-top= website1Title
a.btn.btn-lg.btn-block.btn-info(href=website1Link, target='_blank')
@ -66,7 +66,7 @@ block content
if (website2Title && website2Link && website2Image)
.row
.col-xs-12.col-md-5
img.img-responsive.portfolio-image.img-center(src=website2Image, alt="@#{username}'s #{website2Title")
img.img-responsive.portfolio-image.img-center(src=website2Image, alt="@#{username}'s #{website2Title}")
.col-xs-12.col-md-7
h3.text-center.wrappable.flat-top= website2Title
a.btn.btn-lg.btn-block.btn-info(href=website2Link, target='_blank')
@ -83,7 +83,7 @@ block content
if (website3Title && website3Link && website3Image)
.row
.col-xs-12.col-md-5
img.img-responsive.portfolio-image.img-center(src=website3Image, alt="@#{username}'s #{website1Title")
img.img-responsive.portfolio-image.img-center(src=website3Image, alt="@#{username}'s #{website1Title}")
.col-xs-12.col-md-7
h3.text-center.wrappable.flat-top= website3Title
a.btn.btn-lg.btn-block.btn-info(href=website3Link, target='_blank')
@ -97,7 +97,7 @@ block content
| Try it out
.hidden-xs.col-sm-12
#cal-heatmap.img-center
#cal-heatmap.img-center.hidden
script(src="//d3js.org/d3.v3.min.js")
script(src="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.min.js")
link(rel="stylesheet", href="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css")

View File

@ -26,11 +26,9 @@
else
li
if (user.profile.username)
a(href='/' + user.profile.username) [ #{user.progressTimestamps.length} ]
else
a(href='/account') [ #{user.points} ]
a(href='/account') [ #{user.progressTimestamps.length} ]
.hidden-xs
if user.profile.picture
if (user.profile.username)
@ -42,7 +40,7 @@
else
if (user.profile.username)
a(href='/' + user.profile.username)
img.profile-picture.float-right(src='#{user.gravatar(60)}')
img.profile-picture.float-right(src='https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png')
else
a(href='/account')
img.profile-picture.float-right(src='#{user.gravatar(60)}')
img.profile-picture.float-right(src='https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png')