# HG changeset patch # User Thierry Florac # Date 1539356726 -7200 # Node ID f419b942f7f4c7f9ce1bf70e1c2a5c65b2e58838 # Parent 97e8610cbabd13f76f447044d1d9bd5376b1d7b3 Updated frame and verbatim paragraphs renderers diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/frame.py --- a/src/pyams_default_theme/component/paragraph/frame.py Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/frame.py Fri Oct 12 17:05:26 2018 +0200 @@ -49,17 +49,9 @@ class BaseFrameParagraphRendererSettings(Persistent, Location): """Base frame text paragraph renderer settings""" - display_illustration = FieldProperty(IFrameParagraphRendererSettings['display_illustration']) display_associations = FieldProperty(IFrameParagraphRendererSettings['display_associations']) _pictogram_name = FieldProperty(IDefaultFrameParagraphRendererSettings['pictogram_name']) - def can_display_illustration(self): - if not self.display_illustration: - return False - frame = IFrameParagraph(self.__parent__) - illustration = IIllustration(frame, None) - return (illustration is not None) and bool(II18n(illustration).query_attribute('data')) - def can_display_associations(self): if not self.display_associations: return False @@ -139,8 +131,18 @@ """Base frame paragraph renderer""" i18n_context_attrs = ('title', 'body') + + illustration = None illustration_renderer = None + def update(self): + super(BaseFrameParagraphRenderer, self).update() + self.illustration = IIllustration(self.context) + if self.illustration.data: + renderer = self.illustration_renderer = self.illustration.get_renderer(self.request) + if renderer is not None: + renderer.update() + @adapter_config(name='default', context=(IFrameParagraph, IPyAMSLayer), provides=IContentRenderer) @template_config(template='templates/frame-default.pt', layer=IPyAMSLayer) diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/html.py --- a/src/pyams_default_theme/component/paragraph/html.py Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/html.py Fri Oct 12 17:05:26 2018 +0200 @@ -12,20 +12,16 @@ __docformat__ = 'restructuredtext' - -# import standard library - -# import interfaces from pyams_content.component.illustration import IIllustration -from pyams_content.component.paragraph.interfaces.html import IRawParagraph, IHTMLParagraph +from pyams_content.component.paragraph.interfaces.html import IHTMLParagraph, IRawParagraph from pyams_content.features.renderer.interfaces import IContentRenderer -# import packages from pyams_content.features.renderer.skin import BaseContentRenderer -from pyams_default_theme import _ from pyams_skin.layer import IPyAMSLayer from pyams_template.template import template_config from pyams_utils.adapter import adapter_config +from pyams_default_theme import _ + # # Raw paragraph default renderer @@ -38,7 +34,7 @@ label = _("Default raw HTML renderer") - i18n_context_attrs = ('title', 'body', ) + i18n_context_attrs = ('title', 'body',) # @@ -52,7 +48,7 @@ label = _("Default rich text renderer") - i18n_context_attrs = ('title', 'body', ) + i18n_context_attrs = ('title', 'body',) illustration = None illustration_renderer = None @@ -64,8 +60,3 @@ renderer = self.illustration_renderer = self.illustration.get_renderer(self.request) if renderer is not None: renderer.update() - - def render_illustration(self): - if not self.illustration_renderer: - return '' - return self.illustration_renderer.render() diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/interfaces/frame.py --- a/src/pyams_default_theme/component/paragraph/interfaces/frame.py Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/interfaces/frame.py Fri Oct 12 17:05:26 2018 +0200 @@ -34,14 +34,6 @@ class IFrameParagraphRendererSettings(Interface): """Framed paragraph default renderer settings interface""" - display_illustration = Bool(title=_("Show illustration?"), - description=_("If 'no', illustration will not be displayed"), - required=True, - default=True) - - def can_display_illustration(self): - """Check if illustration can be displayed""" - display_associations = Bool(title=_("Show associations?"), description=_("If 'no', associations will not be displayed"), required=True, diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/interfaces/verbatim.py --- a/src/pyams_default_theme/component/paragraph/interfaces/verbatim.py Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/interfaces/verbatim.py Fri Oct 12 17:05:26 2018 +0200 @@ -12,14 +12,8 @@ __docformat__ = 'restructuredtext' - -# import standard library - -# import interfaces - -# import packages from zope.interface import Interface -from zope.schema import Bool, Choice +from zope.schema import Choice from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm from pyams_default_theme import _ @@ -34,23 +28,7 @@ for item in FRAME_POSITIONS]) -class IVerbatimParagraphRendererSettings(Interface): - """Verbatim paragraph default renderer settings interface""" - - display_illustration = Bool(title=_("Show illustration?"), - description=_("If 'no', illustration will not be displayed"), - required=True, - default=True) - - def can_display_illustration(self): - """Check if illustration can be displayed""" - - -class IDefaultVerbatimParagraphRendererSettings(IVerbatimParagraphRendererSettings): - """Verbatim paragraph default renderer settings interface""" - - -class ILateralVerbatimParagraphRendererSettings(IVerbatimParagraphRendererSettings): +class ILateralVerbatimParagraphRendererSettings(Interface): """Verbatim paragraph lateral renderer settings interface""" relative_width = Choice(title=_("Relative width"), diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/frame-default.pt --- a/src/pyams_default_theme/component/paragraph/templates/frame-default.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/frame-default.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,8 +1,15 @@
-

