diff --git a/bower.json b/bower.json index 5fc2fd4..da404ae 100755 --- a/bower.json +++ b/bower.json @@ -38,14 +38,15 @@ "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", + "zeroclipboard": "~2.2.0", + "ng-clip": "~0.2.6" }, "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" } 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 c1c0ce0..eee4528 100644 --- a/client/index.html +++ b/client/index.html @@ -123,6 +123,8 @@ + + diff --git a/server/routes.js b/server/routes.js index a4fbc2f..c89c99a 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);