Lorem ipsum dolor sit amet, consectetuer adipiscing elit
- +Even the all-powerful Pointing has no control about the blind texts it is an almost unorthographic life One day however a small line of blind text by the name of Lorem Ipsum decided to leave for the far World of Grammar.
diff --git a/src/js/services/twitter.js b/src/js/services/twitter.js index a3907921..d2b8008b 100644 --- a/src/js/services/twitter.js +++ b/src/js/services/twitter.js @@ -1,7 +1,18 @@ 'use strict'; +var url = require('url'); + module.exports = function(shariff) { - var url = encodeURIComponent(shariff.getURL()); + var shareUrl = url.parse('https://twitter.com/intent/tweet', true); + + // TODO FIXME: remove "encodeURIComponent()" from getShareText() + shareUrl.query.text = decodeURIComponent(shariff.getShareText()); + shareUrl.query.url = shariff.getURL(); + if (typeof shariff.options.twitterVia !== null) { + shareUrl.query.via = shariff.options.twitterVia; + } + delete shareUrl.search; + return { popup: true, shareText: 'tweet', @@ -12,6 +23,7 @@ module.exports = function(shariff) { 'en': 'Share on Twitter', 'es': 'Compartir en Twitter' }, - shareUrl: 'https://twitter.com/intent/tweet?text='+ shariff.getShareText() + '&url=' + url + shariff.getReferrerTrack() + // shareUrl: 'https://twitter.com/intent/tweet?text='+ shariff.getShareText() + '&url=' + url + shareUrl: url.format(shareUrl) + shariff.getReferrerTrack() }; }; diff --git a/src/js/shariff.js b/src/js/shariff.js index fa2361ac..13f76a09 100644 --- a/src/js/shariff.js +++ b/src/js/shariff.js @@ -67,6 +67,8 @@ _Shariff.prototype = { // services to be enabled in the following order services : ['twitter', 'facebook', 'googleplus', 'info'], + twitterVia: null, + // build URI from rel="canonical" or document.location url: function() { var url = global.document.location.href;