# HG changeset patch # User Thierry Florac # Date 1535983639 -7200 # Node ID 62632a9571d5063b0b76a0bd640885c9a9469646 # Parent 9638eaef9d343c49093b78643476aed3bc778692 Added renderer to association paragraph to display remote content diff -r 9638eaef9d34 -r 62632a9571d5 src/pyams_default_theme/component/association/__init__.py --- a/src/pyams_default_theme/component/association/__init__.py Mon Sep 03 11:22:03 2018 +0200 +++ b/src/pyams_default_theme/component/association/__init__.py Mon Sep 03 16:07:19 2018 +0200 @@ -18,13 +18,20 @@ # 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_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 +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 _ @@ -39,6 +46,7 @@ """Associations paragraph default renderer""" label = _("Default associations renderer") + associations = () i18n_context_attrs = ('title', ) @@ -46,4 +54,52 @@ super(AssociationParagraphDefaultRenderer, self).update() self.associations = [{'url': item.get_url(self.request), 'title': IAssociationInfo(item).user_title} - for item in IAssociationContainer(self.context).values() if item.visible] + for item in IAssociationContainer(self.context).get_visible_items(self.request)] + + +# +# Associations paragraph remote content renderer +# + +ASSOCIATION_PARAGRAPH_REMOTE_CONTENT_RENDERER_SETTINGS_KEY = 'pyams_content.association.renderer:remote-content' + + +@implementer(IAssociationParagraphRemoteContentRendererSettings) +class AssociationParagraphRemoteContentRendererSettings(Persistent, Location): + """Associations paragraph remote content renderer settings""" + + display_title = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['display_title']) + display_header = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['display_header']) + anchors_only = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['anchors_only']) + factories = FieldProperty(IAssociationParagraphRemoteContentRendererSettings['factories']) + + +@adapter_config(context=IAssociationParagraph, provides=IAssociationParagraphRemoteContentRendererSettings) +def association_paragraph_remote_content_renderer_settings_factory(context): + """Associations paragraph remote content renderer settings factory""" + return get_annotation_adapter(context, ASSOCIATION_PARAGRAPH_REMOTE_CONTENT_RENDERER_SETTINGS_KEY, + AssociationParagraphRemoteContentRendererSettings) + + +@adapter_config(name='remote-content', context=(IAssociationParagraph, IPyAMSLayer), provides=IContentRenderer) +@template_config(template='templates/association-remote-content.pt', layer=IPyAMSLayer) +class AssociationParagraphRemoteContentRenderer(BaseContentRenderer): + """Associations container remote content renderer""" + + label = _("Include remote content") + + i18n_context_attrs = ('title', ) + links = () + + settings_interface = IAssociationParagraphRemoteContentRendererSettings + + def update(self): + super(AssociationParagraphRemoteContentRenderer, self).update() + self.links = [item for item in IAssociationContainer(self.context).get_visible_items(self.request) + if IInternalLink.providedBy(item) and IParagraphContainerTarget.providedBy(item.target)] + + def get_paragraphs(self, target): + container = IParagraphContainer(target, None) + if container is not None: + settings = self.settings + yield from container.get_visible_paragraphs(settings.anchors_only, settings.factories) diff -r 9638eaef9d34 -r 62632a9571d5 src/pyams_default_theme/component/association/interfaces/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/association/interfaces/__init__.py Mon Sep 03 16:07:19 2018 +0200 @@ -0,0 +1,50 @@ +# +# 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.component.paragraph.interfaces import PARAGRAPH_FACTORIES_VOCABULARY + +# import packages +from zope.interface import Interface +from zope.schema import Bool, Set, Choice + +from pyams_default_theme import _ + + +class IAssociationParagraphRemoteContentRendererSettings(Interface): + """Associations paragraph remote content renderer settings interface""" + + display_title = Bool(title=_("Display title?"), + description=_("Choose 'yes' to display remote content's title"), + required=True, + default=False) + + display_header = Bool(title=_("Display header?"), + description=_("Choose 'yes' to display remote content's header"), + 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)) diff -r 9638eaef9d34 -r 62632a9571d5 src/pyams_default_theme/component/association/templates/association-remote-content.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/component/association/templates/association-remote-content.pt Mon Sep 03 16:07:19 2018 +0200 @@ -0,0 +1,17 @@ + + + +

${i18n:target.title}

