# HG changeset patch # User Thierry Florac # Date 1546852278 -3600 # Node ID 5ac6b44152a10100e6148757898641772a94b6f7 # Parent 3e246201a2d00fe48c5113b1e780fb77c3727645 Added view items portlet horizontal renderer diff -r 3e246201a2d0 -r 5ac6b44152a1 src/pyams_default_theme/shared/view/portlet/__init__.py --- 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 diff -r 3e246201a2d0 -r 5ac6b44152a1 src/pyams_default_theme/shared/view/portlet/interfaces.py --- 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') diff -r 3e246201a2d0 -r 5ac6b44152a1 src/pyams_default_theme/shared/view/portlet/templates/view-items-horiz-list.pt --- /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 @@ +
+

${i18n:settings.title}

+
+ + + +
+
+
diff -r 3e246201a2d0 -r 5ac6b44152a1 src/pyams_default_theme/shared/view/portlet/templates/view-items-list.pt --- 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;">
@@ -18,8 +23,9 @@ - ${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')}
@@ -28,8 +34,10 @@

${i18n:item.title}

- -
${structure:tales:tags(item)}
+ +
${structure:tales:tags(item)}
${structure:tales:html(header)}