--- a/src/pyams_default_theme/shared/view/portlet/__init__.py Mon Jan 07 10:10:44 2019 +0100
+++ b/src/pyams_default_theme/shared/view/portlet/__init__.py Mon Jan 07 10:11:18 2019 +0100
@@ -18,7 +18,8 @@
from zope.schema.fieldproperty import FieldProperty
from pyams_content.shared.view.portlet.interfaces import IViewItemsPortletSettings
-from pyams_default_theme.shared.view.portlet.interfaces import IViewItemsPortletVerticalRendererSettings
+from pyams_default_theme.shared.view.portlet.interfaces import IViewItemsPortletVerticalRendererSettings, \
+ IViewItemsPortletHorizontalRendererSettings
from pyams_portal.interfaces import IPortalContext, IPortletRenderer
from pyams_portal.portlet import PortletRenderer
from pyams_skin.layer import IPyAMSLayer
@@ -29,11 +30,18 @@
from pyams_default_theme import _
+#
+# Default view portlet renderer
+#
+
@factory_config(provided=IViewItemsPortletVerticalRendererSettings)
class ViewItemsPortletVerticalRendererSettings(Persistent, Contained):
- """View items portlet renderer settings"""
+ """View items portlet vertical renderer settings"""
display_illustrations = FieldProperty(IViewItemsPortletVerticalRendererSettings['display_illustrations'])
+ thumbnails_selection = FieldProperty(IViewItemsPortletVerticalRendererSettings['thumbnails_selection'])
+ display_breadcrumbs = FieldProperty(IViewItemsPortletVerticalRendererSettings['display_breadcrumbs'])
+ display_tags = FieldProperty(IViewItemsPortletVerticalRendererSettings['display_tags'])
paginate = FieldProperty(IViewItemsPortletVerticalRendererSettings['paginate'])
page_size = FieldProperty(IViewItemsPortletVerticalRendererSettings['page_size'])
@@ -42,9 +50,33 @@
provides=IPortletRenderer)
@template_config(template='templates/view-items-list.pt', layer=IPyAMSLayer)
class ViewItemsPortletVerticalRenderer(PortletRenderer):
- """View items portlet renderer"""
+ """View items portlet vertical renderer"""
label = _("Simple vertical view")
weight = 0
settings_interface = IViewItemsPortletVerticalRendererSettings
+
+
+#
+# Small pictures portlet renderer
+#
+
+@factory_config(provided=IViewItemsPortletHorizontalRendererSettings)
+class ViewItemsPortletHorizontalRendererSettings(Persistent, Contained):
+ """View items portlet horizontal renderer settings"""
+
+ thumbnails_selection = FieldProperty(IViewItemsPortletHorizontalRendererSettings['thumbnails_selection'])
+
+
+@adapter_config(name='horizontal',
+ context=(IPortalContext, IPyAMSLayer, Interface, IViewItemsPortletSettings),
+ provides=IPortletRenderer)
+@template_config(template='templates/view-items-horiz-list.pt', layer=IPyAMSLayer)
+class ViewItemsPortletHorizontalRenderer(PortletRenderer):
+ """View items portlet horizontal renderer"""
+
+ label = _("Simple horizontal thumbnails view")
+ weight = 1
+
+ settings_interface = IViewItemsPortletHorizontalRendererSettings
--- a/src/pyams_default_theme/shared/view/portlet/interfaces.py Mon Jan 07 10:10:44 2019 +0100
+++ b/src/pyams_default_theme/shared/view/portlet/interfaces.py Mon Jan 07 10:11:18 2019 +0100
@@ -13,11 +13,22 @@
__docformat__ = 'restructuredtext'
from zope.interface import Interface
-from zope.schema import Bool, Int
+from zope.schema import Bool, Int, Choice
+from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
from pyams_default_theme import _
+VIEW_ITEMS_THUMBNAILS = (
+ {'id': 'portrait', 'title': _("Portrait selection")},
+ {'id': 'pano', 'title': _("Panoramic selection")},
+ {'id': 'square', 'title': _("Square selection")}
+)
+
+VIEW_ITEMS_THUMBNAILS_VOCABULARY = SimpleVocabulary([SimpleTerm(item['id'], title=item['title'])
+ for item in VIEW_ITEMS_THUMBNAILS])
+
+
class IViewItemsPortletVerticalRendererSettings(Interface):
"""View items portlet vertical renderer settings interface"""
@@ -26,6 +37,22 @@
required=True,
default=True)
+ thumbnails_selection = Choice(title=_("Thumbnails selection"),
+ description=_("Selection used to display images thumbnails"),
+ vocabulary=VIEW_ITEMS_THUMBNAILS_VOCABULARY,
+ required=True,
+ default='pano')
+
+ display_breadcrumbs = Bool(title=_("Display breadcrumbs?"),
+ description=_("If 'no', view items breadcrumbs will not be displayed"),
+ required=True,
+ default=True)
+
+ display_tags = Bool(title=_("Display tags?"),
+ description=_("If 'no', view items tags will not be displayed"),
+ required=True,
+ default=True)
+
paginate = Bool(title=_("Paginate?"),
description=_("If 'no', results pagination will be disabled"),
required=True,
@@ -35,3 +62,13 @@
description=_("Number of items per page, if pagination is enabled"),
required=False,
default=10)
+
+
+class IViewItemsPortletHorizontalRendererSettings(Interface):
+ """View items portlet horizontal renderer settings interface"""
+
+ thumbnails_selection = Choice(title=_("Thumbnails selection"),
+ description=_("Selection used to display images thumbnails"),
+ vocabulary=VIEW_ITEMS_THUMBNAILS_VOCABULARY,
+ required=True,
+ default='portrait')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/shared/view/portlet/templates/view-items-horiz-list.pt Mon Jan 07 10:11:18 2019 +0100
@@ -0,0 +1,30 @@
+<div tal:define="settings view.settings;
+ renderer_settings view.renderer_settings;"
+ i18n:domain="pyams_default_theme">
+ <h2>${i18n:settings.title}</h2>
+ <div tal:define="items settings.get_items(request);
+ limit settings.limit;
+ selection renderer_settings.thumbnails_selection;
+ lg_width 1 if selection == 'portrait' and limit > 6 else 2;
+ md_width 1 if selection == 'portrait' and limit > 6 else 2;
+ sm_width 2 if selection == 'portrait' and limit > 6 else 3;
+ xs_width 2 if selection == 'portrait' and limit > 6 else 3;">
+ <tal:loop repeat="item items">
+ <div class="thumbnail col-lg-${lg_width} col-md-${md_width} col-sm-${sm_width} col-xs-${xs_width}"
+ tal:define="illustration tales:pyams_illustration(item);
+ target tales:relative_url(item);"
+ tal:condition="illustration">
+ <a href="${target}">
+ <tal:if define="image i18n:illustration.data;
+ alt i18n:illustration.alt_title;"
+ condition="image">
+ ${structure:tales:picture(image, lg_thumb=selection, lg_width=lg_width, md_thumb=selection,
+ md_width=md_width, sm_thumb=selection, sm_width=sm_width,
+ xs_thumb=selection, xs_width=xs_width, alt=alt)}
+ </tal:if>
+ </a>
+ </div>
+ </tal:loop>
+ </div>
+ <div class="clearfix"></div>
+</div>
--- a/src/pyams_default_theme/shared/view/portlet/templates/view-items-list.pt Mon Jan 07 10:10:44 2019 +0100
+++ b/src/pyams_default_theme/shared/view/portlet/templates/view-items-list.pt Mon Jan 07 10:11:18 2019 +0100
@@ -6,7 +6,12 @@
tal:define="start int(request.params.get('start', 0));
limit (start + renderer_settings.page_size) if renderer_settings.paginate else 999;
items settings.get_items(request, limit);
- global count 0;">
+ global count 0;
+ selection renderer_settings.thumbnails_selection;
+ lg_width 3 if selection == 'pano' else 1;
+ md_width 3 if selection == 'pano' else 1;
+ sm_width 4 if selection == 'pano' else 1;
+ xs_width 12 if selection == 'pano' else 2;">
<tal:loop repeat="item items">
<div tal:define="global count count +1;
target tales:relative_url(item);">
@@ -18,8 +23,9 @@
<tal:if define="image i18n:illustration.data;
alt i18n:illustration.alt_title;"
condition="image">
- ${structure:tales:picture(image, lg_thumb='pano', lg_width=3, md_thumb='pano', md_width=3, sm_thumb='pano',
- sm_width=4, xs_thumb='pano', xs_width=12, alt=alt, css_class='result_media')}
+ ${structure:tales:picture(image, lg_thumb=selection, lg_width=lg_width, md_thumb=selection,
+ md_width=md_width, sm_thumb=selection, sm_width=sm_width,
+ xs_thumb=selection, xs_width=xs_width, alt=alt, css_class='result_media')}
</tal:if>
</a>
</div>
@@ -28,8 +34,10 @@
<a href="${target}">
<h3>${i18n:item.title}</h3>
</a>
- <div class="breadcrumbs">${structure:tales:breadcrumbs(item)}</div>
- <div class="tags">${structure:tales:tags(item)}</div>
+ <div class="breadcrumbs"
+ tal:condition="renderer_settings.display_breadcrumbs">${structure:tales:breadcrumbs(item)}</div>
+ <div class="tags"
+ tal:condition="renderer_settings.display_tags">${structure:tales:tags(item)}</div>
<div class="header"
tal:define="header i18n:item.header">
${structure:tales:html(header)}