Updated preview management
authorThierry Florac <thierry.florac@onf.fr>
Fri, 13 Oct 2017 08:41:15 +0200
changeset 230 dabf155776a9
parent 229 c9e2d01b0f8b
child 231 fbca11f0c1f4
Updated preview management
src/pyams_content/shared/imagemap/zmi/preview.py
src/pyams_content/shared/imagemap/zmi/summary.py
src/pyams_content/shared/imagemap/zmi/templates/preview.pt
src/pyams_content/shared/imagemap/zmi/templates/summary.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/imagemap/zmi/preview.py	Fri Oct 13 08:41:15 2017 +0200
@@ -0,0 +1,39 @@
+#
+# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
+# 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.association.interfaces import IAssociationInfo
+from pyams_content.shared.common.interfaces.zmi import IPreviewForm
+from pyams_content.shared.imagemap.interfaces import IWfImageMap
+from pyams_form.interfaces.form import IWidgetsSuffixViewletsManager
+from pyams_skin.layer import IPyAMSLayer
+from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
+
+# import packages
+from pyams_template.template import template_config
+from pyams_viewlet.viewlet import viewlet_config
+
+
+@viewlet_config(name='imagemap-preview', context=IWfImageMap, layer=IPyAMSLayer,
+                view=IPreviewForm, manager=IWidgetsSuffixViewletsManager,
+                permission=VIEW_SYSTEM_PERMISSION, weight=100)
+@template_config(template='templates/preview.pt', layer=IPyAMSLayer)
+class ImagemapPreview(object):
+    """Image map preview"""
+
+    def get_item_info(self, item):
+        return IAssociationInfo(item, None)
--- a/src/pyams_content/shared/imagemap/zmi/summary.py	Fri Oct 13 08:40:13 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
-# 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.association.interfaces import IAssociationContainer, IAssociationInfo
-from pyams_content.shared.common.interfaces.zmi import IInnerSummaryView
-from pyams_content.shared.imagemap.interfaces import IWfImageMap
-from pyams_form.interfaces.form import IInnerTabForm
-from pyams_skin.layer import IPyAMSLayer
-from pyams_utils.interfaces import VIEW_SYSTEM_PERMISSION
-
-# import packages
-from pyams_content.shared.common.zmi.summary import SharedContentSummaryForm
-from pyams_pagelet.pagelet import pagelet_config
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from pyams_zmi.form import InnerAdminDisplayForm
-from zope.interface import implementer
-
-from pyams_content import _
-
-
-@adapter_config(name='imagemap-summary',
-                context=(IWfImageMap, IPyAMSLayer, SharedContentSummaryForm),
-                provides=IInnerTabForm)
-class ImagemapSummary(InnerAdminDisplayForm):
-    """Image map summary view access tab"""
-
-    weight = 20
-    tab_label = _("Quick preview")
-    tab_target = 'imagemap-summary.html'
-
-
-@pagelet_config(name='imagemap-summary.html', context=IWfImageMap, layer=IPyAMSLayer,
-                permission=VIEW_SYSTEM_PERMISSION)
-@template_config(template='templates/summary.pt', layer=IPyAMSLayer)
-@implementer(IInnerSummaryView)
-class ImagemapSummaryView(object):
-    """Image map summary view"""
-
-    def get_item_info(self, item):
-        return IAssociationInfo(item, None)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/shared/imagemap/zmi/templates/preview.pt	Fri Oct 13 08:41:15 2017 +0200
@@ -0,0 +1,23 @@
+<div class="padding-y-5" i18n:domain="pyams_content"
+	 data-ams-plugins="pyams_content"
+	 tal:attributes="data-ams-plugin-pyams_content-src extension:resource_path('pyams_content.skin:pyams_content')">
+	<img usemap="#imagemap_preview"
+		 tal:define="image i18n:context.image"
+		 tal:attributes="src extension:absolute_url(image);"
+		 data-ams-callback="PyAMS_content.imgmap.initSummary" />
+	<map name="imagemap_preview">
+		<tal:loop repeat="area context.areas.values()">
+			<tal:var define="item context.get_association(area)"
+					 condition="item and item.visible">
+				<area shape="poly"
+					  tal:define="info view.get_item_info(item);
+								  area_title i18n:area.title;
+								  item_title i18n:info.user_title;
+								  title area_title or item_title;"
+					  tal:attributes="coords area.area;
+									  href item.get_url(request);
+									  title title;" />
+			</tal:var>
+		</tal:loop>
+	</map>
+</div>
--- a/src/pyams_content/shared/imagemap/zmi/templates/summary.pt	Fri Oct 13 08:40:13 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-<div class="inner no-padding" i18n:domain="pyams_content">
-	<fieldset>
-		<legend class="inner" i18n:translate="">Image areas preview</legend>
-		<div class="padding-y-5"
-			 data-ams-plugins="pyams_content"
-			 tal:attributes="data-ams-plugin-pyams_content-src extension:resource_path('pyams_content.skin:pyams_content')">
-			<img usemap="#imagemap_preview"
-				 tal:define="image i18n:context.image"
-				 tal:attributes="src extension:absolute_url(image);"
-				 data-ams-callback="PyAMS_content.imgmap.initSummary" />
-			<map name="imagemap_preview">
-				<tal:loop repeat="area context.areas.values()">
-					<tal:var define="item context.get_association(area)"
-							 condition="item and item.visible">
-						<area shape="poly"
-							  tal:define="info view.get_item_info(item);
-										  area_title i18n:area.title;
-										  item_title i18n:info.user_title;
-										  title area_title or item_title;"
-							  tal:attributes="coords area.area;
-											  href item.get_url(request);
-											  title title;" />
-					</tal:var>
-				</tal:loop>
-			</map>
-		</div>
-	</fieldset>
-</div>