add twitter social functionality

pull/2/head
Michael Q Larson 2014-12-23 12:16:23 -08:00
parent a032be6a0b
commit 3ac4ecdd08
2 changed files with 10 additions and 0 deletions

View File

@ -7,6 +7,8 @@ var _ = require('lodash');
exports.returnChallenge = function(req, res, next) {
var challengeNumber = parseInt(req.params.challengeNumber) || 0;
var verbs = ['ACED', 'NAILED', 'ROCKED', 'SCORCHED', 'DEVASTATED', 'OWNED', 'CRUSHED', 'CONQUERED', 'KILLED', 'SHREDDED', 'ANNIHILATED', 'NUKED']
var phrases = ['Shout it from on top of a mountain', 'Tell everyone and their dogs', "Show them. Show them all!", "Inspire your friends", "Tell the world of your greatness", "Look accomplished on social media", 'Share news of your grand endeavor', 'Establish your alibi for the past two hours', "Prove to mom that computers aren't just for games"]
if (challengeNumber > 59) { challengeNumber = 0; }
Challenge.find({}, function (err, c) {
if (err) {
@ -19,7 +21,10 @@ exports.returnChallenge = function(req, res, next) {
video: c[challengeNumber].video,
time: c[challengeNumber].time,
steps: c[challengeNumber].steps,
number: challengeNumber,
cc: req.user ? req.user.challengesHash : undefined,
verb: verbs[Math.floor(Math.random()*verbs.length)],
phrase: phrases[Math.floor(Math.random()*phrases.length)],
challenges: c
});
});

View File

@ -34,6 +34,11 @@ block content
.animated.zoomInUp.delay-1
span.landing-icon.ion-checkmark-circled.text-primary
a.animated.fadeIn.delay-2.btn.btn-lg.btn-primary.btn-block.next-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge
if (cc && cc[2] > 0)
a.animated.fadeIn.delay-2.btn-twitter.btn.btn-lg.btn-info.btn-block(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20Free%20Code%20Camp%20Challenge%20%23#{number}:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{number}&hashtags=learntocode, javascript")
i.fa.fa-twitter  
= phrase
#skip-dialog.modal
.modal-dialog.animated.zoomIn.fast-animation
.modal-content