diff --git a/ckanext/harvest/plugin.py b/ckanext/harvest/plugin.py index 5cdf8d2..e3ba231 100644 --- a/ckanext/harvest/plugin.py +++ b/ckanext/harvest/plugin.py @@ -52,6 +52,9 @@ class Harvest(p.SingletonPlugin, DefaultDatasetForm): def package_form(self): return 'source/new_source_form.html' + def search_template(self): + return 'source/search.html' + def new_template(self): return 'source/new.html' diff --git a/ckanext/harvest/templates_new/snippets/source_item.html b/ckanext/harvest/templates_new/snippets/source_item.html new file mode 100644 index 0000000..c9ef735 --- /dev/null +++ b/ckanext/harvest/templates_new/snippets/source_item.html @@ -0,0 +1,39 @@ +{# +Displays a single harvest source result. + +source - A source to display. +item_class - The class name to use on the list item. +hide_resources - If true hides the resources (default: false). +banner - If true displays a popular banner (default: false). +truncate - The length to trucate the description to (default: 180) +truncate_title - The length to truncate the title to (default: 80). + +Example: + + {% snippet 'snippets/source_item.html', source=c.sources[0] %} + +#} +{% set truncate = truncate or 180 %} +{% set truncate_title = truncate_title or 80 %} +{% set title = source.title or source.name %} + +
  • +
    +

    + {{ h.link_to(h.truncate(title, truncate_title), h.url_for('harvest_source_read', id=source.name)) }} + {% if source.get(state, '').startswith('draft') %} + {{ _('Draft') }} + {% elif source.get(state, '').startswith('deleted') %} + {{ _('Deleted') }} + {% endif %} + {{ h.popular('recent views', source.tracking_summary.recent, min=10) if source.tracking_summary }} +

    + {% if banner %} + + {% endif %} + + +
    {{ source.url }}
    + +
    +
  • diff --git a/ckanext/harvest/templates_new/snippets/source_list.html b/ckanext/harvest/templates_new/snippets/source_list.html new file mode 100644 index 0000000..ce04625 --- /dev/null +++ b/ckanext/harvest/templates_new/snippets/source_list.html @@ -0,0 +1,23 @@ +{# +Displays a list of harvest sources. + +sources - A list of harvest sources to display. +list_class - The class name for the list item. +item_class - The class name to use on each item. +hide_resources - If true hides the resources (default: false). +banner - If true displays a popular banner (default: false). +truncate - The length to trucate the description to (default: 180) +truncate_title - The length to truncate the title to (default: 80). + +Example: + + {% snippet 'snippets/sources_list.html', sources=c.sources %} + +#} +{% if sources %} + +{% endif %} diff --git a/ckanext/harvest/templates_new/source/search.html b/ckanext/harvest/templates_new/source/search.html new file mode 100644 index 0000000..0a8093f --- /dev/null +++ b/ckanext/harvest/templates_new/source/search.html @@ -0,0 +1,79 @@ +{% extends "page.html" %} + +{% block subtitle %}{{ _("Harvest sources") }}{% endblock %} + +{% block breadcrumb_content %} +
  • {{ h.nav_named_link(_('Harvest Sources'), '{0}_search'.format(c.dataset_type)) }}
  • +{% endblock %} + +{% block primary_content %} +
    +
    + +
    + + {%- if request.params and c.page.item_count -%} + {{ c.page.item_count }} harvest sources{{ _(" found for \"{query}\"").format(query=c.q) if c.q }} + {%- elif request.params and c.page.item_count == 0 -%} + {{ _('Sorry no harvest sources found for "{query}"').format(query=c.q) }} + {%- else -%} + {{ _('All harvest sources') }} + {%- endif -%} + +
    + {% for field in c.fields_grouped %} + {{ c.facet_titles.get(field) }}: + {% for value in c.fields_grouped[field] %} + + {%- if c.translated_fields and c.translated_fields.has_key((field,value)) -%} + {{ c.translated_fields[(field,value)] }} + {%- else -%} + {{ value }} + {%- endif %} + + + {% endfor %} + {% endfor %} +
    + {% if request.params and c.page.item_count == 0 %} +

    Try another search term, + browse the sources below or {{ _('add a new one') }}. +

    + {% endif %} +
    + + {% if c.query_error %} + {% trans %} +

    There was an error while searching. Please try again.

    + {% endtrans %} + {% endif %} + + {{ h.snippet('snippets/source_list.html', sources=c.page.items) }} + +
    + + {{ c.page.pager(q=c.q) }} +
    + +{% endblock %} + +{% block secondary_content %} + {{ h.snippet('snippets/facet_list.html', title='Frequency', name='frequency', alternative_url=h.url_for('{0}_search'.format(c.dataset_type))) }} + {{ h.snippet('snippets/facet_list.html', title='Type', name='source_type', alternative_url=h.url_for('{0}_search'.format(c.dataset_type))) }} +{% endblock %}