Skip to content

Commit

Permalink
[#472] Unify the dataset searches to give consistent results text
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/templates/package/snippets/search_form.html

    trivial
  • Loading branch information
tobes committed Mar 6, 2013
1 parent 9041229 commit b99ea5b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
8 changes: 1 addition & 7 deletions ckan/templates/package/search.html
Expand Up @@ -34,13 +34,7 @@
</form>
<div class="results">
<strong>
{%- if request.params and c.page.item_count -%}
{{ c.page.item_count }} datasets{{ _(" found for \"{query}\"").format(query=c.q) if c.q }}
{%- elif request.params and c.page.item_count == 0 -%}
{{ _('Sorry no datasets found for "{query}"').format(query=c.q) }}
{%- else -%}
{{ _('All datasets') }}
{%- endif -%}
{% snippet 'snippets/search_result_text.html', query=c.q, count=c.page.item_count, type='dataset' %}
</strong>
<div class="filter-list">
{% for field in c.fields_grouped %}
Expand Down
7 changes: 1 addition & 6 deletions ckan/templates/package/snippets/search_form.html
Expand Up @@ -15,12 +15,7 @@
</form>
<div class="results">
<strong>
{% if c.q %}
{{ _('{number} datasets found for "{query}"').format(query=c.q, number=c.page.item_count) }}
{% else %}
{{ _('{number} datasets found').format(number=c.page.item_count) }}
{% endif %}

{% snippet 'snippets/search_result_text.html', query=c.q, count=c.page.item_count, type='dataset' %}
</strong>
<div class="filter-list">
{% for field in c.fields_grouped %}
Expand Down
33 changes: 33 additions & 0 deletions ckan/templates/snippets/search_result_text.html
@@ -0,0 +1,33 @@
{#

Displays a test for results of a search.

query - The text that was searched for
count - The number of results for the search
type - Search result type (dataset, group, organization)

Example:

{% snippet 'snippets/search_result_text.html', query=query, count=count, type='dataset' %}

#}
{% if type == 'dataset' %}
{% set text_query = ungettext('{number} dataset found for "{query}"', '{number} datasets found for "{query}"', count) %}
{% set text_query_none = _('Sorry no datasets found for "{query}"') %}
{% set text_no_query = ungettext('{number} dataset found', '{number} datasets found', count) %}
{% set text_no_query_none = _('Sorry no datasets found') %}
{%- endif -%}

{% if query %}
{%- if count -%}
{{ text_query.format(number=count, query=query) }}
{%- else -%}
{{ text_query_none.format(query=query) }}
{%- endif -%}
{%- else -%}
{%- if count -%}
{{ text_no_query.format(number=count) }}
{%- else -%}
{{ text_no_query_none }}
{%- endif -%}
{%- endif -%}

0 comments on commit b99ea5b

Please sign in to comment.