# HG changeset patch # User Thierry Florac # Date 1535966523 -7200 # Node ID 9638eaef9d343c49093b78643476aed3bc778692 # Parent d83485dee19aff66872d33e6df6294617f0c72bd Added "position" attribute to illustration renderers diff -r d83485dee19a -r 9638eaef9d34 src/pyams_default_theme/component/illustration/__init__.py --- a/src/pyams_default_theme/component/illustration/__init__.py Thu Aug 30 11:07:17 2018 +0200 +++ b/src/pyams_default_theme/component/illustration/__init__.py Mon Sep 03 11:22:03 2018 +0200 @@ -19,7 +19,8 @@ # 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 +from pyams_default_theme.component.illustration.interfaces import IIllustrationWithZoomSettings, IIllustrationRenderer, \ + ILLUSTRATION_AFTER_BODY, ILLUSTRATION_BEFORE_BODY from pyams_skin.layer import IPyAMSLayer # import packages @@ -57,21 +58,26 @@ # Illustration renderers # +@implementer(IIllustrationRenderer) class BaseIllustrationRenderer(BaseContentRenderer): """Base illustration renderer""" context_attrs = ('author', ) i18n_context_attrs = ('title', 'alt_title', 'description', 'data') + position = None -@adapter_config(name='default', context=(IIllustration, IPyAMSLayer), provides=IContentRenderer) + +@adapter_config(name='centered-before-body', context=(IIllustration, IPyAMSLayer), provides=IContentRenderer) @template_config(template='templates/illustration-default.pt', layer=IPyAMSLayer) class DefaultIllustrationRenderer(BaseIllustrationRenderer): """Default illustration renderer""" - label = _("Centered illustration") + label = _("Centered illustration before text") weight = 1 + position = ILLUSTRATION_BEFORE_BODY + @adapter_config(name='left+zoom', context=(IIllustration, IPyAMSLayer), provides=IContentRenderer) @template_config(template='templates/illustration-left.pt', layer=IPyAMSLayer) @@ -81,6 +87,7 @@ label = _("Small illustration on the left") weight = 2 + position = ILLUSTRATION_BEFORE_BODY settings_interface = IIllustrationWithZoomSettings @@ -92,4 +99,16 @@ label = _("Small illustration on the right") weight = 3 + position = ILLUSTRATION_BEFORE_BODY settings_interface = IIllustrationWithZoomSettings + + +@adapter_config(name='default', context=(IIllustration, IPyAMSLayer), provides=IContentRenderer) +@template_config(template='templates/illustration-default.pt', layer=IPyAMSLayer) +class DefaultIllustrationRenderer(BaseIllustrationRenderer): + """Default illustration renderer""" + + label = _("Centered illustration after text") + weight = 4 + + position = ILLUSTRATION_AFTER_BODY diff -r d83485dee19a -r 9638eaef9d34 src/pyams_default_theme/component/illustration/interfaces/__init__.py --- a/src/pyams_default_theme/component/illustration/interfaces/__init__.py Thu Aug 30 11:07:17 2018 +0200 +++ b/src/pyams_default_theme/component/illustration/interfaces/__init__.py Mon Sep 03 11:22:03 2018 +0200 @@ -18,16 +18,27 @@ # import interfaces # import packages -from zope.interface import Interface -from zope.schema import Bool +from zope.interface import Interface, Attribute +from zope.schema import Bool, Choice from pyams_default_theme import _ +ILLUSTRATION_BEFORE_TITLE = 'before-title' +ILLUSTRATION_BEFORE_BODY = 'before-body' +ILLUSTRATION_AFTER_BODY = 'after-body' + + +class IIllustrationRenderer(Interface): + """Illustration renderer interface""" + + position = Attribute("Illustration position related to it's attached content") + + class IIllustrationWithZoomSettings(Interface): """Illustration with zoom interface""" zoom_on_click = Bool(title=_("Zoom on click?"), description=_("If 'yes', a click on illustration thumbnail is required to zoom"), required=True, - default=True) \ No newline at end of file + default=True) diff -r d83485dee19a -r 9638eaef9d34 src/pyams_default_theme/component/paragraph/templates/html-default.pt --- a/src/pyams_default_theme/component/paragraph/templates/html-default.pt Thu Aug 30 11:07:17 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/html-default.pt Mon Sep 03 11:22:03 2018 +0200 @@ -1,3 +1,9 @@ -

title

-Illustration -
body
+ + ${structure:view.render_illustration()} +

${view.title}

+ ${structure:view.render_illustration()} +
${structure:tales:html(view.body, 'oid_to_href')}
+ ${structure:view.render_illustration()} +