--- a/src/pyams_default_theme/component/illustration/__init__.py Thu Sep 27 15:52:20 2018 +0200
+++ b/src/pyams_default_theme/component/illustration/__init__.py Thu Sep 27 16:28:29 2018 +0200
@@ -12,26 +12,66 @@
__docformat__ = 'restructuredtext'
-
-# import standard library
from persistent import Persistent
-
-# import interfaces
-from pyams_content.component.illustration.interfaces import IIllustration
-from pyams_content.features.renderer.interfaces import IContentRenderer
-from pyams_default_theme.component.illustration.interfaces import IIllustrationWithZoomSettings, IIllustrationRenderer, \
- ILLUSTRATION_AFTER_BODY, ILLUSTRATION_BEFORE_BODY
-from pyams_skin.layer import IPyAMSLayer
-
-# import packages
-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 locate, Location
+from zope.interface import Interface, implementer
+from zope.location import Location
from zope.schema.fieldproperty import FieldProperty
+from pyams_content.component.illustration import IBasicIllustrationTarget, ILinkIllustration
+from pyams_content.component.illustration.interfaces import IIllustration
+from pyams_content.component.links import IInternalLink
+from pyams_content.features.renderer.interfaces import IContentRenderer
+from pyams_content.features.renderer.skin import BaseContentRenderer
+from pyams_content.interfaces import IBaseContent
from pyams_default_theme import _
+from pyams_default_theme.component.illustration.interfaces import IIllustrationRenderer, IIllustrationWithZoomSettings, \
+ ILLUSTRATION_AFTER_BODY, ILLUSTRATION_BEFORE_BODY
+from pyams_default_theme.interfaces import IContentHeaderIllustration, IContentNavigationIllustration
+from pyams_skin.layer import IPyAMSLayer
+from pyams_template.template import template_config
+from pyams_utils.adapter import ContextRequestViewAdapter, adapter_config, get_annotation_adapter
+from pyams_utils.interfaces.tales import ITALESExtension
+
+
+#
+# Illustrations adapters
+#
+
+@adapter_config(context=(IBasicIllustrationTarget, IPyAMSLayer), provides=IContentNavigationIllustration)
+def base_content_navigation_illustration_adapter(context, request):
+ """Default content navigation illustration adapter"""
+ illustration = ILinkIllustration(context, None)
+ if not (illustration and illustration.has_data()):
+ illustration = IIllustration(context, None)
+ if illustration and illustration.has_data():
+ return illustration
+ if IInternalLink.providedBy(context):
+ target = context.get_target()
+ if target is not None:
+ illustration = request.registry.queryMultiAdapter((target, request),
+ IContentNavigationIllustration)
+ if illustration and illustration.has_data():
+ return illustration
+
+
+@adapter_config(name='pyams_illustration',
+ context=(Interface, Interface, Interface),
+ provides=ITALESExtension)
+class PyAMSContentIllustrationTALESExtension(ContextRequestViewAdapter):
+ """PyAMS content illustration TALES extension"""
+
+ def render(self, context=None):
+ if context is None:
+ context = self.context
+ return self.request.registry.queryMultiAdapter((context, self.request), IContentNavigationIllustration)
+
+
+@adapter_config(context=(IBaseContent, IPyAMSLayer), provides=IContentHeaderIllustration)
+def base_content_header_illustration_adapter(context, request):
+ """Base content header illustration adapter"""
+ illustration = IIllustration(context, None)
+ if illustration and illustration.has_data():
+ return illustration
#
@@ -62,7 +102,7 @@
class BaseIllustrationRenderer(BaseContentRenderer):
"""Base illustration renderer"""
- context_attrs = ('author', )
+ context_attrs = ('author',)
i18n_context_attrs = ('title', 'alt_title', 'description', 'data')
position = None
--- a/src/pyams_default_theme/shared/common/__init__.py Thu Sep 27 15:52:20 2018 +0200
+++ b/src/pyams_default_theme/shared/common/__init__.py Thu Sep 27 16:28:29 2018 +0200
@@ -10,16 +10,13 @@
# FOR A PARTICULAR PURPOSE.
#
-
__docformat__ = 'restructuredtext'
from zope.interface import Interface
-from pyams_content.component.illustration import IBasicIllustrationTarget, IIllustration, ILinkIllustration
-from pyams_content.component.links import IInternalLink
from pyams_content.interfaces import IBaseContent
from pyams_content.shared.common.interfaces import IWfSharedContent
-from pyams_default_theme.interfaces import IContentDate, IContentNavigationIllustration, IContentNavigationTitle, \
+from pyams_default_theme.interfaces import IContentDate, IContentNavigationTitle, \
IContentTag
from pyams_i18n.interfaces import II18n
from pyams_skin.layer import IPyAMSLayer
@@ -85,32 +82,3 @@
if context is None:
context = self.context
return self.request.registry.queryMultiAdapter((context, self.request), IContentDate)
-
-
-@adapter_config(context=(IBasicIllustrationTarget, IPyAMSLayer), provides=IContentNavigationIllustration)
-def base_content_navigation_illustration_adapter(context, request):
- """Default content navigation illustration adapter"""
- illustration = ILinkIllustration(context, None)
- if not (illustration and illustration.has_data()):
- illustration = IIllustration(context, None)
- if illustration and illustration.has_data():
- return illustration
- if IInternalLink.providedBy(context):
- target = context.get_target()
- if target is not None:
- illustration = request.registry.queryMultiAdapter((target, request),
- IContentNavigationIllustration)
- if illustration and illustration.has_data():
- return illustration
-
-
-@adapter_config(name='pyams_illustration',
- context=(Interface, Interface, Interface),
- provides=ITALESExtension)
-class PyAMSContentIllustrationTALESExtension(ContextRequestViewAdapter):
- """PyAMS content illustration TALES extension"""
-
- def render(self, context=None):
- if context is None:
- context = self.context
- return self.request.registry.queryMultiAdapter((context, self.request), IContentNavigationIllustration)