# HG changeset patch # User Thierry Florac # Date 1528721911 -7200 # Node ID 04f5df7ee1d2850096016b7a9ee7046b6cb527f0 # Parent a41421d75755de6a4da0df2a7a96e19fa59e4b7c Moved "content" portlet from PyAMS_portal package diff -r a41421d75755 -r 04f5df7ee1d2 src/pyams_content/portlet/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/portlet/__init__.py Mon Jun 11 14:58:31 2018 +0200 @@ -0,0 +1,19 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + +# import standard library + +# import interfaces + +# import packages diff -r a41421d75755 -r 04f5df7ee1d2 src/pyams_content/portlet/content/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/portlet/content/__init__.py Mon Jun 11 14:58:31 2018 +0200 @@ -0,0 +1,44 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces +from pyams_content.portlet.content.interfaces import ISharedContentPortletSettings +from pyams_utils.interfaces import VIEW_PERMISSION + +# import packages +from pyams_portal.portlet import PortletSettings, portlet_config, Portlet +from zope.interface import implementer + +from pyams_content import _ + + +SHARED_CONTENT_PORTLET_NAME = 'pyams_content.portlet.content' + + +@implementer(ISharedContentPortletSettings) +class SharedContentPortletSettings(PortletSettings): + """Shared content portlet persistent settings""" + + +@portlet_config(permission=VIEW_PERMISSION) +class SharedContentPortlet(Portlet): + """Shared content portlet""" + + name = SHARED_CONTENT_PORTLET_NAME + label = _("Context content") + + settings_class = SharedContentPortletSettings diff -r a41421d75755 -r 04f5df7ee1d2 src/pyams_content/portlet/content/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/portlet/content/interfaces.py Mon Jun 11 14:58:31 2018 +0200 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + +# import standard library + +# import interfaces + +# import packages +from pyams_portal.interfaces import IPortletSettings + + +class ISharedContentPortletSettings(IPortletSettings): + """Shared content portlet settings interface""" diff -r a41421d75755 -r 04f5df7ee1d2 src/pyams_content/portlet/content/skin/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/portlet/content/skin/__init__.py Mon Jun 11 14:58:31 2018 +0200 @@ -0,0 +1,54 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + +# import standard library + +# import interfaces +from pyams_content.portlet.content.interfaces import ISharedContentPortletSettings +from pyams_portal.interfaces import IPortalContext, IPortletRenderer +from pyams_skin.layer import IPyAMSLayer + +# import packages +from pyams_content.features.renderer import IContentRenderer +from pyams_portal.portlet import PortletRenderer +from pyams_utils.adapter import adapter_config +from zope.interface import Interface + +from pyams_content import _ + + +@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, ISharedContentPortletSettings), + provides=IPortletRenderer) +class SharedContentPortletRenderer(PortletRenderer): + """Shared content portlet renderer""" + + label = _("Default content renderer") + + def __init__(self, context, request, view, settings): + super(SharedContentPortletRenderer, self).__init__(context, request, view, settings) + registry = self.request.registry + self.renderers = [adapter for name, adapter in sorted(registry.getAdapters((self.context, self.request), + IContentRenderer), + key=lambda x: x[1].weight)] + + def update(self): + super(SharedContentPortletRenderer, self).update() + [renderer.update() for renderer in self.renderers] + + def render(self): + result = '' + for renderer in self.renderers: + if renderer is not None: + result += renderer.render() + return result diff -r a41421d75755 -r 04f5df7ee1d2 src/pyams_content/portlet/content/zmi/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/portlet/content/zmi/__init__.py Mon Jun 11 14:58:31 2018 +0200 @@ -0,0 +1,52 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# + +__docformat__ = 'restructuredtext' + + +# import standard library + +# import interfaces +from pyams_content.portlet.content.interfaces import ISharedContentPortletSettings +from pyams_pagelet.interfaces import IPagelet +from pyams_portal.interfaces import IPortletPreviewer +from pyams_skin.layer import IPyAMSLayer +from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION + +# import packages +from pyams_form.form import AJAXEditForm +from pyams_pagelet.pagelet import pagelet_config +from pyams_portal.portlet import PortletPreviewer +from pyams_portal.zmi.portlet import PortletSettingsEditor +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config +from zope.interface import Interface + + +@pagelet_config(name='properties.html', context=ISharedContentPortletSettings, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +class SharedContentPortletSettingsEditor(PortletSettingsEditor): + """Shared content portlet settings editor""" + + settings = ISharedContentPortletSettings + + +@adapter_config(name='properties.json', context=(ISharedContentPortletSettings, IPyAMSLayer), provides=IPagelet) +class SharedContentPortletConfigurationAJAXEditor(AJAXEditForm, SharedContentPortletSettingsEditor): + """Shared content portlet settings editor, JSON renderer""" + + +@adapter_config(context=(Interface, IPyAMSLayer, Interface, ISharedContentPortletSettings), + provides=IPortletPreviewer) +@template_config(template='preview.pt', layer=IPyAMSLayer) +class SharedContentPortletPreviewer(PortletPreviewer): + """Shared content portlet previewer""" diff -r a41421d75755 -r 04f5df7ee1d2 src/pyams_content/portlet/content/zmi/preview.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/portlet/content/zmi/preview.pt Mon Jun 11 14:58:31 2018 +0200 @@ -0,0 +1,13 @@ + + + This is where the content will be displayed!! + + +
+ + + + +
+
+