Title

-
-
+ tal:define="settings view.settings; + renderer view.illustration_renderer; + position getattr(renderer, 'position', None) if renderer is not None else None;" + tal:switch="position"> + ${structure:renderer.render())} +

${view.title}

+ ${structure:renderer.render()}

body

+ ${structure:renderer.render()} +
+ + ${structure:provider:pyams.associations} +
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/frame-left.pt --- a/src/pyams_default_theme/component/paragraph/templates/frame-left.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/frame-left.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,8 +1,16 @@
-

Title

- + tal:define="settings view.settings; + renderer view.illustration_renderer; + position getattr(renderer, 'position', None) if renderer is not None else None;" + tal:attributes="class string:${default} col-md-${settings.relative_width}" + tal:switch="position"> + ${structure:renderer.render())} +

${view.title}

+ ${structure:renderer.render()}

body

+ ${structure:renderer.render()} +
+ + ${structure:provider:pyams.associations} +
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/frame-right.pt --- a/src/pyams_default_theme/component/paragraph/templates/frame-right.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/frame-right.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,8 +1,16 @@
-

Title

- + tal:define="settings view.settings; + renderer view.illustration_renderer; + position getattr(renderer, 'position', None) if renderer is not None else None;" + tal:attributes="class string:${default} col-md-${settings.relative_width}" + tal:switch="position"> + ${structure:renderer.render())} +

${view.title}

+ ${structure:renderer.render()}

body

+ ${structure:renderer.render()} +
+ + ${structure:provider:pyams.associations} +
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/html-default.pt --- a/src/pyams_default_theme/component/paragraph/templates/html-default.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/html-default.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,11 +1,11 @@ - ${structure:view.render_illustration()} + ${structure:renderer.render()}

${view.title}

- ${structure:view.render_illustration()} + ${structure:renderer.render()}
${structure:tales:html(view.body, 'oid_to_href')}
- ${structure:view.render_illustration()} + ${structure:renderer.render()}
${structure:provider:pyams.associations}
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/verbatim-default.pt --- a/src/pyams_default_theme/component/paragraph/templates/verbatim-default.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/verbatim-default.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,9 +1,14 @@
- + illustration tales:pyams_illustration(context); + display_illustration view.can_display_illustration()"> +
+ tal:define="photo i18n:illustration.data; + alt i18n:illustration.alt_title;" + tal:condition="photo"> + ${structure:tales:picture(photo, lg_thumb='portrait', md_thumb='portrait', + sm_thumb='portrait', xs_thumb='portrait', alt=alt)}
Author
@@ -14,11 +19,11 @@
Quote
+ tal:content="structure tales:html(view.quote)">Quote
- Author - - Charge + ${view.author} + , + ${view.charge}
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/verbatim-left.pt --- a/src/pyams_default_theme/component/paragraph/templates/verbatim-left.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/verbatim-left.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,17 +1,31 @@

Title

-
-
-
Quote
-
- Author - - – + +
+ ${structure:tales:picture(photo, lg_thumb='portrait', md_thumb='portrait', + sm_thumb='portrait', xs_thumb='portrait', alt=alt)} +
+
+ Author
Charge - -
+
+
Quote
+ + +
Quote
+
+ ${view.author} + , + ${view.charge} +
+
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/templates/verbatim-right.pt --- a/src/pyams_default_theme/component/paragraph/templates/verbatim-right.pt Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/templates/verbatim-right.pt Fri Oct 12 17:05:26 2018 +0200 @@ -1,17 +1,31 @@

