--- a/src/pyams_default_theme/component/association/__init__.py Thu Sep 06 13:58:58 2018 +0200
+++ b/src/pyams_default_theme/component/association/__init__.py Thu Sep 06 17:44:38 2018 +0200
@@ -15,25 +15,24 @@
# import standard library
+# import packages
+from persistent import Persistent
+from zope.interface import implementer
+from zope.location import Location
+from zope.schema.fieldproperty import FieldProperty
+
# import interfaces
from pyams_content.component.association.interfaces import IAssociationParagraph, IAssociationInfo, \
IAssociationContainer
from pyams_content.component.links.interfaces import IInternalLink
from pyams_content.component.paragraph.interfaces import IParagraphContainerTarget, IParagraphContainer
from pyams_content.features.renderer.interfaces import IContentRenderer
+from pyams_content.features.renderer.skin import BaseContentRenderer
+from pyams_default_theme import _
from pyams_default_theme.component.association.interfaces import IAssociationParagraphRemoteContentRendererSettings
from pyams_skin.layer import IPyAMSLayer
-
-# import packages
-from persistent import Persistent
-from pyams_content.features.renderer.skin import BaseContentRenderer
from pyams_template.template import template_config
from pyams_utils.adapter import adapter_config, get_annotation_adapter
-from zope.interface import implementer
-from zope.location import Location
-from zope.schema.fieldproperty import FieldProperty
-
-from pyams_default_theme import _
#
@@ -70,8 +69,8 @@
display_title = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['display_title'])
display_header = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['display_header'])
+ factories = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['factories'])
anchors_only = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['anchors_only'])
- factories = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['factories'])
@adapter_config(context=IAssociationParagraph, provides=IAssociationParagraphRemoteContentRendererSettings)
@@ -102,4 +101,4 @@
container = IParagraphContainer(target, None)
if container is not None:
settings = self.settings
- yield from container.get_visible_paragraphs(settings.anchors_only, settings.factories)
+ yield from container.get_visible_paragraphs(None, settings.anchors_only, settings.factories)
--- a/src/pyams_default_theme/component/association/interfaces/__init__.py Thu Sep 06 13:58:58 2018 +0200
+++ b/src/pyams_default_theme/component/association/interfaces/__init__.py Thu Sep 06 17:44:38 2018 +0200
@@ -15,13 +15,12 @@
# import standard library
-# import interfaces
-from pyams_content.component.paragraph.interfaces import PARAGRAPH_FACTORIES_VOCABULARY
-
# import packages
from zope.interface import Interface
from zope.schema import Bool, Set, Choice
+# import interfaces
+from pyams_content.component.paragraph.interfaces import PARAGRAPH_FACTORIES_VOCABULARY
from pyams_default_theme import _
@@ -38,13 +37,13 @@
required=True,
default=False)
- anchors_only = Bool(title=_("Anchors only?"),
- description=_("If 'yes', only paragraphs set as 'anchors' will be selected"),
- required=True,
- default=True)
-
factories = Set(title=_("Paragraph types"),
description=_("Select list of paragraph types you want to include; an empty "
"selection means that all paragraphs will be selected"),
required=False,
value_type=Choice(vocabulary=PARAGRAPH_FACTORIES_VOCABULARY))
+
+ anchors_only = Bool(title=_("Anchors only?"),
+ description=_("If 'yes', only paragraphs set as 'anchors' will be selected"),
+ required=True,
+ default=True)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/portlet/__init__.py Thu Sep 06 17:44:38 2018 +0200
@@ -0,0 +1,57 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# 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
+
+from zope.interface import Interface
+
+from pyams_content import _
+# import interfaces
+from pyams_content.component.paragraph.interfaces import IParagraphContainer
+from pyams_content.component.paragraph.portlet.interfaces import IParagraphContainerPortletSettings
+from pyams_content.features.renderer.interfaces import ISharedContentRenderer
+from pyams_portal.interfaces import IPortalContext, IPortletRenderer
+# import packages
+from pyams_portal.portlet import PortletRenderer
+from pyams_skin.layer import IPyAMSLayer
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IParagraphContainerPortletSettings),
+ provides=IPortletRenderer)
+@template_config(template='templates/content.pt', layer=IPyAMSLayer)
+class ParagraphContainerPortletRenderer(PortletRenderer):
+ """Paragraph container default portlet renderer"""
+
+ label = _("Default paragraphs renderer")
+
+ renderers = ()
+
+ def update(self):
+ super(ParagraphContainerPortletRenderer, self).update()
+ settings = self.settings
+ registry = self.request.registry
+ container = IParagraphContainer(self.context, None)
+ if container is not None:
+ paragraphs = container.get_visible_paragraphs(settings.paragraphs, settings.anchors_only,
+ settings.factories)
+ renderers = [paragraph.get_renderer(self.request) for paragraph in paragraphs]
+ else:
+ renderers = [adapter for name, adapter in sorted(registry.getAdapters((self.context, self.request),
+ ISharedContentRenderer),
+ key=lambda x: x[1].weight)]
+ self.renderers = list(filter(lambda x: x is not None, renderers))
+ [renderer.update() for renderer in self.renderers]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/portlet/templates/content.pt Thu Sep 06 17:44:38 2018 +0200
@@ -0,0 +1,7 @@
+<div class="edito"
+ tal:condition="view.renderers">
+ <tal:loop repeat="renderer view.renderers">
+ <tal:if condition="renderer"
+ content="structure renderer.render()">Renderer</tal:if>
+ </tal:loop>
+</div>
--- a/src/pyams_default_theme/shared/common.py Thu Sep 06 13:58:58 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# 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.features.renderer.interfaces import ISharedContentRenderer
-from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_default_theme.layer import IPyAMSDefaultLayer
-
-# import packages
-from pyams_content.features.renderer.skin import BaseContentRenderer
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-
-
-@adapter_config(name='header-render', context=(IWfSharedContent, IPyAMSDefaultLayer),
- provides=ISharedContentRenderer)
-@template_config(template='templates/content-header.pt', layer=IPyAMSDefaultLayer)
-class SharedContentHeaderRenderer(BaseContentRenderer):
- """Shared content header renderer"""
-
- weight = 1
-
- i18n_context_attrs = ('title', )
--- a/src/pyams_default_theme/shared/templates/content-header.pt Thu Sep 06 13:58:58 2018 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-<h1 tal:content="view.title" />