# HG changeset patch # User Thierry Florac # Date 1571404345 -7200 # Node ID 112904420dc21c0088ab02c837a95b4f825eadfd # Parent 0bf83e0553c47e3f08dd76535aafe1cfedb69710 Added SVG image-map portlet diff -r 0bf83e0553c4 -r 112904420dc2 src/pyams_content/shared/imagemap/portlet/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/imagemap/portlet/__init__.py Fri Oct 18 15:12:25 2019 +0200 @@ -0,0 +1,48 @@ +# +# 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.schema.fieldproperty import FieldProperty + +from pyams_content.component.links import InternalReferenceMixin +from pyams_content.shared.imagemap.portlet.interfaces import IImageMapPortletSettings +from pyams_portal.portlet import PortletSettings, portlet_config, Portlet +from pyams_utils.factory import factory_config +from pyams_utils.interfaces import VIEW_PERMISSION + + +__docformat__ = 'restructuredtext' + +from pyams_content import _ + + +IMAGEMAP_PORTLET_NAME = 'pyams_content.portlet.imagemap' + + +@factory_config(provided=IImageMapPortletSettings) +class ImageMapPortletSettings(PortletSettings, InternalReferenceMixin): + """Image map portlet settings""" + + title = FieldProperty(IImageMapPortletSettings['title']) + reference = FieldProperty(IImageMapPortletSettings['reference']) + + +@portlet_config(permission=VIEW_PERMISSION) +class ImageMapPortlet(Portlet): + """Image map portlet""" + + name = IMAGEMAP_PORTLET_NAME + label = _("Image map") + + toolbar_image = None + toolbar_css_class = 'fa fa-fw fa-2x fa-location-arrow' + + settings_factory = IImageMapPortletSettings diff -r 0bf83e0553c4 -r 112904420dc2 src/pyams_content/shared/imagemap/portlet/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/imagemap/portlet/interfaces.py Fri Oct 18 15:12:25 2019 +0200 @@ -0,0 +1,33 @@ +# +# 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 pyams_content.shared.imagemap import IMAGEMAP_CONTENT_TYPE +from pyams_i18n.schema import I18nTextLineField +from pyams_portal.interfaces import IPortletSettings +from pyams_sequence.interfaces import IInternalReference +from pyams_sequence.schema import InternalReferenceField + + +__docformat__ = 'restructuredtext' + +from pyams_content import _ + + +class IImageMapPortletSettings(IPortletSettings, IInternalReference): + """Image map portlet settings interface""" + + title = I18nTextLineField(title=_("Title"), + required=False) + + reference = InternalReferenceField(title=_("Internal reference"), + description=_("Reference to image map object"), + content_type=IMAGEMAP_CONTENT_TYPE) diff -r 0bf83e0553c4 -r 112904420dc2 src/pyams_content/shared/imagemap/portlet/zmi/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/imagemap/portlet/zmi/__init__.py Fri Oct 18 15:12:25 2019 +0200 @@ -0,0 +1,48 @@ +# +# 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 + +from pyams_content.shared.imagemap.portlet import IImageMapPortletSettings +from pyams_form.form import AJAXEditForm +from pyams_pagelet.interfaces import IPagelet +from pyams_pagelet.pagelet import pagelet_config +from pyams_portal.interfaces import IPortletPreviewer +from pyams_portal.portlet import PortletPreviewer +from pyams_portal.zmi.portlet import PortletSettingsEditor +from pyams_skin.layer import IPyAMSLayer +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config +from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION + + +__docformat__ = 'restructuredtext' + + +@pagelet_config(name='properties.html', context=IImageMapPortletSettings, layer=IPyAMSLayer, + permission=VIEW_SYSTEM_PERMISSION) +class ImageMapPortletSettingsEditor(PortletSettingsEditor): + """Image map portlet settings editor""" + + settings = IImageMapPortletSettings + + +@adapter_config(name='properties.json', context=(IImageMapPortletSettings, IPyAMSLayer), + provides=IPagelet) +class ImageMapPortletSettingsAJAXEditor(AJAXEditForm, ImageMapPortletSettingsEditor): + """Image mpa portlet settings editor, JSON renderer""" + + +@adapter_config(context=(Interface, IPyAMSLayer, Interface, IImageMapPortletSettings), + provides=IPortletPreviewer) +@template_config(template='templates/imagemap-preview.pt', layer=IPyAMSLayer) +class ImageMapPortletPreviewer(PortletPreviewer): + """Image map portlet previewer""" diff -r 0bf83e0553c4 -r 112904420dc2 src/pyams_content/shared/imagemap/portlet/zmi/templates/imagemap-preview.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/shared/imagemap/portlet/zmi/templates/imagemap-preview.pt Fri Oct 18 15:12:25 2019 +0200 @@ -0,0 +1,22 @@ +
+ + ${title}
+
+
+ + + + +
+ + + + +
+
+
+
\ No newline at end of file