2015-01-14 06:26:05 +08:00
|
|
|
/**
|
|
|
|
If you want to add a new sharing source to Discourse, you can do so like this:
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
import Sharing from 'discourse/lib/sharing';
|
|
|
|
|
|
|
|
Sharing.addSource({
|
|
|
|
|
|
|
|
// This id must be present in the `share_links` site setting too
|
|
|
|
id: 'twitter',
|
|
|
|
|
|
|
|
// The icon that will be displayed
|
|
|
|
iconClass: 'fa-twitter-square',
|
|
|
|
|
|
|
|
// A callback for generating the remote link from the `link` and `title`
|
|
|
|
generateUrl: function(link, title) {
|
|
|
|
return "http://twitter.com/intent/tweet?url=" + encodeURIComponent(link) + "&text=" + encodeURIComponent(title);
|
|
|
|
},
|
|
|
|
|
|
|
|
// If true, opens in a popup of `popupHeight` size. If false it's opened in a new tab
|
|
|
|
shouldOpenInPopup: true,
|
|
|
|
popupHeight: 265
|
|
|
|
});
|
|
|
|
```
|
|
|
|
**/
|
|
|
|
|
2015-02-13 02:03:32 +08:00
|
|
|
var _sources = {};
|
2015-01-14 06:26:05 +08:00
|
|
|
|
|
|
|
export default {
|
2015-02-13 02:03:32 +08:00
|
|
|
addSource(source) {
|
|
|
|
_sources[source.id] = source;
|
2015-01-14 06:26:05 +08:00
|
|
|
},
|
|
|
|
|
2015-02-13 02:03:32 +08:00
|
|
|
activeSources() {
|
|
|
|
const enabled = Discourse.SiteSettings.share_links.split('|');
|
|
|
|
return enabled.map(s => _sources[s]).compact();
|
2015-01-14 06:26:05 +08:00
|
|
|
}
|
|
|
|
};
|