--- a/src/pyams_default_theme/features/search/portlet/__init__.py Fri Dec 28 10:45:49 2018 +0100
+++ b/src/pyams_default_theme/features/search/portlet/__init__.py Fri Dec 28 10:47:11 2018 +0100
@@ -18,9 +18,10 @@
from zope.location import ILocation
from zope.schema.fieldproperty import FieldProperty
+from pyams_content.features.search import ISearchFolder
from pyams_content.features.search.portlet import ISearchResultsPortletSettings
from pyams_content.shared.common import IWfSharedContent
-from pyams_default_theme import _
+from pyams_content.shared.common.portlet.interfaces import ISharedContentHeadViewletManager
from pyams_default_theme.features.search.portlet.interfaces import ISearchResultRenderer, \
ISearchResultsPortletDefaultRendererSettings
from pyams_default_theme.interfaces import ISearchResultsView
@@ -32,8 +33,25 @@
from pyams_utils.adapter import NullAdapter, adapter_config
from pyams_utils.factory import factory_config
from pyams_utils.url import canonical_url, relative_url
-from pyams_viewlet.viewlet import ViewContentProvider
+from pyams_viewlet.viewlet import ViewContentProvider, Viewlet, viewlet_config
+
+from pyams_default_theme import _
+
+
+#
+# Search folder custom head specificities renderer
+#
+@viewlet_config(name='search-folder-head', context=ISearchFolder, layer=IPyAMSUserLayer, view=Interface,
+ manager=ISharedContentHeadViewletManager, weight=1)
+@template_config(template='templates/folder-head-specificities.pt', layer=IPyAMSUserLayer)
+class SearchFolderHeadViewlet(Viewlet):
+ """Search folder head specificities viewlet"""
+
+
+#
+# Search results portlet renderers
+#
@factory_config(provided=ISearchResultsPortletDefaultRendererSettings)
class SearchResultsPortletDefaultRendererSettings(Persistent, Contained):
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/features/search/portlet/templates/folder-head-specificities.pt Fri Dec 28 10:47:11 2018 +0100
@@ -0,0 +1,19 @@
+<section class="wrapper-form" i18n:domain="pyams_default_theme">
+ <div class="row">
+ <form class="search-form col-md-offset-1 col-md-10"
+ action="${tales:absolute_url(context)}">
+ <div class="form-group">
+ <input type="text" class="form-control" name="user_search"
+ placeholder="Your search" title="Search" i18n:attributes="placeholder; title"
+ value="${request.params.get('user_search')}" />
+ <input type="hidden" name="tag" value="${request.params.get('tag')}" />
+ <input type="hidden" name="order_by" value="${request.params.get('order_by') or context.order_by}" />
+ <input type="hidden" name="start" value="${request.params.get('start', 0)}" />
+ <input type="hidden" name="length" value="${request.params.get('length', 10)}" />
+ <button type="submit" class="btn btn-default" role="button">
+ <span class="visually-hidden" i18n:translate="">Refine search</span>
+ </button>
+ </div>
+ </form>
+ </div>
+</section>
--- a/src/pyams_default_theme/features/search/portlet/templates/search-results.pt Fri Dec 28 10:45:49 2018 +0100
+++ b/src/pyams_default_theme/features/search/portlet/templates/search-results.pt Fri Dec 28 10:47:11 2018 +0100
@@ -2,24 +2,90 @@
renderer_settings view.renderer_settings;"
i18n:domain="pyams_default_theme">
<h2>${i18n:settings.title}</h2>
+ <form action="${tales:absolute_url(context)}"
+ id="search-results">
+ <input type="hidden" name="user_search" value="${request.params.get('user_search')}" />
+ <input type="hidden" name="tag" value="${request.params.get('tag')}" />
+ <input type="hidden" name="order_by" value="${request.params.get('order_by') or context.order_by}" />
+ <input type="hidden" name="start" value="${request.params.get('start', 0)}" />
+ <input type="hidden" name="length" value="${request.params.get('length', 10)}" />
+ </form>
<div class="search-results"
tal:define="(items, count) settings.get_items(request)">
<header>
- <tal:if condition="renderer_settings.display_results_count">
- <div>
- <tal:if condition="count" i18n:translate="">
- <i18n:var name="count">${count}</i18n:var> result(s) found
- </tal:if>
- <tal:if condition="not:count" i18n:translate="">
- No result found!
- </tal:if>
- </div>
- </tal:if>
- <hr />
+ <div tal:condition="renderer_settings.display_results_count">
+ <tal:if condition="count" i18n:translate="">
+ <i18n:var name="count">${count}</i18n:var> result(s) found
+ </tal:if>
+ <tal:if condition="not:count" i18n:translate="">
+ No result found!
+ </tal:if>
+ </div>
+ <div tal:condition="count and renderer_settings.allow_sorting">
+ <select class="form-control"
+ data-ams-change-handler="PyAMS_default.search.updateSort"
+ tal:define="order_by request.params.get('order_by') or context.order_by">
+ <option value="relevance"
+ selected="${'selected' if order_by == 'relevance' else None}"
+ i18n:translate="">Sort by relevance</option>
+ <option value="publication_date"
+ selected="${'selected' if order_by == 'publication_date' else None}"
+ i18n:translate="">Sort by publication date</option>
+ </select>
+ </div>
+ <div tal:condition="count and renderer_settings.allow_pagination">
+ <span i18n:translate="">Page length:</span>
+ <select class="form-control"
+ data-ams-change-handler="PyAMS_default.search.updatePageLength"
+ tal:define="length request.params.get('length', 10)">
+ <option tal:repeat="value ('10', '20', '50')"
+ value="${value}"
+ selected="${'selected' if value == length else None}"
+ i18n:translate="">${value}</option>
+ </select>
+ </div>
</header>
+ <hr />
<tal:loop repeat="item items">
${structure:view.render_item(item)}
<div class="clearfix"></div>
</tal:loop>
+ <div class="col-md-12 text-center">
+ <nav role="navigation"
+ aria-label="Pagination" i18n:attributes="aria-label">
+ <ol class="pagination"
+ tal:define="(current, total) settings.get_pages(request, count)"
+ data-ams-current-page="${current}">
+ <tal:if condition="renderer_settings.allow_pagination and (total > 1)">
+ <tal:if condition="current > 1">
+ <li class="prev">
+ <a href="#" i18n:translate=""
+ data-ams-click-handler="PyAMS_default.search.previousPage">Previous page</a>
+ </li>
+ </tal:if>
+ <li tal:repeat="page range(current)">
+ <a tal:condition="current != page+1"
+ href="#"
+ data-ams-click-handler="PyAMS_default.search.gotoPage">${page+1}</a>
+ <span tal:condition="current == page+1"
+ class="current">${page+1}</span>
+ </li>
+ <tal:if condition="current < total">
+ <li tal:condition="current < total-1">
+ <a class="disabled">…</a>
+ </li>
+ <li>
+ <a href="#"
+ data-ams-click-handler="PyAMS_default.search.gotoPage">${total}</a>
+ </li>
+ <li class="next">
+ <a href="#" i18n:translate=""
+ data-ams-click-handler="PyAMS_default.search.nextPage">Next page</a>
+ </li>
+ </tal:if>
+ </tal:if>
+ </ol>
+ </nav>
+ </div>
</div>
</div>