Skip to content
This repository

Add a new setting "SHARING_SUFFIX_TEXT" that can be filled with #37

Closed
wants to merge 1 commit into from

2 participants

Sven Lankes Evgeny Fadeev
Sven Lankes

a text that is added to each social media sharing. This way it is
possible to have all twitter/identi.ca postings made from an askbot
instance include something like for example a hashtag pointing
to the instance.

This was requested for ask.fedoraproject.org: http://ask.fedoraproject.org/question/444/rfe-add-askfedora-fedora-tags-to-twitter-identica

What this change does is change the origin of the text that is posted to the social networking sites from h1 > a to h1 > a.attr('title') - and the a.title attribute is filled with the suffix-snippet earlier. I couldn't think of a cleaner way to do this. I you can - please let me know.

Thanks.

Sven Lankes Add a new setting "SHARING_SUFFIX_TEXT" that can be filled with
a text that is added to each social media sharing. This way it is
possible to have all twitter/identi.ca postings made from an askbot
instance include something like for example a hashtag pointing
to the instance.

This was requested for ask.fedoraproject.org: http://ask.fedoraproject.org/question/444/rfe-add-askfedora-fedora-tags-to-twitter-identica
7193abc
Evgeny Fadeev

Hello Sven, this is a very nice feature indeed!

Could you try make it work also when a sharing button is clicked?
I think a better way is to add the sharing suffix explicitly into js and then append it to the text.

There is a data structure in js for askbot: askbot['data'], so a value can be added to it at askbot['data']['social_sharing_suffix'].

That way the suffix will be added automatically regardless on whether you click on the button or the plain text link.

Thank you.

Evgeny Fadeev
Owner

Implemented this feature after looking at this approach. Thank you!

Evgeny Fadeev evgenyfadeev closed this January 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Nov 27, 2011
Sven Lankes Add a new setting "SHARING_SUFFIX_TEXT" that can be filled with
a text that is added to each social media sharing. This way it is
possible to have all twitter/identi.ca postings made from an askbot
instance include something like for example a hashtag pointing
to the instance.

This was requested for ask.fedoraproject.org: http://ask.fedoraproject.org/question/444/rfe-add-askfedora-fedora-tags-to-twitter-identica
7193abc
This page is out of date. Refresh to see the latest.
14  askbot/conf/social_sharing.py
@@ -3,7 +3,7 @@
3 3
 """
4 4
 from askbot.conf.settings_wrapper import settings
5 5
 from askbot.conf.super_groups import EXTERNAL_SERVICES
6  
-from askbot.deps.livesettings import ConfigurationGroup, BooleanValue
  6
+from askbot.deps.livesettings import ConfigurationGroup, BooleanValue, StringValue
7 7
 from django.utils.translation import ugettext as _
8 8
 
9 9
 SOCIAL_SHARING = ConfigurationGroup(
@@ -56,3 +56,15 @@
56 56
         description=_('Check to enable sharing of questions on Google+')
57 57
     )
58 58
 )
  59
+
  60
+settings.register(
  61
+    StringValue(
  62
+        SOCIAL_SHARING,
  63
+        'SHARING_SUFFIX_TEXT',
  64
+        default='',
  65
+        description=_('Text (e.g. Hashtag) to add to all social sharing options'),
  66
+        help_text=_(
  67
+                    'Text to add to all social sharing options. Keep it short!'
  68
+                    )
  69
+    )
  70
+)
2  askbot/skins/common/media/js/post.js
@@ -1587,7 +1587,7 @@ var socialSharing = function(){
1587 1587
     return {
1588 1588
         init: function(){
1589 1589
             URL = window.location.href;
1590  
-            TEXT = escape($('h1 > a').html());
  1590
+            TEXT = escape($('h1 > a').attr('title'));
1591 1591
             var fb = $('a.facebook-share')
1592 1592
             var tw = $('a.twitter-share');
1593 1593
             var ln = $('a.linkedin-share');
4  askbot/skins/default/templates/question/question_card.html
@@ -4,7 +4,9 @@
4 4
 </div>
5 5
 <div class="question-content">
6 6
 
7  
-    <h1><a href="{{ question.get_absolute_url() }}">{{ question.get_question_title() }}</a></h1>
  7
+    <h1><a href="{{ question.get_absolute_url() }}"
  8
+        {% if settings.SHARING_SUFFIX_TEXT %}title="{{question.get_question_title()}} {{ settings.SHARING_SUFFIX_TEXT }}{% endif %}"
  9
+    >{{ question.get_question_title() }}</a></h1>
8 10
     {% include "question/question_tags.html" %}
9 11
     <div id="question-table" {% if question.deleted %}class="deleted"{%endif%}>
10 12
         <div class="question-body">
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.