Moved renderers and templates to "skin" module
authorThierry Florac <thierry.florac@onf.fr>
Wed, 23 May 2018 15:07:59 +0200
changeset 89 9a580d85a427
parent 88 d44d666ca164
child 90 a189d7fac6d9
Moved renderers and templates to "skin" module
src/pyams_portal/portlets/content/__init__.py
src/pyams_portal/portlets/content/content.pt
src/pyams_portal/portlets/content/skin/__init__.py
src/pyams_portal/portlets/content/skin/content.pt
src/pyams_portal/portlets/html/__init__.py
src/pyams_portal/portlets/html/html.pt
src/pyams_portal/portlets/html/skin/__init__.py
src/pyams_portal/portlets/html/skin/html.pt
src/pyams_portal/portlets/image/__init__.py
src/pyams_portal/portlets/image/image.pt
src/pyams_portal/portlets/image/skin/__init__.py
src/pyams_portal/portlets/image/skin/image.pt
--- a/src/pyams_portal/portlets/content/__init__.py	Wed May 23 15:07:07 2018 +0200
+++ b/src/pyams_portal/portlets/content/__init__.py	Wed May 23 15:07:59 2018 +0200
@@ -17,15 +17,11 @@
 
 # import interfaces
 from .interfaces import IContentPortletSettings
-from pyams_portal.interfaces import IPortletRenderer, IPortalContext
-from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import VIEW_PERMISSION
 
 # import packages
-from pyams_portal.portlet import PortletSettings, Portlet, PortletRenderer, portlet_config
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from zope.interface import implementer, Interface
+from pyams_portal.portlet import PortletSettings, Portlet, portlet_config
+from zope.interface import implementer
 
 from pyams_portal import _
 
@@ -46,11 +42,3 @@
     label = _("Context content")
 
     settings_class = ContentPortletSettings
-
-
-@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IContentPortletSettings), provides=IPortletRenderer)
-@template_config(template='content.pt', layer=IPyAMSLayer)
-class ContentPortletRenderer(PortletRenderer):
-    """Content portlet renderer"""
-
-    label = _("Default content renderer")
--- a/src/pyams_portal/portlets/content/content.pt	Wed May 23 15:07:07 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-<h3>This is my context !!!</h3>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/content/skin/__init__.py	Wed May 23 15:07:59 2018 +0200
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2008-2018 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_portal.interfaces import IPortalContext, IPortletRenderer
+from pyams_portal.portlets.content.interfaces import IContentPortletSettings
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_portal.portlet import PortletRenderer
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+from zope.interface import Interface
+
+from pyams_portal import _
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IContentPortletSettings), provides=IPortletRenderer)
+@template_config(template='content.pt', layer=IPyAMSLayer)
+class ContentPortletRenderer(PortletRenderer):
+    """Content portlet renderer"""
+
+    label = _("Default content renderer")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/content/skin/content.pt	Wed May 23 15:07:59 2018 +0200
@@ -0,0 +1,1 @@
+<h3>This is my context !!!</h3>
--- a/src/pyams_portal/portlets/html/__init__.py	Wed May 23 15:07:07 2018 +0200
+++ b/src/pyams_portal/portlets/html/__init__.py	Wed May 23 15:07:59 2018 +0200
@@ -16,16 +16,12 @@
 # import standard library
 
 # import interfaces
-from pyams_portal.interfaces import IPortalContext, IPortletRenderer
 from pyams_portal.portlets.html.interfaces import IRawPortletSettings, IHTMLPortletSettings
-from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import VIEW_PERMISSION
 
 # import packages
-from pyams_portal.portlet import PortletSettings, portlet_config, Portlet, PortletRenderer
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from zope.interface import implementer, Interface
+from pyams_portal.portlet import PortletSettings, portlet_config, Portlet
+from zope.interface import implementer
 from zope.schema.fieldproperty import FieldProperty
 
 from pyams_portal import _
@@ -57,14 +53,6 @@
     settings_class = RawPortletSettings
 
 
-@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IRawPortletSettings), provides=IPortletRenderer)
-@template_config(template='html.pt', layer=IPyAMSLayer)
-class RawPortletDefaultRenderer(PortletRenderer):
-    """Raw HTML portlet renderer"""
-
-    label = _("Default code renderer")
-
-
 #
 # Rich text portlet
 #
@@ -89,11 +77,3 @@
     toolbar_css_class = 'fa fa-fw fa-2x fa-html5'
 
     settings_class = HTMLPortletSettings
