From dc4aa40a32e498fa4483c46daea1a1ccdac620ca Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 23 Feb 2015 07:47:43 +0900 Subject: [PATCH] Add bitly url shortening example to showHTML view --- app.js | 3 ++- public/js/main.js | 2 +- views/coursewares/showHTML.jade | 23 ++++++++++++++++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 846acd690b..f7bb248ebb 100644 --- a/app.js +++ b/app.js @@ -144,7 +144,8 @@ var trusted = [ 'https://*.togetherjs.com', 'wss://hub.togetherjs.com', '*.ytimg.com', - 'wss://fcctogether.herokuapp.com' + 'wss://fcctogether.herokuapp.com', + '*.bitly.com' ]; app.use(helmet.contentSecurityPolicy({ diff --git a/public/js/main.js b/public/js/main.js index d9162a53c9..c8b4d39d7a 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -66,7 +66,7 @@ $(document).ready(function() { completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash); }); - $('#completed-courseware').on('click', function() { + $('#complete-courseware').on('click', function() { $('#complete-courseware-dialog').modal('show'); }); diff --git a/views/coursewares/showHTML.jade b/views/coursewares/showHTML.jade index 25e1fbddd9..cb884bf531 100644 --- a/views/coursewares/showHTML.jade +++ b/views/coursewares/showHTML.jade @@ -68,11 +68,16 @@ block content var challengeName = !{JSON.stringify(name)}; var prodOrDev = !{JSON.stringify(environment)}; var started = Math.floor(Date.now() / 1000); + var url = ''; + var dashed = !{JSON.stringify(dashedName)}; + console.log(dashed); + .col-xs-12.col-sm-12.col-md-5.col-lg-6 #mainEditorPanel form.code .form-group.codeMirrorView textarea#codeEditor(autofocus=true) + script(src='/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js') .col-md-4.col-lg-3 .hidden-xs.hidden-sm img.iphone-position(src="https://s3.amazonaws.com/freecodecamp/iphone6-frame.png") @@ -82,8 +87,8 @@ block content .modal-dialog.animated.zoomIn.fast-animation .modal-content .modal-header.challenge-list-header= compliment - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - .modal-body(ng-controller="pairedWithController") + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body .text-center .animated.zoomInDown.delay-half span.completion-icon.ion-checkmark-circled.text-primary @@ -91,9 +96,10 @@ block content a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter) - if (points && points > 2) - 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") + a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank") i.fa.fa-twitter   = phrase + - else a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress @@ -104,3 +110,14 @@ block content a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × .modal-body include ../partials/coursewares + script. + $.ajax({ + url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fchallenges%2F' + dashed + '&format=txt' + }) + .success( + function(data) { + console.log(data); + url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Challenge:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript"; + $('.btn-twitter').attr('href', url); + } + );