Added Title field for Raw HTML portlet. doc-dc
authorDamien Correia
Wed, 29 Aug 2018 16:55:28 +0200
branchdoc-dc
changeset 166 4a57e6e76d5f
parent 165 c5e34981deac
child 167 885d64d94aed
Added Title field for Raw HTML portlet.
src/pyams_portal/portlets/html/__init__.py
src/pyams_portal/portlets/html/interfaces.py
src/pyams_portal/portlets/html/skin/__init__.py
src/pyams_portal/portlets/html/skin/raw.pt
src/pyams_portal/portlets/html/zmi/__init__.py
src/pyams_portal/portlets/html/zmi/raw-preview.pt
--- a/src/pyams_portal/portlets/html/__init__.py	Tue Aug 28 15:42:39 2018 +0200
+++ b/src/pyams_portal/portlets/html/__init__.py	Wed Aug 29 16:55:28 2018 +0200
@@ -40,6 +40,7 @@
 class RawPortletSettings(PortletSettings):
     """Raw HTML code portlet settings"""
 
+    title = FieldProperty(IRawPortletSettings['title'])
     body = FieldProperty(IRawPortletSettings['body'])
 
 
--- a/src/pyams_portal/portlets/html/interfaces.py	Tue Aug 28 15:42:39 2018 +0200
+++ b/src/pyams_portal/portlets/html/interfaces.py	Wed Aug 29 16:55:28 2018 +0200
@@ -19,8 +19,7 @@
 from pyams_portal.interfaces import IPortletSettings
 
 # import packages
-from pyams_i18n.schema import I18nTextField, I18nHTMLField
-
+from pyams_i18n.schema import I18nTextField, I18nHTMLField, I18nTextLineField
 
 from pyams_portal import _
 
@@ -28,6 +27,8 @@
 class IRawPortletSettings(IPortletSettings):
     """Raw HTML code portlet settings interface"""
 
+    title = I18nTextLineField(title=_("ยง Title"),
+                              required=False)
     body = I18nTextField(title=_("Raw HTML code"),
                          description=_("This HTML code will be used 'as is', without any transformation. Use with "
                                        "care!!"),
--- a/src/pyams_portal/portlets/html/skin/__init__.py	Tue Aug 28 15:42:39 2018 +0200
+++ b/src/pyams_portal/portlets/html/skin/__init__.py	Wed Aug 29 16:55:28 2018 +0200
@@ -30,7 +30,7 @@
 
 
 @adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, IRawPortletSettings), provides=IPortletRenderer)
-@template_config(template='html.pt', layer=IPyAMSLayer)
+@template_config(template='raw.pt', layer=IPyAMSLayer)
 class RawPortletDefaultRenderer(PortletRenderer):
     """Raw HTML portlet renderer"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/html/skin/raw.pt	Wed Aug 29 16:55:28 2018 +0200
@@ -0,0 +1,3 @@
+<h3 tal:condition="i18n:view.settings.title"
+    tal:content="i18n:view.settings.title">Title</h3>
+<tal:var replace="structure i18n:view.settings.body">HTML code</tal:var>
--- a/src/pyams_portal/portlets/html/zmi/__init__.py	Tue Aug 28 15:42:39 2018 +0200
+++ b/src/pyams_portal/portlets/html/zmi/__init__.py	Wed Aug 29 16:55:28 2018 +0200
@@ -61,7 +61,7 @@
 
 
 @adapter_config(context=(Interface, IPyAMSLayer, Interface, IRawPortletSettings), provides=IPortletPreviewer)
-@template_config(template='preview.pt', layer=IPyAMSLayer)
+@template_config(template='raw-preview.pt', layer=IPyAMSLayer)
 class RawPortletPreviewer(PortletPreviewer):
     """Raw HTML portlet previewer"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/html/zmi/raw-preview.pt	Wed Aug 29 16:55:28 2018 +0200
@@ -0,0 +1,5 @@
+<strong tal:define="title i18n:view.settings.title"
+		tal:condition="title">
+	<tal:var content="title" /><br />
+</strong>
+<tal:var replace="structure i18n:view.settings.body">HTML code</tal:var>