-
-
-@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IHTMLPortletSettings), provides=IPortletRenderer)
-@template_config(template='html.pt', layer=IPyAMSLayer)
-class HTMLPortletDefaultRenderer(PortletRenderer):
-    """Rich text portlet renderer"""
-
-    label = _("Default text renderer")
--- a/src/pyams_portal/portlets/html/html.pt	Wed May 23 15:07:07 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-<tal:var replace="structure i18n:view.settings.body">HTML code</tal:var>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/html/skin/__init__.py	Wed May 23 15:07:59 2018 +0200
@@ -0,0 +1,45 @@
+#
+# Copyright (c) 2008-2018 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_portal.interfaces import IPortalContext, IPortletRenderer
+from pyams_portal.portlets.html.interfaces import IRawPortletSettings, IHTMLPortletSettings
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_portal.portlet import PortletRenderer
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+from zope.interface import Interface
+
+from pyams_portal import _
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IRawPortletSettings), provides=IPortletRenderer)
+@template_config(template='html.pt', layer=IPyAMSLayer)
+class RawPortletDefaultRenderer(PortletRenderer):
+    """Raw HTML portlet renderer"""
+
+    label = _("Default code renderer")
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IHTMLPortletSettings), provides=IPortletRenderer)
+@template_config(template='html.pt', layer=IPyAMSLayer)
+class HTMLPortletDefaultRenderer(PortletRenderer):
+    """Rich text portlet renderer"""
+
+    label = _("Default text renderer")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/html/skin/html.pt	Wed May 23 15:07:59 2018 +0200
@@ -0,0 +1,1 @@
+<tal:var replace="structure i18n:view.settings.body">HTML code</tal:var>
\ No newline at end of file
--- a/src/pyams_portal/portlets/image/__init__.py	Wed May 23 15:07:07 2018 +0200
+++ b/src/pyams_portal/portlets/image/__init__.py	Wed May 23 15:07:59 2018 +0200
@@ -18,16 +18,12 @@
 # import interfaces
 from .interfaces import IImagePortletSettings
 from pyams_file.interfaces import IResponsiveImage, DELETED_FILE
-from pyams_portal.interfaces import IPortalContext, IPortletRenderer
-from pyams_skin.layer import IPyAMSLayer
 from pyams_utils.interfaces import VIEW_PERMISSION
 
 # import packages
 from pyams_file.property import FileProperty
-from pyams_portal.portlet import portlet_config, Portlet, PortletSettings, PortletRenderer
-from pyams_template.template import template_config
-from pyams_utils.adapter import adapter_config
-from zope.interface import implementer, Interface, alsoProvides
+from pyams_portal.portlet import portlet_config, Portlet, PortletSettings
+from zope.interface import implementer, alsoProvides
 
 from pyams_portal import _
 
@@ -63,11 +59,3 @@
     toolbar_css_class = 'fa fa-fw fa-2x fa-picture-o'
 
     settings_class = ImagePortletSettings
