Skip to content
Snippets Groups Projects
Commit 163cccc1 authored by anonymous's avatar anonymous
Browse files

ODPSH-67: Modifies templates

parent 3f444031
No related branches found
No related tags found
No related merge requests found
import ckan.plugins as plugins import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit import ckan.plugins.toolkit as toolkit
from ckan.lib.plugins import DefaultTranslation
from ckan.common import OrderedDict
_ = toolkit._
def odsh_main_groups(): def odsh_main_groups():
'''Return a list of the groups to be shown on the start page.''' '''Return a list of the groups to be shown on the start page.'''
...@@ -11,10 +15,12 @@ def odsh_main_groups(): ...@@ -11,10 +15,12 @@ def odsh_main_groups():
return groups return groups
class OdshPlugin(plugins.SingletonPlugin): class OdshPlugin(plugins.SingletonPlugin, DefaultTranslation):
plugins.implements(plugins.IConfigurer) plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.ITemplateHelpers) plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.IRoutes, inherit=True) plugins.implements(plugins.IRoutes, inherit=True)
plugins.implements(plugins.ITranslation)
plugins.implements(plugins.IFacets)
# IConfigurer # IConfigurer
...@@ -32,3 +38,9 @@ class OdshPlugin(plugins.SingletonPlugin): ...@@ -32,3 +38,9 @@ class OdshPlugin(plugins.SingletonPlugin):
def before_map(self, map): def before_map(self, map):
map.connect('info_page', '/info_page', controller='ckanext.odsh.controller:OdshRouteController', action='info_page') map.connect('info_page', '/info_page', controller='ckanext.odsh.controller:OdshRouteController', action='info_page')
return map return map
def dataset_facets(self, facets_dict, package_type):
return OrderedDict({'groups': _('Groups')})
def group_facets(self, facets_dict, group_type, package_type):
return facets_dict
\ No newline at end of file
hier ist der footer
\ No newline at end of file
{% ckan_extends %} {% block header_wrapper %}
{% block header_account_container_content %} {% block header_account %}
hier war der login <header class="account-masthead">
<div class="container">
</div>
</header>
<header class="navbar navbar-static-top masthead">
{% block header_debug %}
{% if g.debug and not g.debug_supress_header %}
<div class="debug">Controller : {{ c.controller }}<br />Action : {{ c.action }}</div>
{% endif %}
{% endblock %} {% endblock %}
{% block header_site_navigation %} <div class="container">
<button data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar" type="button">
<span class="fa fa-bars"></span>
</button>
{# The .header-image class hides the main text and uses image replacement for the title #}
<div class='row'>
<div class='span4'>
<hgroup class="{{ g.header_class }} pull-left">
{% block header_logo %}
{% if g.site_logo %}
<a class="logo" href="{{ h.url_for('home') }}"><img src="{{ h.url_for_static_or_external(g.site_logo) }}"
alt="{{ g.site_title }}" title="{{ g.site_title }}" /></a>
{% else %}
<h1>
<a href="{{ h.url_for('home') }}">{{ g.site_title }}</a>
</h1>
{% if g.site_description %}<h2>{{ g.site_description }}</h2>{% endif %}
{% endif %}
{% endblock %}
</hgroup>
</div>
{% block header_site_search %}
<div class="span4">
<form class="section site-search simple-input" action="{% url_for controller='package', action='search' %}"
method="get">
<div class="field">
<label for="field-sitewide-search">{% block header_site_search_label %}{{ _('Search Datasets')
}}{%
endblock %}</label>
<input id="field-sitewide-search" type="text" name="q" placeholder="{{ _('Search') }}" />
<button class="btn-search" type="submit"><i class="fa fa-search"></i></button>
</div>
</form>
</div>
{% endblock %}
<div class='span4'>
{% snippet "snippets/language_selector.html" %}
</div>
</div>
<div class="nav-collapse collapse">
<nav class="section navigation"> <nav class="section navigation">
<ul class="nav nav-pills"> <ul class="nav nav-pills">
{% block header_site_navigation_tabs %} {% block header_site_navigation_tabs %}
{{ h.build_nav_main( {{ h.build_nav_main(
('home', _('Start')),
('search', _('Datasets')), ('search', _('Datasets')),
('organizations_index', _('Organizations')), ('organizations_index', _('Organizations')),
('group_index', _('Groups')),
('about', _('About')),
('info_page', _('Info')) ('info_page', _('Info'))
) }} ) }}
{% endblock %} {% endblock %}
</ul> </ul>
</nav> </nav>
{% endblock %} {% endblock %}
</div>
</div>
</header>
{% endblock %}
\ No newline at end of file
{% ckan_extends %}
{% block page_primary_action %}
{% endblock %}
{% block package_search_results_list %}
{{ h.snippet('snippets/package_list.html', packages=c.page.items) }}
{% endblock %}
##
## tools on left side, ie filter
{% block secondary_content %}
<div class="filters">
<div>
{% for facet in c.facet_titles %}
{{ h.snippet('snippets/facet_list.html', title=c.facet_titles[facet], name=facet) }}
{% endfor %}
</div>
<a class="close no-text hide-filters"><i class="fa fa-times-circle"></i><span class="text">close</span></a>
</div>
{% endblock %}
{% block package_search_results_api %}
{% endblock %}
\ No newline at end of file
{#
Displays a single of dataset.
package - A package 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/package_item.html', package=c.datasets[0] %}
#}
{% set truncate = truncate or 180 %}
{% set truncate_title = truncate_title or 80 %}
{% set title = package.title or package.name %}
{% set notes = h.markdown_extract(package.notes, extract_length=truncate) %}
{% block package_item %}
<li class="{{ item_class or "dataset-item" }}">
{% block content %}
<div class="dataset-content">
{% block heading %}
<h3 class="dataset-heading">
{% block heading_private %}
{% if package.private %}
<span class="dataset-private label label-inverse">
<i class="fa fa-lock"></i>
{{ _('Private') }}
</span>
{% endif %}
{% endblock %}
{% block heading_title %}
{{ h.link_to(h.truncate(title, truncate_title), h.url_for(controller='package', action='read', id=package.name)) }}
{% endblock %}
{% block heading_meta %}
{% if package.get('state', '').startswith('draft') %}
<span class="label label-info">{{ _('Draft') }}</span>
{% elif package.get('state', '').startswith('deleted') %}
<span class="label label-important">{{ _('Deleted') }}</span>
{% endif %}
{{ h.popular('recent views', package.tracking_summary.recent, min=10) if package.tracking_summary }}
{% endblock %}
</h3>
{% endblock %}
{% block banner %}
{% if banner %}
<span class="banner">{{ _('Popular') }}</span>
{% endif %}
{% endblock %}
{% block notes %}
{% if notes %}
<div>{{ notes|urlize }}</div>
{% else %}
<p class="empty">{{ _("This dataset has no description") }}</p>
{% endif %}
{% endblock %}
</div>
{% block resources %}
{% if package.resources and not hide_resources %}
{% block resources_outer %}
<ul class="dataset-resources unstyled">
{% block resources_inner %}
{% for resource in h.dict_list_reduce(package.resources, 'format') %}
<li>
<a href="{{ h.url_for(controller='package', action='read', id=package.name) }}" class="label" data-format="{{ resource.lower() }}">{{ resource }}</a>
</li>
{% endfor %}
{% endblock %}
</ul>
{% endblock %}
{% endif %}
{% endblock %}
{% block package_openness %}
<div class="module module-narrow module-shallow context-info">
</div>
{% endblock %}
{% endblock %}
</li>
{% endblock %}
{#
Displays a list of datasets.
packages - A list of packages 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)
truncatle_title - The length to truncate the title to (default: 80).
Example:
{% snippet 'snippets/package_list.html', packages=c.datasets %}
#}
{% block package_list %}
{% if packages %}
<ul class="{{ list_class or 'dataset-list unstyled' }}">
{% block package_list_inner %}
{% for package in packages %}
{% snippet 'snippets/package_item.html', package=package, item_class=item_class, hide_resources=hide_resources, banner=banner, truncate=truncate, truncate_title=truncate_title %}
{% endfor %}
{% endblock %}
</ul>
{% endif %}
{% endblock %}
{% import 'macros/form.html' as form %}
{% set placeholder = placeholder if placeholder else _('Search datasets...') %}
{% set sorting = sorting if sorting else [(_('Name Ascending'), 'name asc'), (_('Name Descending'), 'name desc')] %}
{% set search_class = search_class if search_class else 'search-giant' %}
{% set no_bottom_border = no_bottom_border if no_bottom_border else false %}
{% set form_id = form_id if form_id else false %}
<form {% if form_id %}id="{{ form_id }}" {% endif %}class="search-form{% if no_bottom_border %} no-bottom-border{% endif %}"
method="get" data-module="select-switch">
{% block search_input %}
{% endblock %}
{% block search_search_fields %}
{% if fields -%}
<span>{{ form.hidden_from_list(fields=fields) }}</span>
{%- endif %}
{% endblock %}
{% block search_sortby %}
{% if sorting %}
<div class="form-select control-group control-order-by">
<label for="field-order-by">{{ _('Order by') }}</label>
<select id="field-order-by" name="sort">
{% for label, value in sorting %}
{% if label and value %}
<option value="{{ value }}" {% if sorting_selected==value %} selected="selected" {% endif %}>{{ label }}</option>
{% endif %}
{% endfor %}
</select>
{% block search_sortby_button %}
<button class="btn js-hide" type="submit">{{ _('Go') }}</button>
{% endblock %}
</div>
{% endif %}
{% endblock %}
{% block search_title %}
{% if not error %}
<h2>{% snippet 'snippets/search_result_text.html', query=query, count=count, type=type %}</h2>
{% else %}
<h2>Error</h2>
{% endif %}
{% endblock %}
{% block search_facets %}
{% if facets %}
<p class="filter-list">
{% for field in facets.fields %}
{% set search_facets_items = facets.search.get(field)['items'] %}
<span class="facet">{{ facets.titles.get(field) }}:</span>
{% for value in facets.fields[field] %}
<span class="filtered pill">
{%- if facets.translated_fields and facets.translated_fields.has_key((field,value)) -%}
{{ facets.translated_fields[(field,value)] }}
{%- else -%}
{{ h.list_dict_filter(search_facets_items, 'name', 'display_name', value) }}
{%- endif %}
<a href="{{ facets.remove_field(field, value) }}" class="remove" title="{{ _('Remove') }}"><i class="fa fa-times"></i></a>
</span>
{% endfor %}
{% endfor %}
</p>
<a class="show-filters btn">{{ _('Filter Results') }}</a>
{% endif %}
{% endblock %}
</form>
{% if show_empty and count == 0 and not error %}
{% trans %}
<p class="extra">Please try another search.</p>
{% endtrans %}
{% endif %}
{% if error %}
{% trans %}
<p id="search-error"><strong>There was an error while searching.</strong> Please try again.</p>
{% endtrans %}
{% endif %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment