# HG changeset patch # User Thierry Florac # Date 1543305074 -3600 # Node ID ab68305914ef00d7a7df0d22499f0064e4dfaf10 # Parent 20b80d2c592db8b872cb8c235ce05a6d5dc5c350 Added search results portlet diff -r 20b80d2c592d -r ab68305914ef src/pyams_default_theme/features/search/__init__.py --- a/src/pyams_default_theme/features/search/__init__.py Mon Nov 26 11:05:48 2018 +0100 +++ b/src/pyams_default_theme/features/search/__init__.py Tue Nov 27 08:51:14 2018 +0100 @@ -13,10 +13,12 @@ __docformat__ = 'restructuredtext' from pyams_content.features.search.interfaces import ISearchFolder +from pyams_content.shared.site import ISiteElementNavigation from pyams_default_theme.interfaces import IContentSummaryInfo -from pyams_content.shared.site import ISiteElementNavigation from pyams_i18n.interfaces import II18n +from pyams_skin.interfaces.viewlet import IBreadcrumbItem from pyams_skin.layer import IPyAMSUserLayer +from pyams_skin.viewlet.breadcrumb import BreadcrumbItem from pyams_utils.adapter import ContextRequestAdapter, adapter_config from pyams_utils.interfaces.url import IRelativeURL from pyams_utils.url import absolute_url @@ -44,6 +46,17 @@ return IWorkflowPublicationInfo(self.context).is_visible(self.request) +@adapter_config(context=(ISearchFolder, IPyAMSUserLayer), provides=IBreadcrumbItem) +class SearchFolderBreadcumbAdapter(BreadcrumbItem): + """Search folder breadcrumb adapter""" + + @property + def label(self): + return II18n(self.context).query_attribute('short_name', request=self.request) + + url = None + + @adapter_config(context=(ISearchFolder, IPyAMSUserLayer), provides=IContentSummaryInfo) class SearchFolderSummaryAdapter(ContextRequestAdapter): """Search folder summary adapter""" diff -r 20b80d2c592d -r ab68305914ef src/pyams_default_theme/features/search/portlet/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/search/portlet/__init__.py Tue Nov 27 08:51:14 2018 +0100 @@ -0,0 +1,59 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# 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 persistent import Persistent +from zope.container.contained import Contained +from zope.interface import Interface, implementer +from zope.location import ILocation +from zope.schema.fieldproperty import FieldProperty + +from pyams_content.features.search.portlet import ISearchResultsPortletSettings +from pyams_default_theme.features.search.portlet.interfaces import ISearchResultsPortletDefaultRendererSettings +from pyams_default_theme.interfaces import ISearchResultsView +from pyams_portal.interfaces import IPortalContext, IPortletRenderer +from pyams_portal.portlet import PortletRenderer +from pyams_skin.interfaces.viewlet import IBreadcrumbs +from pyams_skin.layer import IPyAMSLayer, IPyAMSUserLayer +from pyams_template.template import template_config +from pyams_utils.adapter import adapter_config, NullAdapter +from pyams_utils.factory import factory_config + +from pyams_default_theme import _ + + +@implementer(ISearchResultsPortletDefaultRendererSettings) +@factory_config(provided=ISearchResultsPortletDefaultRendererSettings) +class SearchResultsPortletDefaultRendererSettings(Persistent, Contained): + """Search results portlet default renderer settings""" + + display_results_count = FieldProperty(ISearchResultsPortletDefaultRendererSettings['display_results_count']) + allow_sorting = FieldProperty(ISearchResultsPortletDefaultRendererSettings['allow_sorting']) + allow_pagination = FieldProperty(ISearchResultsPortletDefaultRendererSettings['allow_pagination']) + + +@adapter_config(context=(IPortalContext, IPyAMSLayer, Interface, ISearchResultsPortletSettings), + provides=IPortletRenderer) +@template_config(template='templates/search-results.pt', layer=IPyAMSLayer) +@implementer(ISearchResultsView) +class SearchResultsPortletDefaultRenderer(PortletRenderer): + """Search results portlet default renderer""" + + label = _("Default search results") + + settings_interface = ISearchResultsPortletDefaultRendererSettings + + +@adapter_config(context=(ILocation, IPyAMSUserLayer, ISearchResultsView), provides=IBreadcrumbs) +class BreadcrumbsAdapter(NullAdapter): + """Disable breadcrumbs in search results view""" diff -r 20b80d2c592d -r ab68305914ef src/pyams_default_theme/features/search/portlet/interfaces.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/search/portlet/interfaces.py Tue Nov 27 08:51:14 2018 +0100 @@ -0,0 +1,37 @@ +# +# Copyright (c) 2008-2018 Thierry Florac +# 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 zope.schema import Bool + +from pyams_default_theme import _ + + +class ISearchResultsPortletDefaultRendererSettings(Interface): + """Search results portlet default renderer settings interface""" + + display_results_count = Bool(title=_("Display results count?"), + description=_("If 'no', results count will not be displayed"), + required=True, + default=True) + + allow_sorting = Bool(title=_("Allow results sorting?"), + description=_("If 'no', results will not be sortable"), + required=True, + default=True) + + allow_pagination = Bool(title=_("Allow pagination?"), + description=_("If 'no', results will not be paginated"), + required=True, + default=True) diff -r 20b80d2c592d -r ab68305914ef src/pyams_default_theme/features/search/portlet/templates/search-results.pt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_default_theme/features/search/portlet/templates/search-results.pt Tue Nov 27 08:51:14 2018 +0100 @@ -0,0 +1,31 @@ +
+

${i18n:settings.title}

+
+ + + +
+

${i18n:item.title}

+ +
${structure:tales:tags(item)}
+
+ ${structure:tales:html(header)} +
+
+
+
+
+
+
\ No newline at end of file