From 8d2552fe57a3caf59fae678b36e1de1a77e9a901 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Sun, 8 Mar 2015 15:39:36 -0700 Subject: [PATCH] give users without images a default image and retroactively give that to all their stories and comments and also make some UI changes to stories. --- controllers/resources.js | 17 ++++++++++------- public/css/main.less | 4 ++++ views/stories/comments.jade | 2 +- views/stories/hot-stories.jade | 10 ++++++---- views/stories/new-stories.jade | 10 ++++++---- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/controllers/resources.js b/controllers/resources.js index 9a95f26eca..9076fd06bd 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -130,9 +130,7 @@ module.exports = { var githubHeaders = {headers: {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1521.3 Safari/537.36'}, port:80 }; request('https://api.github.com/repos/freecodecamp/freecodecamp/pulls?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function(err, status1, pulls) { pulls = pulls ? Object.keys(JSON.parse(pulls)).length : "Can't connect to github"; - debug('pulls', pulls); request('https://api.github.com/repos/freecodecamp/freecodecamp/issues?client_id=' + secrets.github.clientID + '&client_secret=' + secrets.github.clientSecret, githubHeaders, function (err, status2, issues) { - debug('issues', issues); issues = ((pulls === parseInt(pulls)) && issues) ? Object.keys(JSON.parse(issues)).length - pulls : "Can't connect to GitHub"; res.send({"issues": issues, "pulls" : pulls}); }); @@ -168,8 +166,16 @@ module.exports = { about: function(req, res) { if (req.user) { if (!req.user.picture) { - req.user.picture = "https://s3.amazonaws.com/freecodecamp/favicons/apple-touch-icon-180x180.png" - req.user.save(); + User.find({'_id': req.user._id}, function (err, user) { + if (err) { + debug('Err:', err); + } + user = user.pop(); + user.picture = "https://s3.amazonaws.com/freecodecamp/favicons/apple-touch-icon-180x180.png"; + user.markModifed('user.picture'); + user.save(); + updateUserStoryPictures(user._id.toString(), "https://s3.amazonaws.com/freecodecamp/favicons/apple-touch-icon-180x180.png"); + }); } } @@ -291,7 +297,6 @@ module.exports = { var $ = cheerio.load(body); var title = $('title').text(); result.title = title; - debug('calling callback with', result); callback(null, result); } else { callback('failed'); @@ -334,8 +339,6 @@ module.exports = { R.forEach(function(story) { story.author.picture = picture; - debug('This is a story', story); - debug(story.author.picture); story.markModified('author'); story.save(); }, foundStories); diff --git a/public/css/main.less b/public/css/main.less index 2314b09067..cc69374949 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -834,6 +834,10 @@ iframe.iphone { height: 35px; } +.story-headline { + font-size: 20px; +} + //uncomment this to see the dimensions of all elements outlined in red //* { diff --git a/views/stories/comments.jade b/views/stories/comments.jade index a7b488de60..649283cf3f 100644 --- a/views/stories/comments.jade +++ b/views/stories/comments.jade @@ -24,7 +24,7 @@ var div = document.createElement('div'); $(div) .html( - '
' + + '
' + '
' + "" + '' + commentDetails.author.username + '' + diff --git a/views/stories/hot-stories.jade b/views/stories/hot-stories.jade index 9949b3deb6..7839ef1204 100644 --- a/views/stories/hot-stories.jade +++ b/views/stories/hot-stories.jade @@ -22,15 +22,17 @@ $(div) .html( "
" + - "
" + + "

" + (i + 1) + - "

" + + "" + "
" + "
" + "
" + - "
" + + "
" + "" + data[i].storyLink + "" + diff --git a/views/stories/new-stories.jade b/views/stories/new-stories.jade index 93b9b25e58..6c95274db9 100644 --- a/views/stories/new-stories.jade +++ b/views/stories/new-stories.jade @@ -22,15 +22,17 @@ $(div) .html( "
" + - "
" + + "

" + (i + 1) + - "

" + + "" + "
" + - "" + + "" + + "" + + "" + "
" + "
" + "
" + - "