diff --git a/app.js b/app.js index df9bcc4c61..1814d41115 100755 --- a/app.js +++ b/app.js @@ -514,6 +514,16 @@ app.post( storyController.upvote ); +app.get( + '/unsubscribe/:email', + resourcesController.unsubscribe +); + +app.get( + '/unsubscribed', + resourcesController.unsubscribed +); + app.all('/account', passportConf.isAuthenticated); app.get('/account/api', userController.getAccountAngular); diff --git a/controllers/resources.js b/controllers/resources.js index dada649cbf..77fa720fbf 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -185,6 +185,31 @@ module.exports = { }); }, + unsubscribe: function unsubscribe(req, res) { + User.findOne({email: req.params.email}, function(err, user) { + if (user) { + if (err) { + return next(err); + } + user.sendMonthlyEmail = false; + user.save(function () { + if (err) { + return next(err); + } + res.redirect('/unsubscribed'); + }); + } else { + res.redirect('/unsubscribed'); + } + }); + }, + + unsubscribed: function unsubscribed(req, res) { + res.render('resources/unsubscribed', { + title: "You have been unsubscribed" + }); + }, + githubCalls: function(req, res) { 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) { diff --git a/models/User.js b/models/User.js index 5874bb2bdb..07804fadd8 100644 --- a/models/User.js +++ b/models/User.js @@ -141,6 +141,7 @@ var userSchema = new mongoose.Schema({ }, needsMigration: { type: Boolean, default: true }, finishedWaypoints: { type: Boolean, default: false }, + sendMonthlyEmail: { type: Boolean, default: true }, challengesHash: {} }); diff --git a/seed_data/field-guides.json b/seed_data/field-guides.json index e8ee3ba70e..87af2174af 100644 --- a/seed_data/field-guides.json +++ b/seed_data/field-guides.json @@ -260,7 +260,7 @@ }, { "_id": "bd7159d9c442eddfaeb5bdef", - "name": "What does Register mean?", + "name": "Global Mac Keyboard Shortcuts", "description": [ "
", "

", diff --git a/views/challengeMap/show.jade b/views/challengeMap/show.jade index bd4a76ea7b..62b7a8dbf5 100644 --- a/views/challengeMap/show.jade +++ b/views/challengeMap/show.jade @@ -112,21 +112,21 @@ block content a(href="/nonprofits/directory") Browse our nonprofit projects p * Complete all Waypoints, Bonfires, Ziplines and Basejumps to be assigned your first nonprofit project - //#announcementModal.modal(tabindex='-1') - // .modal-dialog - // .modal-content - // .modal-header.challenge-list-header We've updated our curriculum - // a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - // .modal-body - // h3.text-left We now have a 1,600 hour curriculum and tons of new challenges. Read more about it - // a(href='http://blog.freecodecamp.com', target='_blank') here - // | . - // a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='http://blog.freecodecamp.com/', target='_blank') Take me to the blog post. - // a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up! - //script. - // $(document).ready(function () { - // if (!localStorage || !localStorage.newCurriculum) { - // $('#announcementModal').modal('show'); - // localStorage.campWideMeeting = "true"; - // } - // }); + #announcementModal.modal(tabindex='-1') + .modal-dialog.animated.fadeInUp.fast-animation + .modal-content + .modal-header.challenge-list-header Join our Saturday Summit! + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body + h3.text-left Saturday at Noon EDT: We'll live-stream our Saturday Summit on Twitch.tv. Join us as our community turns 200 days old. We'll have Nonprofit Project demos from 6 of our campers.   + a(href='http://www.freecodecamp.com/twitch', target='_blank') Add it to your calendar here + | . + a.btn.btn-lg.btn-info.btn-block(name='_csrf', value=_csrf, aria-hidden='true', href='http://twitch.tv/freecodecamp', target='_blank') Follow us on Twitch.tv + a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Thanks for the heads-up! + script. + $(document).ready(function () { + if (!localStorage || !localStorage.day200) { + $('#announcementModal').modal('show'); + localStorage.day200 = "true"; + } + }); diff --git a/views/coursewares/showVideo.jade b/views/coursewares/showVideo.jade index 83b3ab759f..8b496d6c17 100644 --- a/views/coursewares/showVideo.jade +++ b/views/coursewares/showVideo.jade @@ -67,7 +67,7 @@ block content $('#complete-courseware-dialog').bind('keypress', modalControlEnterHandler); - if (user.progressTimestamps.length > 2) - a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank") + a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Challenge:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank") i.fa.fa-twitter   = phrase - else diff --git a/views/resources/unsubscribed.jade b/views/resources/unsubscribed.jade new file mode 100644 index 0000000000..d1de0b6398 --- /dev/null +++ b/views/resources/unsubscribed.jade @@ -0,0 +1,6 @@ +extends ../layout +block content + .panel.panel-info + .panel-body.text-center + h1 You have successfully been unsubscribed. + h2 Whatever you do, keep coding! :)