Skip to content

Commit

Permalink
Merge 48d531a into 6411fc2
Browse files Browse the repository at this point in the history
  • Loading branch information
rodfersou committed Jul 25, 2017
2 parents 6411fc2 + 48d531a commit 7a9ebf6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ There's a frood who really knows where his towel is.
2.10.1 (unreleased)
^^^^^^^^^^^^^^^^^^^

- Update plugins javascript (closes `#117 <https://github.com/collective/sc.social.like/issues/117>`_).
[rodfersou]

- Fix Canonical URL updater form;
a new upgrade step is provided to update the ``objects_provides`` catalog index (fixes `#115 <https://github.com/collective/sc.social.like/issues/115>`_).
[hvelarde]
Expand Down
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 7a9ebf6

Please sign in to comment.