Skip to content

Commit

Permalink
Merge dc56154 into 4163a4f
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jun 6, 2016
2 parents 4163a4f + dc56154 commit 1bf7157
Show file tree
Hide file tree
Showing 33 changed files with 413 additions and 611 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ There's a frood who really knows where his towel is.
2.4.2 (unreleased)
^^^^^^^^^^^^^^^^^^

- Nothing changed yet.
- Use Plone's registry instead of the ``portal_properties`` tool to store package configuration (closes `#1`_).
[hvelarde]


2.4.1 (2015-12-10)
Expand Down Expand Up @@ -276,6 +277,7 @@ There's a frood who really knows where his towel is.

* Initial release [cleberjsantos]

.. _`#1`: https://github.com/collective/sc.social.like/issues/1
.. _`#15`: https://github.com/collective/sc.social.like/pull/15
.. _`#36`: https://github.com/collective/sc.social.like/issues/36
.. _`#38`: https://github.com/collective/sc.social.like/issues/38
Expand Down
7 changes: 7 additions & 0 deletions sc/social/like/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,11 @@
permission="zope.Public"
/>

<browser:page
name="sociallike-settings"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class="sc.social.like.controlpanel.SocialLikeSettingsControlPanel"
permission="cmf.ManagePortal"
/>

</configure>
12 changes: 7 additions & 5 deletions sc/social/like/browser/helper.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# -*- coding: utf-8 -*-

from Acquisition import aq_inner
from Products.Five import BrowserView
from plone.app.layout.globals.interfaces import IViewView
from plone.memoize.view import memoize
from plone.memoize.view import memoize_contextless
from sc.social.like.controlpanel.likes import LikeControlPanelAdapter
from plone.registry.interfaces import IRegistry
from Products.Five import BrowserView
from sc.social.like.controlpanel import ISocialLikeSettings
from sc.social.like.interfaces import IHelperView
from sc.social.like.plugins import IPlugin
from zope.component import getMultiAdapter
from zope.component import getUtilitiesFor
from zope.component import getUtility
from zope.interface import implements


Expand All @@ -30,8 +31,9 @@ def __init__(self, context, request, *args, **kwargs):

@memoize_contextless
def configs(self):
adapter = LikeControlPanelAdapter(self.portal)
return adapter
registry = getUtility(IRegistry)
settings = registry.forInterface(ISocialLikeSettings)
return settings

@memoize_contextless
def enabled_portal_types(self):
Expand Down
3 changes: 3 additions & 0 deletions sc/social/like/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
__docformat__ = 'plaintext'

PROJECTNAME = 'sc.social.like'

DEFAULT_ENABLED_CONTENT_TYPES = ('Document', 'Event')
DEFAULT_PLUGINS_ENABLED = ('Facebook', 'Twitter')
3 changes: 1 addition & 2 deletions sc/social/like/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

<five:registerPackage package="." />

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

<include file="profiles.zcml" />
<include package=".browser" />
<include package=".controlpanel" />
<include package=".plugins" />

<i18n:registerTranslations directory="locales" />
Expand Down
85 changes: 85 additions & 0 deletions sc/social/like/controlpanel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# -*- coding:utf-8 -*-
from plone.app.registry.browser import controlpanel
from sc.social.like import LikeMessageFactory as _
from sc.social.like.config import DEFAULT_ENABLED_CONTENT_TYPES
from sc.social.like.config import DEFAULT_PLUGINS_ENABLED
from zope import schema
from zope.interface import Interface
from zope.schema.vocabulary import SimpleTerm
from zope.schema.vocabulary import SimpleVocabulary


CONTENT_TYPES = 'plone.app.vocabularies.ReallyUserFriendlyTypes'

styles = SimpleVocabulary([
SimpleTerm(value=u'horizontal', title=_(u'horizontal')),
SimpleTerm(value=u'vertical', title=_(u'vertical')),
])


class ISocialLikeSettings(Interface):

"""Schema for the control panel form."""

enabled_portal_types = schema.Tuple(
title=_(u'Content types'),
description=_(
u'help_portal_types',
default=u'Please select content types in which the '
u'viewlet will be applied.',
),
required=True,
default=DEFAULT_ENABLED_CONTENT_TYPES,
value_type=schema.Choice(vocabulary=CONTENT_TYPES)
)

plugins_enabled = schema.Tuple(
title=_(u'Plugins'),
description=_(
u'help_enabled_plugins',
default=u'Please select which plugins will be used',
),
required=False,
default=DEFAULT_PLUGINS_ENABLED,
value_type=schema.Choice(vocabulary='sc.social.likes.plugins')
)

typebutton = schema.Choice(
title=_(u'Button style'),
description=_(
u'help_selected_buttons',
default=u'Choose your button style.',
),
required=True,
default=_(u'horizontal'),
vocabulary=styles,
)

do_not_track = schema.Bool(
title=_(u'Do not track users'),
description=_(
u'help_do_not_track',
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 SocialLikeSettingsEditForm(controlpanel.RegistryEditForm):

"""Control panel edit form."""

schema = ISocialLikeSettings
label = _(u'Social Like')
description = _(u'Settings for the sc.social.like package')


class SocialLikeSettingsControlPanel(controlpanel.ControlPanelFormWrapper):

"""Control panel form wrapper."""

form = SocialLikeSettingsEditForm
1 change: 0 additions & 1 deletion sc/social/like/controlpanel/__init__.py

This file was deleted.

14 changes: 0 additions & 14 deletions sc/social/like/controlpanel/configure.zcml

This file was deleted.

171 changes: 0 additions & 171 deletions sc/social/like/controlpanel/likes.pt

This file was deleted.

Loading

0 comments on commit 1bf7157

Please sign in to comment.