Title

-
-
-
Quote
-
- Author - - – + +
+ ${structure:tales:picture(photo, lg_thumb='portrait', md_thumb='portrait', + sm_thumb='portrait', xs_thumb='portrait', alt=alt)} +
+
+ Author
Charge - -
+
+
Quote
+ + +
Quote
+
+ ${view.author} + , + ${view.charge} +
+
diff -r 97e8610cbabd -r f419b942f7f4 src/pyams_default_theme/component/paragraph/verbatim.py --- a/src/pyams_default_theme/component/paragraph/verbatim.py Fri Oct 12 10:28:46 2018 +0200 +++ b/src/pyams_default_theme/component/paragraph/verbatim.py Fri Oct 12 17:05:26 2018 +0200 @@ -21,8 +21,7 @@ from pyams_content.component.paragraph.interfaces.verbatim import IVerbatimParagraph from pyams_content.features.renderer.interfaces import IContentRenderer from pyams_content.features.renderer.skin import BaseContentRenderer -from pyams_default_theme.component.paragraph.interfaces.verbatim import IDefaultVerbatimParagraphRendererSettings, \ - ILateralVerbatimParagraphRendererSettings, IVerbatimParagraphRendererSettings +from pyams_default_theme.component.paragraph.interfaces.verbatim import ILateralVerbatimParagraphRendererSettings from pyams_i18n.interfaces import II18n from pyams_skin.layer import IPyAMSLayer from pyams_template.template import template_config @@ -32,40 +31,11 @@ # -# Verbatim paragraph default renderer settings +# Verbatim paragraph lateral renderer settings # -VERBATIM_PARAGRAPH_RENDERER_SETTINGS_KEY = 'pyams_content.verbatim.renderer:default' - - -@implementer(IVerbatimParagraphRendererSettings) -class BaseVerbatimParagraphRendererSettings(Persistent, Location): - """Base frame text paragraph renderer settings""" - - display_illustration = FieldProperty(IVerbatimParagraphRendererSettings['display_illustration']) - - def can_display_illustration(self): - if not self.display_illustration: - return False - frame = IVerbatimParagraph(self.__parent__) - illustration = IIllustration(frame, None) - return (illustration is not None) and bool(II18n(illustration).query_attribute('data')) - - -@implementer(IDefaultVerbatimParagraphRendererSettings) -class DefaultVerbatimParagraphRendererSettings(BaseVerbatimParagraphRendererSettings): - """Verbatim paragraph lateral renderer settings""" - - -@adapter_config(context=IVerbatimParagraph, provides=IDefaultVerbatimParagraphRendererSettings) -def default_verbatim_paragraph_renderer_settings_factory(context): - """Frame paragraph default renderer settings factory""" - return get_annotation_adapter(context, VERBATIM_PARAGRAPH_RENDERER_SETTINGS_KEY, - DefaultVerbatimParagraphRendererSettings) - - @implementer(ILateralVerbatimParagraphRendererSettings) -class LateralVerbatimParagraphRendererSettings(BaseVerbatimParagraphRendererSettings): +class LateralVerbatimParagraphRendererSettings(Persistent, Location): """Verbatim paragraph lateral renderer settings""" relative_width = FieldProperty(ILateralVerbatimParagraphRendererSettings['relative_width']) @@ -90,7 +60,11 @@ context_attrs = ('author',) i18n_context_attrs = ('title', 'quote', 'charge') - illustration_renderer = None + + def can_display_illustration(self): + frame = IVerbatimParagraph(self.context) + illustration = IIllustration(frame, None) + return (illustration is not None) and bool(II18n(illustration).query_attribute('data')) @adapter_config(name='default', context=(IVerbatimParagraph, IPyAMSLayer), provides=IContentRenderer) @@ -101,8 +75,6 @@ label = _("Default verbatim renderer") weight = 1 - settings_interface = IDefaultVerbatimParagraphRendererSettings - @adapter_config(name='left', context=(IVerbatimParagraph, IPyAMSLayer), provides=IContentRenderer) @template_config(template='templates/verbatim-left.pt', layer=IPyAMSLayer)