Skip to content

Commit

Permalink
Update Facebook plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Aug 1, 2017
1 parent 10e99b3 commit d3627c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
18 changes: 7 additions & 11 deletions sc/social/like/plugins/facebook/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
from zope.component import getMultiAdapter


BASE_URL = 'https://www.facebook.com/plugins/like.php?'
PARAMS = 'locale={0}&href={1}&send=false&layout={2}&show_faces=true&action={3}'


class PluginView(BrowserView):

fb_enabled = False
Expand Down Expand Up @@ -62,13 +58,13 @@ def is_plone_5(self):

def fbjs(self):
js_source = """
(function() {{
var po = document.createElement('script');
po.async = true;
po.src = document.location.protocol + '//connect.facebook.net/{0}/all.js#xfbml=1';
var head = document.getElementsByTagName('head')[0];
head.appendChild(po);
}}());
(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/{0}/sdk.js#xfbml=1&version=v2.10";
fjs.parentNode.insertBefore(js, fjs);
}}(document, 'script', 'facebook-jssdk'));
""".format(self.language)
return js_source

Expand Down
2 changes: 1 addition & 1 deletion sc/social/like/plugins/facebook/templates/metadata.pt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
</tal:image>
<meta tal:condition="view/admins" property="fb:admins" tal:attributes="content view/admins" />
<meta tal:condition="view/app_id" property="fb:app_id" tal:attributes="content view/app_id" />
<script type="application/javascript" tal:content="view/fbjs"></script>
<script type="application/javascript" tal:content="structure view/fbjs"></script>
</tal:fb>
4 changes: 2 additions & 2 deletions sc/social/like/tests/test_plugin_facebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ def test_plugin_language(self):
self.document.setLanguage('pt-br')
view = document.restrictedTraverse(plugin_view)
html = view.metadata()
self.assertIn('connect.facebook.net/pt_BR/all.js', html)
self.assertIn('connect.facebook.net/pt_BR/sdk.js', html)

self.document.setLanguage('en')
view = document.restrictedTraverse(plugin_view)
html = view.metadata()
self.assertIn('connect.facebook.net/en_GB/all.js', html)
self.assertIn('connect.facebook.net/en_GB/sdk.js', html)

def test_plugin_view_typebutton(self):
portal = self.portal
Expand Down

0 comments on commit d3627c3

Please sign in to comment.