Added site summary portlet renderer
authorThierry Florac <thierry.florac@onf.fr>
Mon, 26 Nov 2018 11:04:15 +0100
changeset 252 830495568da4
parent 251 cd3ac4329f32
child 253 b6ff1877cb48
Added site summary portlet renderer
src/pyams_default_theme/shared/site/portlet/__init__.py
src/pyams_default_theme/shared/site/portlet/templates/site-panels.pt
src/pyams_default_theme/shared/site/portlet/templates/site-summary.pt
--- a/src/pyams_default_theme/shared/site/portlet/__init__.py	Mon Nov 26 11:03:43 2018 +0100
+++ b/src/pyams_default_theme/shared/site/portlet/__init__.py	Mon Nov 26 11:04:15 2018 +0100
@@ -26,13 +26,8 @@
 from pyams_default_theme import _
 
 
-@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, ISiteContainerSummaryPortletSettings),
-                provides=IPortletRenderer)
-@template_config(template='templates/site-summary.pt', layer=IPyAMSLayer)
-class SiteContainerSummaryPortletDefaultRenderer(PortletRenderer):
-    """Site container summary portlet default renderer"""
-
-    label = _("Site container summary")
+class BaseSiteSummaryPortletRenderer(PortletRenderer):
+    """Base site summary portlet renderer"""
 
     @property
     def visible_items(self):
@@ -42,3 +37,22 @@
             yield from filter(lambda x: x is not None,
                               [registry.queryMultiAdapter((item, self.request), IContentSummaryInfo)
                                for item in container.get_visible_items(self.request)])
+
+
+@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, ISiteContainerSummaryPortletSettings),
+                provides=IPortletRenderer)
+@template_config(template='templates/site-summary.pt', layer=IPyAMSLayer)
+class SiteContainerSummaryPortletDefaultRenderer(BaseSiteSummaryPortletRenderer):
+    """Site container summary portlet default renderer"""
+
+    label = _("Site container summary")
+
+
+@adapter_config(name='summary-panels',
+                context=(IPortalContext, IPyAMSLayer, Interface, ISiteContainerSummaryPortletSettings),
+                provides=IPortletRenderer)
+@template_config(template='templates/site-panels.pt', layer=IPyAMSLayer)
+class SiteContainerSummaryPortletPanelsRenderer(BaseSiteSummaryPortletRenderer):
+    """Site container summary portlet panels renderer"""
+
+    label = _("Vertical panels with panoramic illustrations")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/shared/site/portlet/templates/site-panels.pt	Mon Nov 26 11:04:15 2018 +0100
@@ -0,0 +1,35 @@
+<div class="panels" i18n:domain="pyams_default_theme"
+	 tal:define="settings view.settings;
+				 button_title i18n:settings.button_title;">
+	<h2 tal:condition="settings.title">${i18n:settings.title}</h2>
+	<div tal:repeat="item view.visible_items"
+		 class="col-sm-4">
+		<tal:var define="target tales:relative_url(item.context)">
+			<div class="thumbnail pull-left hidden-xs">
+				<a tal:define="illustration tales:pyams_illustration(item.context)"
+				   tal:condition="illustration"
+				   href="${target}">
+					<tal:if define="image i18n:illustration.data;
+									alt i18n:illustration.alt_title;"
+							condition="image">
+						${structure:tales:picture(image, lg_thumb='pano', lg_width=4, md_thumb='pano', md_width=4,
+												  sm_thumb='pano', sm_width=4, xs_thumb='pano', xs_width=12, alt=alt)}
+					</tal:if>
+				</a>
+			</div>
+			<div>
+				<a href="${target}">
+					<h3>${item.title}</h3>
+				</a>
+				<div class="header">${structure:tales:html(item.header)}</div>
+				<div class="action">
+					<a tal:condition="button_title"
+					   href="${target}">
+						<span i18n:translate="">${button_title}</span>
+					</a>
+				</div>
+			</div>
+		</tal:var>
+	</div>
+	<div class="clearfix"></div>
+</div>
\ No newline at end of file
--- a/src/pyams_default_theme/shared/site/portlet/templates/site-summary.pt	Mon Nov 26 11:03:43 2018 +0100
+++ b/src/pyams_default_theme/shared/site/portlet/templates/site-summary.pt	Mon Nov 26 11:04:15 2018 +0100
@@ -1,6 +1,7 @@
 <div i18n:domain="pyams_default_theme"
 	 tal:define="settings view.settings;
 				 button_title i18n:settings.button_title;">
+	<h2 tal:condition="settings.title">${i18n:settings.title}</h2>
 	<div class="summary">
 		<div tal:repeat="item view.visible_items">
 			<tal:var define="target tales:relative_url(item.context)">
@@ -17,7 +18,9 @@
 					</a>
 				</div>
 				<div>
-					<h2>${item.title}</h2>
+					<a href="${target}">
+						<h3>${item.title}</h3>
+					</a>
 					<div class="header">${structure:tales:html(item.header)}</div>
 					<div class="action">
 						<a href="${target}">