# HG changeset patch # User Thierry Florac # Date 1571651137 -7200 # Node ID f07423f2dfc40999ffe094c60a9ff6f72be5be12 # Parent b923f4cfa9787f53404ec47ca2bc79c909c93781 Added width and offset to image map paragraph default renderer settings diff -r b923f4cfa978 -r f07423f2dfc4 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 b923f4cfa978 -r f07423f2dfc4 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 Fri Oct 18 16:56:20 2019 +0200 +++ b/src/pyams_default_theme/locales/fr/LC_MESSAGES/pyams_default_theme.po Mon Oct 21 11:45:37 2019 +0200 @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2019-10-18 15:15+0200\n" +"POT-Creation-Date: 2019-10-21 11:30+0200\n" "PO-Revision-Date: 2017-06-07 12:41+0200\n" "Last-Translator: Thierry Florac \n" "Language-Team: French\n" @@ -952,10 +952,34 @@ msgid "Four vertical panels with portrait illustrations" msgstr "Quatre panneaux verticaux avec illustrations en portrait" -#: src/pyams_default_theme/shared/imagemap/__init__.py:52 +#: src/pyams_default_theme/shared/imagemap/__init__.py:77 msgid "Default imagemap renderer" msgstr "Par défaut" +#: src/pyams_default_theme/shared/imagemap/interfaces.py:25 +msgid "Paragraph width" +msgstr "Largeur du bloc" + +#: src/pyams_default_theme/shared/imagemap/interfaces.py:26 +msgid "Width of the image map relative to it's parent portlet" +msgstr "" +"Largeur de l'image par rapport au bloc, en nombre de " +"\"colonnes\" (100% équivaut à 12 colonnes)" + +#: src/pyams_default_theme/shared/imagemap/interfaces.py:30 +msgid "Left offset" +msgstr "Décalage à gauche" + +#: src/pyams_default_theme/shared/imagemap/interfaces.py:31 +msgid "Left offset width, relative to it's parent portlet" +msgstr "" +"Largeur du décalaga à gauche de l'image par rapport au bloc, " +"en nombre de \"colonnes\"" + +#: src/pyams_default_theme/shared/imagemap/interfaces.py:38 +msgid "Sum of width and offset shouldn't be higher than 12!" +msgstr "La somme de la largeur du bloc et de son décalage à gauche ne doit pas dépasser 12 !" + #: src/pyams_default_theme/shared/imagemap/portlet/__init__.py:35 msgid "Responsive SVG image map" msgstr "Par défaut" diff -r b923f4cfa978 -r f07423f2dfc4 src/pyams_default_theme/locales/pyams_default_theme.pot --- a/src/pyams_default_theme/locales/pyams_default_theme.pot Fri Oct 18 16:56:20 2019 +0200 +++ b/src/pyams_default_theme/locales/pyams_default_theme.pot Mon Oct 21 11:45:37 2019 +0200 @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 1.0\n" -"POT-Creation-Date: 2019-10-18 15:15+0200\n" +"POT-Creation-Date: 2019-10-21 11:35+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" @@ -918,10 +918,30 @@ msgid "Four vertical panels with portrait illustrations" msgstr "" -#: ./src/pyams_default_theme/shared/imagemap/__init__.py:52 +#: ./src/pyams_default_theme/shared/imagemap/__init__.py:77 msgid "Default imagemap renderer" msgstr "" +#: ./src/pyams_default_theme/shared/imagemap/interfaces.py:25 +msgid "Paragraph width" +msgstr "" + +#: ./src/pyams_default_theme/shared/imagemap/interfaces.py:26 +msgid "Width of the image map relative to it's parent portlet" +msgstr "" + +#: ./src/pyams_default_theme/shared/imagemap/interfaces.py:30 +msgid "Left offset" +msgstr "" + +#: ./src/pyams_default_theme/shared/imagemap/interfaces.py:31 +msgid "Left offset width, relative to it's parent portlet" +msgstr "" + +#: ./src/pyams_default_theme/shared/imagemap/interfaces.py:38 +msgid "Sum of width and offset shouldn't be higher than 12!" +msgstr "" + #: ./src/pyams_default_theme/shared/imagemap/portlet/__init__.py:35 msgid "Responsive SVG image map" msgstr "" diff -r b923f4cfa978 -r f07423f2dfc4 src/pyams_default_theme/shared/imagemap/__init__.py --- a/src/pyams_default_theme/shared/imagemap/__init__.py Fri Oct 18 16:56:20 2019 +0200 +++ b/src/pyams_default_theme/shared/imagemap/__init__.py Mon Oct 21 11:45:37 2019 +0200 @@ -10,19 +10,26 @@ # FOR A PARTICULAR PURPOSE. # -__docformat__ = 'restructuredtext' +from persistent import Persistent +from zope.container.contained import Contained +from zope.schema.fieldproperty import FieldProperty from pyams_content.component.association.interfaces import IAssociationInfo from pyams_content.features.renderer.interfaces import IContentRenderer from pyams_content.shared.imagemap.interfaces import IImageMapParagraph, IWfImageMap from pyams_default_theme.features.renderer import BaseContentRenderer from pyams_default_theme.page import BasePreviewPage +from pyams_default_theme.shared.imagemap.interfaces import IImageMapParagraphDefaultRendererSettings from pyams_pagelet.pagelet import pagelet_config from pyams_skin.layer import IPyAMSLayer, IPyAMSUserLayer 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 pyams_utils.factory import factory_config from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION + +__docformat__ = 'restructuredtext' + from pyams_default_theme import _ @@ -33,8 +40,8 @@ @pagelet_config(name='preview.html', context=IWfImageMap, layer=IPyAMSUserLayer, permission=VIEW_SYSTEM_PERMISSION) @template_config(template='templates/render.pt', layer=IPyAMSLayer) -class ImagemapRenderer(BasePreviewPage): - """Image map renderer""" +class ImageMapPreviewer(BasePreviewPage): + """Image map preview renderer""" def get_item_info(self, item): return IAssociationInfo(item, None) @@ -44,12 +51,31 @@ # Imagemap paragraph renderer # +IMAGEMAP_DEFAULT_RENDERER_SETTINGS_KEY = 'pyams_content.imagemap.renderer:default' + + +@factory_config(IImageMapParagraphDefaultRendererSettings) +class ImageMapParagraphDefaultRendererSettings(Persistent, Contained): + """Image map paragraph default renderer settings""" + + width = FieldProperty(IImageMapParagraphDefaultRendererSettings['width']) + offset = FieldProperty(IImageMapParagraphDefaultRendererSettings['offset']) + + +@adapter_config(context=IImageMapParagraph, provides=IImageMapParagraphDefaultRendererSettings) +def imagemap_paragraph_default_renderer_settings_factory(context): + """Image map paragraph default renderer settings factory""" + return get_annotation_adapter(context, IMAGEMAP_DEFAULT_RENDERER_SETTINGS_KEY, + IImageMapParagraphDefaultRendererSettings) + + @adapter_config(name='default', context=(IImageMapParagraph, IPyAMSLayer), provides=IContentRenderer) @template_config(template='templates/imagemap-default.pt', layer=IPyAMSLayer) -class ImagemapDefaultParagraphRenderer(BaseContentRenderer): +class ImageMapParagraphDefaultRenderer(BaseContentRenderer): """Image map default paragraph renderer""" label = _("Default imagemap renderer") + settings_interface = IImageMapParagraphDefaultRendererSettings i18n_context_attrs = ('title',) diff -r b923f4cfa978 -r f07423f2dfc4 src/pyams_default_theme/shared/imagemap/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/shared/imagemap/interfaces.py Mon Oct 21 11:45:37 2019 +0200 @@ -0,0 +1,38 @@ +# +# Copyright (c) 2008-2019 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. +# + +from zope.interface import Interface, invariant, Invalid +from zope.schema import Choice + + +__docformat__ = 'restructuredtext' + +from pyams_default_theme import _ + + +class IImageMapParagraphDefaultRendererSettings(Interface): + """Image map paragraph default renderer settings interface""" + + width = Choice(title=_("Paragraph width"), + description=_("Width of the image map relative to it's parent portlet"), + values=(12, 11, 10, 9, 8, 7, 6, 5, 4), + default=12) + + offset = Choice(title=_("Left offset"), + description=_("Left offset width, relative to it's parent portlet"), + values=(0, 1, 2, 3, 4, 5, 6, 7, 8), + default=0) + + @invariant + def check_offset(self): + if (self.width + self.offset) > 12: + raise Invalid(_("Sum of width and offset shouldn't be higher than 12!")) diff -r b923f4cfa978 -r f07423f2dfc4 src/pyams_default_theme/shared/imagemap/templates/imagemap-default.pt --- a/src/pyams_default_theme/shared/imagemap/templates/imagemap-default.pt Fri Oct 18 16:56:20 2019 +0200 +++ b/src/pyams_default_theme/shared/imagemap/templates/imagemap-default.pt Mon Oct 21 11:45:37 2019 +0200 @@ -1,26 +1,30 @@ -

title

-
- - - - - - - - - - -
+

${title}

+
+
+ + + + + + + + + + +
+
\ No newline at end of file