Skip to content

Commit

Permalink
Merge f6dec88 into 8678614
Browse files Browse the repository at this point in the history
  • Loading branch information
keul committed Jul 8, 2015
2 parents 8678614 + f6dec88 commit 271ddb3
Show file tree
Hide file tree
Showing 59 changed files with 887 additions and 260 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.3 (unreleased)
^^^^^^^^^^^^^^^^

- Added the "Severe privacy" mode configuration option.
[keul]

- Added German translations.
[tohafi]

Expand Down
19 changes: 19 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,28 @@ Go to the 'Site Setup' page in the Plone interface and click on the
There you can configure how **Social: Like Actions** will behave, which actions
will be displayed and for which content types.

Privacy and cookies
^^^^^^^^^^^^^^^^^^^

Social networks and privacy togheter is a thorny argument, let say that
social media widget commonly tracks user actions and add 3rd party cookies.

If privacy is something you must care about (for example: if you need to take
care of the `European Cookie Law`_) sc.social.like provide a
"*Severe privacy*" option.
When enabled, social media widget are rendered as simple HTML links at the expense
of features and user experience.

This product is also respecting the `Do Not Track`_ browser user's preference.
If the user configured his browser for beeing not tracked, social media will
be rendered as the "*Severe privacy*" settings is enabled.

Screenshots
^^^^^^^^^^^

.. image:: https://github.com/collective/sc.social.like/raw/master/docs/screenshot1.png

.. image:: https://github.com/collective/sc.social.like/raw/master/docs/screenshot2.png

.. _`European Cookie Law`: http://eur-lex.europa.eu/legal-content/EN/TXT/?uri=celex:32009L0136
.. _`Do Not Track`: http://donottrack.us/
Binary file modified docs/control_panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sc/social/like/browser/images/ico-sociallike.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified sc/social/like/browser/images/ico-whatsapp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sc/social/like/browser/images/pin_it_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sc/social/like/browser/images/share-facebook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sc/social/like/browser/images/share-gplus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sc/social/like/browser/images/share-linkedin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sc/social/like/browser/images/share-twitter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion sc/social/like/browser/templates/metadata.pt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<tal:metas i18n:domain="sc.social.like" tal:condition="view/enabled">
<tal:plugin tal:repeat="plugin view/plugins">
<tal:replace replace="structure plugin/html" />
</tal:plugin>
</tal:plugin>
</tal:metas>
29 changes: 24 additions & 5 deletions sc/social/like/browser/viewlets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from plone.app.layout.viewlets import ViewletBase
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from zope.component import getMultiAdapter
from plone.memoize.view import memoize


class BaseLikeViewlet(ViewletBase):
Expand All @@ -20,6 +21,7 @@ def __init__(self, context, request, view, manager):
name=u'sl_helper')
self.typebutton = self.helper.typebutton()

@memoize
def plugins(self):
context = self.context
render_method = self.render_method
Expand All @@ -28,15 +30,16 @@ def plugins(self):
for plugin in plugins:
if plugin and getattr(plugin, render_method)():
view = context.restrictedTraverse(plugin.view())
html = getattr(view, render_method)()
rendered.append({'id': plugin.id,
'html': html})
html_generator = getattr(view, render_method, None)
if html_generator:
rendered.append({'id': plugin.id,
'html': html_generator()})
return rendered

def enabled(self):
"""Validates if the viewlet should be enabled for this context
"""
return self.helper.enabled()
return self.helper.enabled() and self.plugins()

# HACK: fixes https://bitbucket.org/takaki/sc.social.like/issue/1
def update(self):
Expand Down Expand Up @@ -68,4 +71,20 @@ class SocialLikesViewlet(BaseLikeViewlet):
"""Viewlet used to display the buttons
"""
render = ViewPageTemplateFile('templates/sociallikes.pt')
render_method = 'plugin'

@property
def render_method(self):
tools = getMultiAdapter((self.context, self.request),
name=u'plone_tools')
site_properties = tools.properties()
# global cookie settings for privacy level
if self.request.cookies.get('social-optout', None) == 'true' or \
self.request.get_header('HTTP_DNT') == '1':
return 'link'
# site specific privacy level check
if getattr(site_properties, 'sc_social_likes_properties') \
and getattr(site_properties.sc_social_likes_properties,
'privacy') and \
site_properties.sc_social_likes_properties.privacy:
return 'link'
return 'plugin'
2 changes: 1 addition & 1 deletion sc/social/like/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<five:registerPackage package="." initialize=".initialize" />

<include zcml:condition="have plone-4" package="Products.CMFCore" file="permissions.zcml" />

<include file="profiles.zcml" />
<include package=".browser" />
<include package=".controlpanel" />
Expand Down
2 changes: 1 addition & 1 deletion sc/social/like/controlpanel/likes.pt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
i18n:translate="" i18n:domain="sc.social.like">
Configure each plugin.
</span>
</label>
</label>
<ul tal:define="plugins view/plugins_configs">
<li tal:repeat="plugin plugins">
<a tal:attributes="href plugin/url;
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 @@ -72,6 +72,19 @@ class IProvidersSchema(Interface):
vocabulary=styles,
)

privacy = schema.Bool(
title=_(u'Severe privacy'),
description=_(
u'help_privacy',
default=u'If enabled, the site will not provide advanced sharing '
u'widgets , instead simple links will be used.\n'
u'This will limits user experience and features '
u'(like the share count) but will enhance users privacy: '
u'no 3rd party cookies will be sent to users.'
),
default=False,
)


class BaseControlPanelAdapter(SchemaAdapterBase):
""" Base control panel adapter """
Expand All @@ -90,6 +103,7 @@ class LikeControlPanelAdapter(BaseControlPanelAdapter):
enabled_portal_types = PFP(IProvidersSchema['enabled_portal_types'])
typebutton = PFP(IProvidersSchema['typebutton'])
plugins_enabled = PFP(IProvidersSchema['plugins_enabled'])
privacy = PFP(IProvidersSchema['privacy'])


class ProvidersControlPanel(ControlPanelForm):
Expand All @@ -105,7 +119,7 @@ class ProvidersControlPanel(ControlPanelForm):
form_name = _('Social: Like Actions')

def plugins_configs(self):
''' Return Plugins and their configuration pages '''
""" Return Plugins and their configuration pages """
context = aq_inner(self.context)
portal_url = getToolByName(context, 'portal_url')()
registered = dict(getUtilitiesFor(IPlugin))
Expand Down
18 changes: 9 additions & 9 deletions sc/social/like/interfaces/socialikes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@ class IHelperView(Interface):
"""
"""
def configs():
''' Social Like configuration '''
""" Social Like configuration """

def enabled_portal_types():
''' Portal Types that will display our viewlet '''
""" Portal Types that will display our viewlet """

def plugins_enabled():
''' List of plugins enabled '''
""" List of plugins enabled """

def typebutton():
''' Button to be used '''
""" Button to be used """

def enabled(view):
'''
"""
Social Like is enabled for this context and provided view
(when provided)
'''
"""

def available_plugins():
''' Return available plugins '''
""" Return available plugins """

def plugins():
''' Return enabled plugins '''
""" Return enabled plugins """

def view_template_id():
''' View or template id for this context '''
""" View or template id for this context """
Loading

0 comments on commit 271ddb3

Please sign in to comment.