-
-
-@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IImagePortletSettings), provides=IPortletRenderer)
-@template_config(template='image.pt', layer=IPyAMSLayer)
-class ImagePortletRenderer(PortletRenderer):
-    """Image portlet renderer"""
-
-    label = _("Responsive image renderer")
--- a/src/pyams_portal/portlets/image/image.pt	Wed May 23 15:07:07 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-<tal:if condition="view.settings.image">
-	<picture
-		tal:define="image view.settings.image;
-					image_url extension:absolute_url(image);
-					slot_config view.slot_configuration;
-					slot_width slot_config.get_width();
-					base_width 100 / 12;">
-		<tal:var define="width slot_width['lg']">
-			<source media="(min-width: 1200px)"
-					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++lg:w1200 1200w, ${image_url}/++thumb++lg:w512 512w, ${image_url}/++thumb++lg:w256 256w, ${image_url}/++thumb++lg:w128 128w;
-									sizes string:${round(base_width * width)}vw" />
-			<source media="(min-width: 1200px)"
-					srcset="/--static--/pyams_default_theme/img/dot.png"
-					tal:condition="not:width"
-					tal:attributes="sizes string:${round(base_width * width)}vw" />
-		</tal:var>
-		<tal:var define="width slot_width['md']">
-			<source media="(min-width: 992px)"
-					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++md:w992 992w, ${image_url}/++thumb++md:w512 512w, ${image_url}/++thumb++md:w256 256w, ${image_url}/++thumb++md:w128 128w;
-									sizes string:${round(base_width * width)}vw" />
-			<source media="(min-width: 992px)"
-					srcset="/--static--/pyams_default_theme/img/dot.png"
-					tal:condition="not:width"
-					tal:attributes="sizes string:${round(base_width * width)}vw" />
-		</tal:var>
-		<tal:var define="width slot_width['sm']">
-			<source media="(min-width: 768px)"
-					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++sm:w768 768w, ${image_url}/++thumb++sm:w512 512w, ${image_url}/++thumb++sm:w256 256w, ${image_url}/++thumb++sm:w128 128w;
-									sizes string:${round(base_width * width)}vw" />
-			<source media="(min-width: 768px)"
-					srcset="/--static--/pyams_default_theme/img/dot.png"
-					tal:condition="not:width"
-					tal:attributes="sizes string:${round(base_width * width)}vw" />
-		</tal:var>
-		<tal:var define="width slot_width['xs']">
-			<source media="(max-width: 767px)"
-					tal:condition="width"
-					tal:attributes="srcset string:${image_url}/++thumb++xs:w768 768w, ${image_url}/++thumb++xs:w512 512w, ${image_url}/++thumb++xs:w256 256w, ${image_url}/++thumb++xs:w128 128w;
-									sizes string:${round(base_width * width)}vw" />
-			<source media="(max-width: 767px)"
-					srcset="/--static--/pyams_default_theme/img/dot.png"
-					tal:condition="not:width"
-					tal:attributes="sizes string:${round(base_width * width)}vw" />
-		</tal:var>
-		<img style="width: 100%;" tal:attributes="src image_url" />
-	</picture>
-</tal:if>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/image/skin/__init__.py	Wed May 23 15:07:59 2018 +0200
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2008-2018 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_portal.interfaces import IPortalContext, IPortletRenderer
+from pyams_portal.portlets.image.interfaces import IImagePortletSettings
+from pyams_skin.layer import IPyAMSLayer
+
+# import packages
+from pyams_portal.portlet import PortletRenderer
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+from zope.interface import Interface
+
+from pyams_portal import _
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IImagePortletSettings), provides=IPortletRenderer)
+@template_config(template='image.pt', layer=IPyAMSLayer)
+class ImagePortletRenderer(PortletRenderer):
+    """Image portlet renderer"""
+
+    label = _("Responsive image renderer")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/image/skin/image.pt	Wed May 23 15:07:59 2018 +0200
@@ -0,0 +1,50 @@
+<tal:if condition="view.settings.image">
+	<picture
+		tal:define="image view.settings.image;
+					image_url extension:absolute_url(image);
+					slot_config view.slot_configuration;
+					slot_width slot_config.get_width();
+					base_width 100 / 12;">
+		<tal:var define="width slot_width['lg']">
+			<source media="(min-width: 1200px)"
+					tal:condition="width"
+					tal:attributes="srcset string:${image_url}/++thumb++lg:w1200 1200w, ${image_url}/++thumb++lg:w512 512w, ${image_url}/++thumb++lg:w256 256w, ${image_url}/++thumb++lg:w128 128w;
+									sizes string:${round(base_width * width)}vw" />
+			<source media="(min-width: 1200px)"
+					srcset="/--static--/pyams_default_theme/img/dot.png"
+					tal:condition="not:width"
+					tal:attributes="sizes string:${round(base_width * width)}vw" />
+		</tal:var>
+		<tal:var define="width slot_width['md']">
+			<source media="(min-width: 992px)"
+					tal:condition="width"
+					tal:attributes="srcset string:${image_url}/++thumb++md:w992 992w, ${image_url}/++thumb++md:w512 512w, ${image_url}/++thumb++md:w256 256w, ${image_url}/++thumb++md:w128 128w;
+									sizes string:${round(base_width * width)}vw" />
+			<source media="(min-width: 992px)"
+					srcset="/--static--/pyams_default_theme/img/dot.png"
+					tal:condition="not:width"
+					tal:attributes="sizes string:${round(base_width * width)}vw" />
+		</tal:var>
+		<tal:var define="width slot_width['sm']">
+			<source media="(min-width: 768px)"
+					tal:condition="width"
+					tal:attributes="srcset string:${image_url}/++thumb++sm:w768 768w, ${image_url}/++thumb++sm:w512 512w, ${image_url}/++thumb++sm:w256 256w, ${image_url}/++thumb++sm:w128 128w;
+									sizes string:${round(base_width * width)}vw" />
+			<source media="(min-width: 768px)"
+					srcset="/--static--/pyams_default_theme/img/dot.png"
+					tal:condition="not:width"
+					tal:attributes="sizes string:${round(base_width * width)}vw" />
+		</tal:var>
+		<tal:var define="width slot_width['xs']">
+			<source media="(max-width: 767px)"
+					tal:condition="width"
+					tal:attributes="srcset string:${image_url}/++thumb++xs:w768 768w, ${image_url}/++thumb++xs:w512 512w, ${image_url}/++thumb++xs:w256 256w, ${image_url}/++thumb++xs:w128 128w;
+									sizes string:${round(base_width * width)}vw" />
+			<source media="(max-width: 767px)"
+					srcset="/--static--/pyams_default_theme/img/dot.png"
+					tal:condition="not:width"
+					tal:attributes="sizes string:${round(base_width * width)}vw" />
+		</tal:var>
+		<img style="width: 100%;" tal:attributes="src image_url" />
+	</picture>
+</tal:if>