Added default banner and logo
authorThierry Florac <thierry.florac@onf.fr>
Mon, 09 Jul 2018 11:53:51 +0200
changeset 76 777ca38e9d26
parent 75 c87bb4047e5d
child 77 cf7ff7b5cbf3
Added default banner and logo
src/pyams_default_theme/viewlet/__init__.py
src/pyams_default_theme/viewlet/banner/__init__.py
src/pyams_default_theme/viewlet/banner/templates/banner.pt
src/pyams_default_theme/viewlet/logo/__init__.py
src/pyams_default_theme/viewlet/logo/templates/logo.pt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/viewlet/__init__.py	Mon Jul 09 11:53:51 2018 +0200
@@ -0,0 +1,19 @@
+#
+# Copyright (c) 2008-2017 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
+
+# import packages
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/viewlet/banner/__init__.py	Mon Jul 09 11:53:51 2018 +0200
@@ -0,0 +1,38 @@
+#
+# 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_content.features.header.interfaces import IHeaderTarget, IHeaderSettings
+from pyams_default_theme.features.header.interfaces import ISimpleHeaderRendererSettings
+from pyams_skin.layer import IPyAMSUserLayer
+
+# import packages
+from pyams_template.template import template_config
+from pyams_utils.traversing import get_parent
+from pyams_viewlet.viewlet import contentprovider_config, ViewContentProvider
+from zope.interface import Interface
+
+
+@contentprovider_config(name='pyams.banner', layer=IPyAMSUserLayer, view=Interface)
+@template_config(template='templates/banner.pt', layer=IPyAMSUserLayer)
+class Banner(ViewContentProvider):
+    """Banner content provider"""
+
+    @property
+    def settings(self):
+        target = get_parent(self.context, IHeaderTarget)
+        return ISimpleHeaderRendererSettings(IHeaderSettings(target).settings, None)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/viewlet/banner/templates/banner.pt	Mon Jul 09 11:53:51 2018 +0200
@@ -0,0 +1,12 @@
+<section class="wrapper-regularbanner" i18n:domain="onf_website"
+		 tal:define="settings view.settings"
+		 tal:condition="settings and settings.banner">
+	<div class="regularbanner">
+		<div class="regularbanner__bg">
+			<img alt="" class="regularbanner__media"
+				 tal:define="image settings.banner"
+				 tal:attributes="src extension:absolute_url(image, '++thumb++w1320')" />
+		</div>  <!-- /.regularbanner__bg -->
+		<tal:var content="structure provider:pyams.logo" />
+	</div>  <!-- /.regularbanner -->
+</section>  <!-- /.wrapper-regularbanner -->
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/viewlet/logo/__init__.py	Mon Jul 09 11:53:51 2018 +0200
@@ -0,0 +1,37 @@
+#
+# Copyright (c) 2008-2017 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.features.header.interfaces import IHeaderTarget, IHeaderSettings
+from pyams_default_theme.features.header import ISimpleHeaderRendererSettings
+from pyams_skin.layer import IPyAMSUserLayer
+
+# import packages
+from pyams_template.template import template_config
+from pyams_utils.traversing import get_parent
+from pyams_viewlet.viewlet import contentprovider_config, ViewContentProvider
+from zope.interface import Interface
+
+
+@contentprovider_config(name='pyams.logo', layer=IPyAMSUserLayer, view=Interface)
+@template_config(template='templates/logo.pt', layer=IPyAMSUserLayer)
+class LogoContentProvider(ViewContentProvider):
+    """Logo content provider"""
+
+    @property
+    def settings(self):
+        target = get_parent(self.context, IHeaderTarget)
+        return ISimpleHeaderRendererSettings(IHeaderSettings(target).settings, None)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/viewlet/logo/templates/logo.pt	Mon Jul 09 11:53:51 2018 +0200
@@ -0,0 +1,11 @@
+<tal:var define="settings view.settings"
+		 condition="settings" i18n:domain="pyams_default_theme">
+	<tal:if define="logo settings.logo"
+			condition="logo">
+		<a href="/" title="Back home" i18n:attributes="title">
+			<img class="logo"
+				 tal:define="src extension:absolute_url(settings.logo, '++thumb++200x200')"
+				 tal:attributes="src string:${src}?_=${extension:timestamp(logo)}" />
+		</a>
+	</tal:if>
+</tal:var>
\ No newline at end of file