Added spacer portlet
authorThierry Florac <thierry.florac@onf.fr>
Tue, 27 Nov 2018 13:55:31 +0100
changeset 221 dadc318d0871
parent 220 b2858d5e3449
child 222 50b97b22bdd7
Added spacer portlet
src/pyams_portal/portlets/spacer/__init__.py
src/pyams_portal/portlets/spacer/interfaces.py
src/pyams_portal/portlets/spacer/skin/__init__.py
src/pyams_portal/portlets/spacer/skin/spacer.pt
src/pyams_portal/portlets/spacer/zmi/__init__.py
src/pyams_portal/portlets/spacer/zmi/preview.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/spacer/__init__.py	Tue Nov 27 13:55:31 2018 +0100
@@ -0,0 +1,43 @@
+#
+# 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'
+
+from zope.interface import implementer
+
+from pyams_portal.portlet import portlet_config, Portlet, PortletSettings
+from pyams_portal.portlets.spacer.interfaces import ISpacerPortletSettings
+from pyams_utils.factory import factory_config
+from pyams_utils.interfaces import VIEW_PERMISSION
+
+from pyams_portal import _
+
+
+SPACER_PORTLET_NAME = 'pyams_portal.portlet.spacer'
+
+
+@factory_config(provided=ISpacerPortletSettings)
+@implementer(ISpacerPortletSettings)
+class SpacerPortletSettings(PortletSettings):
+    """Spacer portlet settings"""
+
+
+@portlet_config(permission=VIEW_PERMISSION)
+class SpacerPortlet(Portlet):
+    """Spacer portlet"""
+
+    name = SPACER_PORTLET_NAME
+    label = _("Spacer")
+
+    toolbar_css_class = 'fa fa-fw fa-2x fa-arrow-h'
+
+    settings_factory = ISpacerPortletSettings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/spacer/interfaces.py	Tue Nov 27 13:55:31 2018 +0100
@@ -0,0 +1,17 @@
+#
+# 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.
+#
+
+from pyams_portal.interfaces import IPortletSettings
+
+
+class ISpacerPortletSettings(IPortletSettings):
+    """Spacer portlet settings interface"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/spacer/skin/__init__.py	Tue Nov 27 13:55:31 2018 +0100
@@ -0,0 +1,32 @@
+#
+# 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'
+
+from zope.interface import Interface
+
+from pyams_portal.interfaces import IPortalContext, IPortletRenderer
+from pyams_portal.portlet import PortletRenderer
+from pyams_portal.portlets.spacer import ISpacerPortletSettings
+from pyams_skin.layer import IPyAMSLayer
+from pyams_template.template import template_config
+from pyams_utils.adapter import adapter_config
+
+from pyams_portal import _
+
+
+@adapter_config(context=(IPortalContext,IPyAMSLayer, Interface, ISpacerPortletSettings), provides=IPortletRenderer)
+@template_config(template='spacer.pt', layer=IPyAMSLayer)
+class SpacerPortletDefaultRenderer(PortletRenderer):
+    """Spacer portlet renderer"""
+
+    label = _("Default spacer renderer")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/spacer/skin/spacer.pt	Tue Nov 27 13:55:31 2018 +0100
@@ -0,0 +1,1 @@
+<hr />
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/spacer/zmi/__init__.py	Tue Nov 27 13:55:31 2018 +0100
@@ -0,0 +1,56 @@
+#
+# 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'
+
+from zope.interface import Interface
+
+from pyams_form.form import AJAXEditForm
+from pyams_form.interfaces.form import IInnerTabForm
+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.portlets.spacer import ISpacerPortletSettings
+from pyams_portal.zmi.portlet import PortletSettingsEditor, PortletSettingsPropertiesEditor
+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
+
+
+#
+# Spacer portlet properties
+#
+
+@pagelet_config(name='properties.html', context=ISpacerPortletSettings, request_type=IPyAMSLayer,
+                permission=VIEW_SYSTEM_PERMISSION)
+class SpacerPortletSettingsEditor(PortletSettingsEditor):
+    """Spacer HTML portlet settings editor"""
+
+    settings = ISpacerPortletSettings
+
+
+@adapter_config(name='properties', context=(Interface, IPyAMSLayer, SpacerPortletSettingsEditor), provides=IInnerTabForm)
+class SpacerPortletSettingsPropertiesEditor(PortletSettingsPropertiesEditor):
+    """Spacer portlet settings properties editor"""
+
+
+@adapter_config(name='properties.json', context=(ISpacerPortletSettings, IPyAMSLayer), provides=IPagelet)
+class SpacerPortletConfigurationAJAXEditor(AJAXEditForm, SpacerPortletSettingsEditor):
+    """Spacer portlet settings editor, AJAX renderer"""
+
+
+@adapter_config(context=(Interface, IPyAMSLayer, Interface, ISpacerPortletSettings), provides=IPortletPreviewer)
+@template_config(template='preview.pt', layer=IPyAMSLayer)
+class SpacerPortletPreviewer(PortletPreviewer):
+    """Spacer portlet previewer"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_portal/portlets/spacer/zmi/preview.pt	Tue Nov 27 13:55:31 2018 +0100
@@ -0,0 +1,1 @@
+<hr />
\ No newline at end of file