From ae62c1361e49571575d83d02c81e392f2700f863 Mon Sep 17 00:00:00 2001 From: Erick Guan Date: Fri, 26 Dec 2014 22:09:08 +0800 Subject: [PATCH] extends share links - change `iconClass` to `faIcon` - add `htmlIcon` to allow custom HTML - add reddit, linkedin, tumblr --- .../discourse/initializers/sharing-sources.js.es6 | 8 ++++---- app/assets/javascripts/discourse/lib/sharing.js.es6 | 6 ++++-- .../discourse/templates/components/share-source.hbs | 8 +++++++- app/assets/javascripts/discourse/templates/share.hbs | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/discourse/initializers/sharing-sources.js.es6 b/app/assets/javascripts/discourse/initializers/sharing-sources.js.es6 index ccdb15f0f..e48f4a9d1 100644 --- a/app/assets/javascripts/discourse/initializers/sharing-sources.js.es6 +++ b/app/assets/javascripts/discourse/initializers/sharing-sources.js.es6 @@ -14,7 +14,7 @@ export default { Sharing.addSource({ id: 'twitter', - iconClass: 'fa-twitter-square', + faIcon: 'fa-twitter-square', generateUrl: function(link, title) { return "http://twitter.com/intent/tweet?url=" + encodeURIComponent(link) + "&text=" + encodeURIComponent(title); }, @@ -24,7 +24,7 @@ export default { Sharing.addSource({ id: 'facebook', - iconClass: 'fa-facebook-square', + faIcon: 'fa-facebook-square', generateUrl: function(link, title) { return "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(link) + '&t=' + encodeURIComponent(title); }, @@ -33,7 +33,7 @@ export default { Sharing.addSource({ id: 'google+', - iconClass: 'fa-google-plus-square', + faIcon: 'fa-google-plus-square', generateUrl: function(link) { return "https://plus.google.com/share?url=" + encodeURIComponent(link); }, @@ -43,7 +43,7 @@ export default { Sharing.addSource({ id: 'email', - iconClass: 'fa-envelope-square', + faIcon: 'fa-envelope-square', generateUrl: function(link, title) { return "mailto:?to=&subject=" + encodeURIComponent('[' + Discourse.SiteSettings.title + '] ' + title) + "&body=" + encodeURIComponent(link); } diff --git a/app/assets/javascripts/discourse/lib/sharing.js.es6 b/app/assets/javascripts/discourse/lib/sharing.js.es6 index e695119c7..955618f07 100644 --- a/app/assets/javascripts/discourse/lib/sharing.js.es6 +++ b/app/assets/javascripts/discourse/lib/sharing.js.es6 @@ -9,8 +9,10 @@ // This id must be present in the `share_links` site setting too id: 'twitter', - // The icon that will be displayed - iconClass: 'fa-twitter-square', + // The icon that will be displayed, choose between font awesome class name `faIcon` and custom HTML `htmlIcon`. + // When both provided, prefer `faIcon` + faIcon: 'fa-twitter-square' + htmlIcon: '', // A callback for generating the remote link from the `link` and `title` generateUrl: function(link, title) { diff --git a/app/assets/javascripts/discourse/templates/components/share-source.hbs b/app/assets/javascripts/discourse/templates/components/share-source.hbs index 252538793..aca17c8b7 100644 --- a/app/assets/javascripts/discourse/templates/components/share-source.hbs +++ b/app/assets/javascripts/discourse/templates/components/share-source.hbs @@ -1 +1,7 @@ - + + {{#if source.faIcon}} + + {{else}} + {{{source.htmlIcon}}} + {{/if}} + diff --git a/app/assets/javascripts/discourse/templates/share.hbs b/app/assets/javascripts/discourse/templates/share.hbs index 0797ac723..2270c3778 100644 --- a/app/assets/javascripts/discourse/templates/share.hbs +++ b/app/assets/javascripts/discourse/templates/share.hbs @@ -6,7 +6,7 @@ {{/if}}
- +