}, function(err, reply) { var tweets = []; _.each(reply, function(raw_tweet) { var tweet = {}, hashtag_regexp = /#([a-zA-Z0-9]+)/g, username_regexp = /@([a-zA-Z0-9]+)/g; if (raw_tweet.retweeted_status) { tweet.img = raw_tweet.retweeted_status.user.profile_image_url; tweet.username = raw_tweet.retweeted_status.user.screen_name; tweet.tweet = raw_tweet.retweeted_status.text; tweet.retweeted = true; } else { tweet.username = raw_tweet.user.screen_name; tweet.img = raw_tweet.user.profile_image_url; tweet.tweet = raw_tweet.text; tweet.retweeted = false; } tweet.time_distance = moment(raw_tweet.created_at, 'ddd MMM DD HH:mm:ss Z YYYY').calendar(); tweet.tweet = tweet.tweet.replace(hashtag_regexp, '<span class="hashtag">#$1</span>'); tweet.tweet = tweet.tweet.replace(username_regexp, '<span class="at-name">@$1</span>'); tweets.push(tweet); }); response.tweets = tweets; var blog = new Tumblr(config.tumblr.blog, config.tumblr.consumer_key); blog.text({ limit: 1 }, function(error, tumblr_response) { post = _.first(tumblr_response.posts); response.post_title = post.title; response.post = S(post.body).truncate(500, '...<a href="' + post.post_url + '" class="read_more">[read more]</a>').s; skills.prepare(['blue', 'red', 'green'], database.skills); response.columns = skills.columns; response.projects = database.projects; response.projectCount = response.projects.length; res.render('index', response); }); });
app.get('/blog', function(req, res) { var blog = new Tumblr( config.tumblr.blog, config.tumblr.consumer_key ); blog.text({ limit: 1 }, function(error, response) { post = _.first(response.posts); if (req.xhr) { res.send(post); } else { res.render('blog', post); } }); });