summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-11-08 22:28:55 -0500
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2010-11-08 22:28:55 -0500
commitf08e6644993e50c0b6ab777521e42aa56740a1c3 (patch)
treec1d65c091db27dfdf24950d582491a8adb552806
parente30fb53b1db25813087a1acf39cbc353a07c4011 (diff)
downloadaskbot-f08e6644993e50c0b6ab777521e42aa56740a1c3.tar.gz
askbot-f08e6644993e50c0b6ab777521e42aa56740a1c3.tar.bz2
askbot-f08e6644993e50c0b6ab777521e42aa56740a1c3.zip
first scratch on sharing buttons
-rw-r--r--askbot/conf/__init__.py1
-rw-r--r--askbot/conf/social_sharing.py20
-rw-r--r--askbot/skins/default/media/images/sprite.pngbin0 -> 1655 bytes
-rw-r--r--askbot/skins/default/media/js/com.cnprog.post.js45
-rw-r--r--askbot/skins/default/media/js/com.cnprog.utils.js4
-rwxr-xr-xaskbot/skins/default/media/style/style.css14
-rw-r--r--askbot/skins/default/templates/question.html5
7 files changed, 88 insertions, 1 deletions
diff --git a/askbot/conf/__init__.py b/askbot/conf/__init__.py
index 3773daa4..ac286861 100644
--- a/askbot/conf/__init__.py
+++ b/askbot/conf/__init__.py
@@ -11,6 +11,7 @@ import askbot.conf.external_keys
import askbot.conf.skin_general_settings
import askbot.conf.user_settings
import askbot.conf.markup
+import askbot.conf.social_sharing
#import main settings object
from askbot.conf.settings_wrapper import settings
diff --git a/askbot/conf/social_sharing.py b/askbot/conf/social_sharing.py
new file mode 100644
index 00000000..3b3357d9
--- /dev/null
+++ b/askbot/conf/social_sharing.py
@@ -0,0 +1,20 @@
+"""
+Social sharing settings
+"""
+from askbot.conf.settings_wrapper import settings
+from askbot.deps.livesettings import ConfigurationGroup, BooleanValue
+from django.utils.translation import ugettext as _
+
+SOCIAL_SHARING = ConfigurationGroup(
+ 'SOCIAL_SHARING',
+ _('Sharing content on social networks'),
+ )
+
+settings.register(
+ BooleanValue(
+ SOCIAL_SHARING,
+ 'ENABLE_SOCIAL_SHARING',
+ default=False,
+ description=_('Check to enable sharing of questions on Twitter and Facebook')
+ )
+)
diff --git a/askbot/skins/default/media/images/sprite.png b/askbot/skins/default/media/images/sprite.png
new file mode 100644
index 00000000..5eb6f68c
--- /dev/null
+++ b/askbot/skins/default/media/images/sprite.png
Binary files differ
diff --git a/askbot/skins/default/media/js/com.cnprog.post.js b/askbot/skins/default/media/js/com.cnprog.post.js
index 87b12a61..33a9f3b8 100644
--- a/askbot/skins/default/media/js/com.cnprog.post.js
+++ b/askbot/skins/default/media/js/com.cnprog.post.js
@@ -1061,12 +1061,57 @@ function createComments(type) {
};
}
+var socialSharing = function(){
+
+ var SERVICE_DATA = {
+ //url - template for the sharing service url, params are for the popup
+ twitter: {
+ url: "http://twitter.com/share?url={URL}&ref=twitbtn&text={TEXT}",
+ params: "width=820,height=526,toolbar=1,status=1,resizable=1,scrollbars=1"
+ },
+ facebook: {
+ url: "http://www.facebook.com/sharer.php?u={URL}&ref=fbshare&t={TEXT}",
+ params: "width=630,height=436,toolbar=1,status=1,resizable=1,scrollbars=1"
+ }
+ };
+ var URL = "";
+ var TEXT = "";
+
+ var share_page = function(service_name){
+ if (SERVICE_DATA[service_name]){
+ var url = SERVICE_DATA[service_name]['url'];
+ url = url.replace('{URL}', URL);
+ url = url.replace('{TEXT}', TEXT);
+ alert(url);
+ var params = SERVICE_DATA[service_name]['params'];
+ if(!window.open(url, "sharing", params)){
+ window.location.href=share_url;
+ }
+ }
+ }
+
+ return{
+ init: function(page_url, text_to_share){
+ URL = window.location.href;
+ TEXT = escape($('div.headNormal > a').html());
+ var fb = $('a.fb-share')
+ var tw = $('a.twitter-share');
+ copyAltToTitle(fb);
+ copyAltToTitle(tw);
+ setupButtonEventHandlers(fb, function(){share_page("facebook")});
+ setupButtonEventHandlers(tw, function(){share_page("twitter")});
+ },
+ }
+}();
+
$(document).ready(function() {
questionComments.init();
questionRetagger.init();
answerComments.init();
+ socialSharing.init();
});
+
/*
Prettify
http://www.apache.org/licenses/LICENSE-2.0
diff --git a/askbot/skins/default/media/js/com.cnprog.utils.js b/askbot/skins/default/media/js/com.cnprog.utils.js
index d9a4a0ee..aec04ffd 100644
--- a/askbot/skins/default/media/js/com.cnprog.utils.js
+++ b/askbot/skins/default/media/js/com.cnprog.utils.js
@@ -3,6 +3,10 @@ var mediaUrl = function(resource){
return scriptUrl + 'm/' + askbotSkin + '/' + resource;
};
+var copyAltToTitle = function(sel){
+ sel.attr('title', sel.attr('alt'));
+};
+
var showMessage = function(object, msg) {
var div = $('<div class="vote-notification"><h3>' + msg + '</h3>(' +
$.i18n._('click to close') + ')</div>');
diff --git a/askbot/skins/default/media/style/style.css b/askbot/skins/default/media/style/style.css
index ff5ceacc..ed8802c1 100755
--- a/askbot/skins/default/media/style/style.css
+++ b/askbot/skins/default/media/style/style.css
@@ -2764,6 +2764,20 @@ img.gravatar {
font-weight:bold;
}
+.fb-share, .twitter-share {
+ background: url(../images/sprite.png) no-repeat;
+ text-indent:-100em;
+ width:25px;
+ height:25px;
+ display:block;
+}
+.fb-share {
+ background-position: -25px 0px;
+}
+.twitter-share {
+ margin-top:10px;
+ background-position: 0px 0px;
+}
/* Pretty printing styles. Used with prettify.js. */
.str { color: #080; }
diff --git a/askbot/skins/default/templates/question.html b/askbot/skins/default/templates/question.html
index f185924f..6c96cc03 100644
--- a/askbot/skins/default/templates/question.html
+++ b/askbot/skins/default/templates/question.html
@@ -71,7 +71,10 @@
{% if question.favourite_count != 0 %}{{ question.favourite_count }}{% endif %}
</div>
{% endif %}
-
+ {% if settings.ENABLE_SOCIAL_SHARING %}
+ <a class="twitter-share" alt="{% trans %}Share this question on twitter{% endtrans %}"></a>
+ <a class="fb-share" alt="{% trans %}Share this question on facebook{% endtrans %}"></a>
+ {% endif %}
</div>
</td>
<td>