+
${structure:tales:html(header)}
+ + ${structure:renderer.render()} + +
+
+
diff -r 9638eaef9d34 -r 62632a9571d5 src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.mo Binary file src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.mo has changed diff -r 9638eaef9d34 -r 62632a9571d5 src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po --- a/src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po Mon Sep 03 11:22:03 2018 +0200 +++ b/src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po Mon Sep 03 16:07:19 2018 +0200 @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2018-07-19 17:00+0200\n" +"POT-Creation-Date: 2018-09-03 15:38+0200\n" "PO-Revision-Date: 2017-06-07 12:41+0200\n" "Last-Translator: Thierry Florac \n" "Language-Team: French\n" @@ -24,6 +24,10 @@ msgid "Default gallery renderer" msgstr "Par défaut" +#: src/pyams_default_theme/component/keynumber/__init__.py:53 +msgid "Default key numbers renderer" +msgstr "Par défaut" + #: src/pyams_default_theme/component/keynumber/portlet/__init__.py:55 msgid "Horizontal list with carousel" msgstr "Liste horizontale (par défaut)" @@ -32,23 +36,27 @@ msgid "Vertical list" msgstr "Liste verticale" -#: src/pyams_default_theme/component/illustration/__init__.py:72 -msgid "Centered illustration" -msgstr "Illustration centrée (par défaut)" +#: src/pyams_default_theme/component/illustration/__init__.py:76 +msgid "Centered illustration before text" +msgstr "Illustration centrée avant le texte" -#: src/pyams_default_theme/component/illustration/__init__.py:81 +#: src/pyams_default_theme/component/illustration/__init__.py:87 msgid "Small illustration on the left" msgstr "Illustration sur la gauche" -#: src/pyams_default_theme/component/illustration/__init__.py:92 +#: src/pyams_default_theme/component/illustration/__init__.py:99 msgid "Small illustration on the right" msgstr "Illustration sur la droite" -#: src/pyams_default_theme/component/illustration/interfaces/__init__.py:30 +#: src/pyams_default_theme/component/illustration/__init__.py:111 +msgid "Centered illustration after text" +msgstr "Illustration centrée après le texte" + +#: src/pyams_default_theme/component/illustration/interfaces/__init__.py:41 msgid "Zoom on click?" msgstr "Zoom sur clic ?" -#: src/pyams_default_theme/component/illustration/interfaces/__init__.py:31 +#: src/pyams_default_theme/component/illustration/interfaces/__init__.py:42 msgid "If 'yes', a click on illustration thumbnail is required to zoom" msgstr "" "Si 'oui', un clic sur la vignette de l'illustration est nécessaire pour " @@ -79,10 +87,6 @@ msgid "Default audio renderer" msgstr "Par défaut" -#: src/pyams_default_theme/component/paragraph/keynumber.py:50 -msgid "Default key numbers renderer" -msgstr "Par défaut" - #: src/pyams_default_theme/component/paragraph/frame.py:123 msgid "Default frame renderer" msgstr "Encadré en pleine largeur (par défaut)" @@ -113,10 +117,6 @@ msgid "Default contact renderer" msgstr "Encadré en pleine largeur (par défaut)" -#: src/pyams_default_theme/component/paragraph/header.py:40 -msgid "Default header renderer" -msgstr "Par défaut" - #: src/pyams_default_theme/component/paragraph/zmi/map.py:62 msgid "Don't use default map configuration" msgstr "Ne pas utiliser la configuration de carte par défaut" @@ -218,10 +218,50 @@ msgid "Map position" msgstr "Position de la carte" -#: src/pyams_default_theme/component/association/__init__.py:41 +#: src/pyams_default_theme/component/association/__init__.py:48 msgid "Default associations renderer" msgstr "Par défaut" +#: src/pyams_default_theme/component/association/__init__.py:89 +msgid "Include remote content" +msgstr "Include les blocs de contenu distants" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:31 +msgid "Display title?" +msgstr "Afficher le titre ?" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:32 +msgid "Choose 'yes' to display remote content's title" +msgstr "Choisissez 'oui' pour afficher le titre des contenus liés" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:36 +msgid "Display header?" +msgstr "Afficher le chapô ?" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:37 +msgid "Choose 'yes' to display remote content's header" +msgstr "Choisissez 'oui' pour afficher le chapô des contenus liés" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:41 +msgid "Anchors only?" +msgstr "Ancres seulement ?" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:42 +msgid "If 'yes', only paragraphs set as 'anchors' will be selected" +msgstr "Si 'oui', seuls les blocs de contenu désignés comme ancres seront sélectionnés" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:46 +msgid "Paragraph types" +msgstr "Types de blocs" + +#: src/pyams_default_theme/component/association/interfaces/__init__.py:47 +msgid "" +"Select list of paragraph types you want to include; an empty selection means " +"that all paragraphs will be selected" +msgstr "" +"Sélectionnez le type des blocs de contenu que vous souhaitez intégrer ; si vous laissez " +"la sélection vide, tous les types de blocs seront pris en compte" + #: src/pyams_default_theme/shared/view/templates/render.pt:2 msgid "View result items" msgstr "Aperçu du contenu de la vue" @@ -324,6 +364,9 @@ msgid "PyAMS simple header with banner and tabs" msgstr "PyAMS: en-tête simple avec bandeau et onglets de navigation" +#~ msgid "Default header renderer" +#~ msgstr "Par défaut" + #~ msgid "Search..." #~ msgstr "Chercher..." diff -r 9638eaef9d34 -r 62632a9571d5 src/pyams_default_theme/locales/pyams_default_theme.pot --- a/src/pyams_default_theme/locales/pyams_default_theme.pot Mon Sep 03 11:22:03 2018 +0200 +++ b/src/pyams_default_theme/locales/pyams_default_theme.pot Mon Sep 03 16:07:19 2018 +0200 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2018-07-19 17:00+0200\n" +"POT-Creation-Date: 2018-09-03 15:38+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" @@ -24,6 +24,10 @@ msgid "Default gallery renderer" msgstr "" +#: ./src/pyams_default_theme/component/keynumber/__init__.py:53 +msgid "Default key numbers renderer" +msgstr "" + #: ./src/pyams_default_theme/component/keynumber/portlet/__init__.py:55 msgid "Horizontal list with carousel" msgstr "" @@ -32,23 +36,27 @@ msgid "Vertical list" msgstr "" -#: ./src/pyams_default_theme/component/illustration/__init__.py:72 -msgid "Centered illustration" +#: ./src/pyams_default_theme/component/illustration/__init__.py:76 +msgid "Centered illustration before text" msgstr "" -#: ./src/pyams_default_theme/component/illustration/__init__.py:81 +#: ./src/pyams_default_theme/component/illustration/__init__.py:87 msgid "Small illustration on the left" msgstr "" -#: ./src/pyams_default_theme/component/illustration/__init__.py:92 +#: ./src/pyams_default_theme/component/illustration/__init__.py:99 msgid "Small illustration on the right" msgstr "" -#: ./src/pyams_default_theme/component/illustration/interfaces/__init__.py:30 +#: ./src/pyams_default_theme/component/illustration/__init__.py:111 +msgid "Centered illustration after text" +msgstr "" + +#: ./src/pyams_default_theme/component/illustration/interfaces/__init__.py:41 msgid "Zoom on click?" msgstr "" -#: ./src/pyams_default_theme/component/illustration/interfaces/__init__.py:31 +#: ./src/pyams_default_theme/component/illustration/interfaces/__init__.py:42 msgid "If 'yes', a click on illustration thumbnail is required to zoom" msgstr "" @@ -77,10 +85,6 @@ msgid "Default audio renderer" msgstr "" -#: ./src/pyams_default_theme/component/paragraph/keynumber.py:50 -msgid "Default key numbers renderer" -msgstr "" - #: ./src/pyams_default_theme/component/paragraph/frame.py:123 msgid "Default frame renderer" msgstr "" @@ -111,10 +115,6 @@ msgid "Default contact renderer" msgstr "" -#: ./src/pyams_default_theme/component/paragraph/header.py:40 -msgid "Default header renderer" -msgstr "" - #: ./src/pyams_default_theme/component/paragraph/zmi/map.py:62 msgid "Don't use default map configuration" msgstr "" @@ -203,10 +203,48 @@ msgid "Map position" msgstr "" -#: ./src/pyams_default_theme/component/association/__init__.py:41 +#: ./src/pyams_default_theme/component/association/__init__.py:48 msgid "Default associations renderer" msgstr "" +#: ./src/pyams_default_theme/component/association/__init__.py:89 +msgid "Include remote content" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:31 +msgid "Display title?" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:32 +msgid "Choose 'yes' to display remote content's title" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:36 +msgid "Display header?" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:37 +msgid "Choose 'yes' to display remote content's header" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:41 +msgid "Anchors only?" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:42 +msgid "If 'yes', only paragraphs set as 'anchors' will be selected" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:46 +msgid "Paragraph types" +msgstr "" + +#: ./src/pyams_default_theme/component/association/interfaces/__init__.py:47 +msgid "" +"Select list of paragraph types you want to include; an empty selection means " +"that all paragraphs will be selected" +msgstr "" + #: ./src/pyams_default_theme/shared/view/templates/render.pt:2 msgid "View result items" msgstr ""