From ff4fbefc0a3e39d21e1380ffa27a0eb827cf3dd5 Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Sun, 22 Feb 2015 13:24:26 +0900 Subject: [PATCH 1/4] Cleaned up where do I belong challenge --- seed_data/bonfires.json | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json index 2f9da459a1..04663879c8 100644 --- a/seed_data/bonfires.json +++ b/seed_data/bonfires.json @@ -239,15 +239,13 @@ "name": "Where do I belong", "difficulty": "1.61", "description": [ - "Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument)." + "Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).", + "For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index)." ], "challengeSeed": "function where(arr, num) {\n // Find my place in this sorted array.\r\n return num;\r\n}\n\nwhere([40, 60], 50);", "tests": [ - "var numbers = [10, 20, 30, 40, 50], num = 35;", - "var indexForNum = where(numbers, num);", - "assert.equal(indexForNum, 3, '35 should be inserted at index 3');", - "var indexFor30 = where(numbers, 30);", - "assert.equal(indexFor30, 2, '30 should be inserted at index 2');" + "expect(where([10, 20, 30, 40, 50], 35)).to.eql(3);", + "expect(where([10, 20, 30, 40, 50], 30)).to.eql(2);" ] }, { From a087068022793acce071a5018247aa3082d284ab Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Sun, 22 Feb 2015 13:55:27 +0900 Subject: [PATCH 2/4] Fix drop it like its hot challenge --- seed_data/bonfires.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/seed_data/bonfires.json b/seed_data/bonfires.json index 04663879c8..b95c4ba83c 100644 --- a/seed_data/bonfires.json +++ b/seed_data/bonfires.json @@ -244,8 +244,8 @@ ], "challengeSeed": "function where(arr, num) {\n // Find my place in this sorted array.\r\n return num;\r\n}\n\nwhere([40, 60], 50);", "tests": [ - "expect(where([10, 20, 30, 40, 50], 35)).to.eql(3);", - "expect(where([10, 20, 30, 40, 50], 30)).to.eql(2);" + "expect(where([10, 20, 30, 40, 50], 35)).to.equal(3);", + "expect(where([10, 20, 30, 40, 50], 30)).to.equal(2);" ] }, { @@ -419,9 +419,9 @@ ], "challengeSeed": "function drop(arr, func) {\n // Drop them elements.\r\n return arr;\r\n}\n\ndrop([1, 2, 3], function(n) {return n < 3; });", "tests": [ - "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n < 3; }), [3, 4], 'should return remaining array');", - "assert.deepEqual(drop([1, 2, 3], function(n) {return n < 0; }), [1, 2, 3], 'should return complete array if predicate met in first element.');", - "assert.deepEqual(drop([1, 2, 3, 4], function(n) {return n < 5; }), [], 'should return an empty array if predicate does not return true');" + "expect(drop([1, 2, 3, 4], function(n) {return n >= 3; })).to.eqls([3, 4]);", + "expect(drop([1, 2, 3], function(n) {return n > 0; })).to.eqls([1, 2, 3]);", + "expect(drop([1, 2, 3, 4], function(n) {return n > 5; })).to.eqls([]);" ] }, { From 380e301a9a7cbfa35da12c82725e53d532771546 Mon Sep 17 00:00:00 2001 From: Mike Date: Sun, 22 Feb 2015 08:05:32 -0700 Subject: [PATCH 3/4] Flip windows and mac gitter links --- views/resources/chat.jade | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/resources/chat.jade b/views/resources/chat.jade index b300dcc3e7..9647804dea 100644 --- a/views/resources/chat.jade +++ b/views/resources/chat.jade @@ -6,9 +6,9 @@ block content a(href="http://github.com/join", target='_blank') here | . li Download the chat room app on   - a(href="https://update.gitter.im/osx/latest") Windows + a(href="https://update.gitter.im/win/latest") Windows | ,  - a(href="https://update.gitter.im/win/latest") Mac + a(href="https://update.gitter.im/osx/latest") Mac | ,  a(href="http://appstore.com/gitter") iPhone | ,  or   From 0674466f5fc4e1390a612c94599d9bce8d0d14cb Mon Sep 17 00:00:00 2001 From: Nathan Leniz Date: Mon, 23 Feb 2015 08:01:55 +0900 Subject: [PATCH 4/4] Add bitly url shortening to twitter buttons --- app.js | 3 ++- views/bonfire/show.jade | 22 ++++++++++++++-------- views/challenges/show.jade | 15 +++++++++++++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index 106c3a6d6b..74c920dcec 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/views/bonfire/show.jade b/views/bonfire/show.jade index bfa7fdbd77..01cbe87077 100644 --- a/views/bonfire/show.jade +++ b/views/bonfire/show.jade @@ -93,6 +93,7 @@ block content var challengeName = !{JSON.stringify(name)}; var started = Math.floor(Date.now() / 1000); var _ = R; + var dashed = !{JSON.stringify(dashedName)}; .col-xs-12.col-sm-12.col-md-8 #mainEditorPanel form.code @@ -127,17 +128,22 @@ block content - 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%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(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 - //#all-bonfires-dialog.modal(tabindex='-1') - // .modal-dialog.animated.fadeInUp.fast-animation - // .modal-content - // .modal-header.challenge-list-header Bonfires - // a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - // .modal-body - // include ../partials/bonfires + script. + $.ajax({ + url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fbonfires%2F' + dashed + '&format=txt' + }) + .success( + function (data) { + console.log(data); + url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript"; + $('.btn-twitter').attr('href', url); + } + ); + diff --git a/views/challenges/show.jade b/views/challenges/show.jade index 9de6372f82..becbc7cdb8 100644 --- a/views/challenges/show.jade +++ b/views/challenges/show.jade @@ -31,7 +31,7 @@ block content - if (cc) a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-challenge-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge - 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%23#{number}:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{number}&hashtags=LearnToCode, JavaScript" target="_blank") + a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank") i.fa.fa-twitter   = phrase - else @@ -42,4 +42,15 @@ block content .modal-header.challenge-list-header Challenges a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × .modal-body - include ../partials/challenges \ No newline at end of file + include ../partials/challenges + script. + $.ajax({ + url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fchallenges%2F' + !{JSON.stringify(number)} + '&format=txt' + }) + .success( + function (data) { + console.log(data); + url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript"; + $('.btn-twitter').attr('href', url); + } + ); \ No newline at end of file