Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to activate 'Share' with facebook button #15

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions sc/social/like/browser/stylesheets/social_like.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
#viewlet-social-like {margin-top: 5px;}
#viewlet-social-like .twitter-count-horizontal {height: 20px !important;}
#viewlet-social-like .fb_edge_widget_with_comment {position: relative; margin-top: 0px;}
.twitter-share-button {margin-top: 0.8px;}
.horizontal .fb_iframe_widget iframe {height: 23px !important;}

#viewlet-social-like ul.like-buttons{
float: left;
list-style: none;
margin: 5px 0 5px 0;
padding: 0;
width: 100%;
list-style-type: none;
}

#viewlet-social-like ul.like-buttons li{
display: block;
float: left;
}
72 changes: 40 additions & 32 deletions sc/social/like/browser/templates/sociallikes.pt
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
<div id="viewlet-social-like"
tal:attributes="class view/typebutton"
style="display:none" i18n:domain="sc.social.like" tal:condition="view/enabled">
<tal:gp tal:condition="view/gp_enabled">
<tal:block tal:define="button python:{'vertical':'tall','horizontal':'medium'}; vbutton view/typebutton">
<div id="plusonebt"></div>
<script type="text/javascript" tal:content="python:'''\n jQuery(document).ready(function(){ \n gapi.plusone.render('plusonebt',{'size': '%s','annotation': 'bubble'}) \n }); ''' %(button[str(vbutton)])" >
</script>
</tal:block>
</tal:gp>
<tal:twitter tal:condition="view/twitter_enabled">
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<a href="//twitter.com/share" class="twitter-share-button" tal:attributes="data-count view/typebutton;
data-via view/twittvia;
data-url here/absolute_url;
data-lang view/language;
data-text here/Title;">Tweet</a>
</tal:twitter>
<tal:fb
tal:condition="view/fb_enabled"
tal:define="button python:{'vertical':'box_count','horizontal':'button_count'};
vbutton view/typebutton">
<iframe tal:attributes="src python:'https://www.facebook.com/plugins/like.php?locale=%s&href=%s&amp;send=false&amp;layout=%s&amp;show_faces=true&amp;action=%s' %(view.language,here.absolute_url(),button[str(vbutton)],view.fbaction)"
style="border:none; overflow:hidden; height:21px;"></iframe>
</tal:fb>
</div>
i18n:domain="sc.social.like" tal:condition="view/enabled">

<ul class="like-buttons">
<li class="g-plus-one" tal:condition="view/gp_enabled">
<tal:block tal:define="button python:{'vertical':'tall','horizontal':'medium'}; vbutton view/typebutton">
<div id="plusonebt"></div>
<script type="text/javascript" tal:content="python:'''\n jQuery(document).ready(function(){ \n gapi.plusone.render('plusonebt',{'size': '%s','annotation': 'bubble'}) \n }); ''' %(button[str(vbutton)])" >
</script>
</tal:block>
</li>

<li class="twitter-like" tal:condition="view/twitter_enabled">
<script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
<a href="//twitter.com/share" class="twitter-share-button" tal:attributes="data-count view/typebutton;
data-via view/twittvia;
data-lang view/language;
data-text here/Title;">Tweet</a>
</li>

<li class="fb-like" tal:condition="view/fb_enabled">

<script type="text/javascript" tal:condition="view/enabled">
jQuery(function () {
jQuery("div#viewlet-social-like").each(function(){
jQuery(this).fadeIn(3000);
jQuery(this).removeAttr("style");
});
});
</script>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/fr_FR/all.js#xfbml=1&appId=321358197994003";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like"
data-layout="button_count"
data-show-faces="false"
data-font="arial"
data-send=""
data-width=""
tal:attributes="data-send python: view.fb_typebutton == 'share_this' and 'true' or 'false'"></div>

</li>
</ul>
</div>
2 changes: 2 additions & 0 deletions sc/social/like/browser/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class BaseLikeViewlet(ViewletBase):
twitter_enabled = False
twittvia = ''
fb_enabled = False
fb_typebutton = ''
fbaction = ''
fbadmins = ''
gp_enabled = False
Expand All @@ -74,6 +75,7 @@ def __init__(self, context, request, view, manager):
self.twitter_enabled = self.sheet.getProperty("twitter_enabled", True)
self.twittvia = self.sheet.getProperty("twittvia", "")
self.fb_enabled = self.sheet.getProperty("fb_enabled", True)
self.fb_typebutton = self.sheet.getProperty("fb_typebutton", "")
self.fbaction = self.sheet.getProperty("fbaction", "")
self.fbadmins = self.sheet.getProperty("fbadmins", "")
self.gp_enabled = self.sheet.getProperty("gp_enabled", True)
Expand Down
16 changes: 15 additions & 1 deletion sc/social/like/controlpanel/likes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm

buttonTypes = SimpleVocabulary([
SimpleTerm(value=u'like', title=_(u'Like')),
SimpleTerm(value=u'share_this', title=_(u'Share this')),
])

verbs = SimpleVocabulary([
SimpleTerm(value=u'like', title=_(u'Like')),
SimpleTerm(value=u'recommend', title=_(u'Recommend')),
Expand Down Expand Up @@ -90,13 +95,21 @@ class IFbSchema(Interface):
required=False,
)

fb_typebutton = Choice(
title=_(u"Choose the type of button you want"),
required=True,
default=u'like',
vocabulary=buttonTypes,
)

fbaction = Choice(
title=_(u'Verb to display'),
description=_(
u'help_verb_display',
default=u"The verb to display in the facebook button. "
u"Currently only 'like' and 'recommend' are "
u"supported.",
u"supported."
u"Only used for 'Like' button type.",
),
required=True,
default=u'like',
Expand Down Expand Up @@ -158,6 +171,7 @@ class FbControlPanelAdapter(BaseControlPanelAdapter):
implements(IFbSchema)

fb_enabled = ProxyFieldProperty(IFbSchema['fb_enabled'])
fb_typebutton = ProxyFieldProperty(IFbSchema['fb_typebutton'])
fbaction = ProxyFieldProperty(IFbSchema['fbaction'])
fbadmins = ProxyFieldProperty(IFbSchema['fbadmins'])

Expand Down
1 change: 1 addition & 0 deletions sc/social/like/profiles/default/propertiestool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<property name="twitter_enabled" type="boolean">True</property>
<property name="twittvia" type="string" purge="False"></property>
<property name="fb_enabled" type="boolean">True</property>
<property name="fb_typebutton" type="string" purge="False"></property>
<property name="fbaction" type="string" purge="False"></property>
<property name="fbadmins" type="string" purge="False"></property>
<property name="gp_enabled" type="boolean">True</property>
Expand Down
1 change: 1 addition & 0 deletions sc/social/like/profiles/to2000/propertiestool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<property name="twitter_enabled" type="boolean">True</property>
<property name="twittvia" type="string" purge="False"></property>
<property name="fb_enabled" type="boolean">True</property>
<property name="fb_typebutton" type="string" purge="False"></property>
<property name="fbaction" type="string" purge="False"></property>
<property name="fbadmins" type="string" purge="False"></property>
<property name="gp_enabled" type="boolean">False</property>
Expand Down