From a5377a698ae279e12c95067446d0536b28601aa7 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Mon, 11 Jan 2016 21:31:30 +0000 Subject: [PATCH 1/5] Fixed new API route --- server/routes.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/server/routes.js b/server/routes.js index a4fbc2f..341c681 100755 --- a/server/routes.js +++ b/server/routes.js @@ -1,7 +1,19 @@ 'use strict'; var errors = require('./components/errors'); var http = require('http'); +var url = require('url'); +function _parseUrl(u){ + var parts = url.parse(u, true, true); + var path = parts.pathname.split('/').filter(function(arg){ + return arg; + }); + if (path.length == 2){ + //probably a mix, reconstruct url and return + return parts.protocol + "//" + parts.host + "/mix/" + path[1]; + } + return u; +} module.exports = function (app) { app.route('/config') @@ -21,7 +33,7 @@ module.exports = function (app) { app.route('/*') .get(function (req, res) { if (req.headers['user-agent'].indexOf('facebookexternalhit') > -1) { - var url = (app.get('apiUrl') + req.path + '/').replace(/([^:]\/)\/+/g, "$1"); + var url = _parseUrl((app.get('apiUrl') + req.path + '/').replace(/([^:]\/)\/+/g, "$1")); console.log('Api url: ' + url); http.get(url, function (api_res) { var body = ''; @@ -29,7 +41,7 @@ module.exports = function (app) { body += chunk; }); api_res.on('end', function() { - res.render('social/facebook/mix', JSON.parse(body)); + res.render('social/facebook/mix', JSON.parse(body)); }); }).on('error', function (e) { console.log("Got error: " + e.message); From 7af981c4ffa12010d143a84292bbe6f6544470e5 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Mon, 11 Jan 2016 21:52:59 +0000 Subject: [PATCH 2/5] Fixed trailing slash in FB redirect --- server/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/routes.js b/server/routes.js index 341c681..c89c99a 100755 --- a/server/routes.js +++ b/server/routes.js @@ -10,7 +10,7 @@ function _parseUrl(u){ }); if (path.length == 2){ //probably a mix, reconstruct url and return - return parts.protocol + "//" + parts.host + "/mix/" + path[1]; + return parts.protocol + "//" + parts.host + "/mix/" + path[1] + "/"; } return u; } From 429689c79f7a229a7bf9f412f7ae20d25c19b43f Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Tue, 12 Jan 2016 10:47:00 +0000 Subject: [PATCH 3/5] Added back ngclipboard --- bower.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 5fc2fd4..fd46e92 100755 --- a/bower.json +++ b/bower.json @@ -38,14 +38,14 @@ "smalot-bootstrap-datetimepicker": "~2.3.4", "js-data-angular": "~3.1.0", "ui-select": "angular-ui-select#~0.13.2", - "ngInfiniteScroll": "~1.2.1" + "ngInfiniteScroll": "~1.2.1", + "ngclipboard": "~1.1.0" }, "devDependencies": { "angular-mocks": ">=1.2.*", "angular-scenario": ">=1.2.*" }, "resolutions": { - "js-data-angular": "~3.1.0", "angular-bootstrap": "~0.14.3", "angular": "1.4.8" } From 7dad41ec8b074f734228d469af599604d1bf5565 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Tue, 12 Jan 2016 13:49:16 +0000 Subject: [PATCH 4/5] Added ng-clip --- bower.json | 3 ++- client/index.html | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index fd46e92..da404ae 100755 --- a/bower.json +++ b/bower.json @@ -39,7 +39,8 @@ "js-data-angular": "~3.1.0", "ui-select": "angular-ui-select#~0.13.2", "ngInfiniteScroll": "~1.2.1", - "ngclipboard": "~1.1.0" + "zeroclipboard": "~2.2.0", + "ng-clip": "~0.2.6" }, "devDependencies": { "angular-mocks": ">=1.2.*", diff --git a/client/index.html b/client/index.html index c1c0ce0..11f3935 100644 --- a/client/index.html +++ b/client/index.html @@ -123,6 +123,8 @@ + + From 96a00bb685b19c2768bad0263e7c64b7b769b982 Mon Sep 17 00:00:00 2001 From: Fergal Moran Date: Tue, 12 Jan 2016 22:42:21 +0000 Subject: [PATCH 5/5] Fixed up share links --- .../app/directives/audio/audio.player.directive.js | 9 +++++++-- client/app/helpers/social.js | 14 +++++++++----- client/app/views/mixes/upload/upload.controller.js | 5 +++-- client/index.html | 4 ++-- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/client/app/directives/audio/audio.player.directive.js b/client/app/directives/audio/audio.player.directive.js index dafb69f..62dd188 100644 --- a/client/app/directives/audio/audio.player.directive.js +++ b/client/app/directives/audio/audio.player.directive.js @@ -48,10 +48,15 @@ angular.module('dssWebApp') {size: 'md'}); }; $scope.shareFacebook = function () { - helpers.social.postToFacebook($scope.mix); + helpers.social.postToFacebook( + $scope.mix.title, + $scope.mix.mix_image, + $scope.mix.description, + $state.href('root.user.mix', {user: $scope.mix.user.slug, mix: $scope.mix.slug}) + ); }; $scope.shareTwitter = function () { - helpers.social.postToTwitter($scope.mix); + helpers.social.postToTwitter($state.href('root.user.mix', {user: $scope.mix.user.slug, mix: $scope.mix.slug})); }; $scope.toggleFollow = function () { if ($scope.currentUser) { diff --git a/client/app/helpers/social.js b/client/app/helpers/social.js index 5292c01..adb4d33 100644 --- a/client/app/helpers/social.js +++ b/client/app/helpers/social.js @@ -1,4 +1,8 @@ var helpers = helpers || {}; +function _getLink(url){ + return window.location.protocol + "//" + (window.location.host + '/' + url).replace(/([^:]\/)\/+/g, '$1'); +} + if (FB) { FB.init({ appId: '154504534677009', @@ -9,17 +13,17 @@ if (FB) { }); } helpers.social = { - postToFacebook: function (mix) { + postToFacebook: function (title, image, description, url) { FB.getLoginStatus(function (oResponse) { if (oResponse.status === "connected") { return FB.ui({ method: "feed", name: "Check out this mix on Deep South Sounds", display: "iframe", - link: "http://" + window.location.host + "/mixes/" + mix.slug, - picture: mix.mix_image, - caption: mix.title, - description: mix.description + link: _getLink(url), + picture: _getLink(image), + caption: title, + description: description }, function (response) { if (response && response.post_id) { return utils.showAlert("Success", "Post shared to facebook"); diff --git a/client/app/views/mixes/upload/upload.controller.js b/client/app/views/mixes/upload/upload.controller.js index 6ff96d1..3dfe1e9 100755 --- a/client/app/views/mixes/upload/upload.controller.js +++ b/client/app/views/mixes/upload/upload.controller.js @@ -110,10 +110,11 @@ angular.module('dssWebApp') var _processResult = function (result) { $scope.mix = result; $timeout(function () { + var url = $state.href('root.user.mix', {user: $scope.mix.user.slug, mix: $scope.mix.slug}); $scope.waveformFooter = "Waveform processing is taking longer than expected.
" + - "Your mix should be available Here"; + "Your mix should be available Here"; $scope.$apply(); - }, 120000); + }, 1200); var imageFile = document.getElementById('mix-image-fileinput').files[0]; if (imageFile) { diff --git a/client/index.html b/client/index.html index 11f3935..eee4528 100644 --- a/client/index.html +++ b/client/index.html @@ -123,8 +123,8 @@ - - + +