Skip to content

Commit

Permalink
[#2375] Add hooks to the resource_read template
Browse files Browse the repository at this point in the history
  • Loading branch information
aron committed Aug 14, 2012
1 parent 9ee4b30 commit 0ac6b3d
Showing 1 changed file with 62 additions and 75 deletions.
137 changes: 62 additions & 75 deletions ckan/templates/package/resource_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,92 +41,79 @@
{{ self.flash() }}
{{ self.toolbar() }}

<section class="module">
<div class="module-content">
{% block resource_read_title %}<h1 class="page-heading">{{ h.resource_display_name(res) | truncate(50) }}</h1>{% endblock %}
<div class="prose notes" property="rdfs:label">
{% if res.description %}
{{ h.render_markdown(res.description) }}
{% else %}
<p class="empty">{{ _('There is no description for this resource') }}</p>
{% endif %}
{% if not res.description and c.package.notes %}
<h3>{{ _('From the dataset abstract') }}</h3>
<blockquote>{{ h.markdown_extract(c.package.get('notes')) }}</blockquote>
<p>{% trans dataset=c.package.title, url=h.url_for(controller='package', action='read', id=c.package['name']) %}Source: <a href="{{ url }}">{{ dataset }}</a>{% endtrans %}
{% endif %}
{% block resource %}
<section class="module">
<div class="module-content">
{% block resource_content %}
{% block resource_read_title %}<h1 class="page-heading">{{ h.resource_display_name(res) | truncate(50) }}</h1>{% endblock %}
<div class="prose notes" property="rdfs:label">
{% if res.description %}
{{ h.render_markdown(res.description) }}
{% else %}
<p class="empty">{{ _('There is no description for this resource') }}</p>
{% endif %}
{% if not res.description and c.package.notes %}
<h3>{{ _('From the dataset abstract') }}</h3>
<blockquote>{{ h.markdown_extract(c.package.get('notes')) }}</blockquote>
<p>{% trans dataset=c.package.title, url=h.url_for(controller='package', action='read', id=c.package['name']) %}Source: <a href="{{ url }}">{{ dataset }}</a>{% endtrans %}
{% endif %}
{% endblock %}
</div>
</div>
</div>
<div id="ckanext-datapreview" class="module-content"></div>
</section>
{% block data_preview %}
<div id="ckanext-datapreview" class="module-content"></div>
{% endblock %}
</section>
{% endblock %}

{{ self.primary() }}
{{ self.secondary() }}
{% endblock %}

{% block primary_content %}
{% if res %}
<section class="module">
<div class="module-content">
<h2>Additional Information</h2>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Field</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for key, value in h.format_resource_items(res.items()) %}
<tr><th>{{ key }}</th><td>{{ value }}</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endif %}
{% block resource_additional_information %}
{% if res %}
<section class="module">
<div class="module-content">
<h2>Additional Information</h2>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Field</th>
<th>Value</th>
</tr>
</thead>
<tbody>
{% for key, value in h.format_resource_items(res.items()) %}
<tr><th>{{ key }}</th><td>{{ value }}</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
{% endif %}
{% endblock %}
{% endblock %}

{#
{% if config.get('ckan.datastore.enabled', false) %}
<section class="module">
{{ data_api_help(c.datastore_api) }}
{% block secondary_content %}
{% block resource_information %}
<section class="module module-narrow">
<h2 class="module-heading"><i class="icon-medium icon-info-sign"></i> Resource Information</h2>
<ul class="simple-list">
<li><i class="ckan-icon ckan-icon-calendar"></i> Last Updated: {{ h.render_datetime(res.last_modified) or _("unknown") }}</li>
<li><i class="ckan-icon ckan-icon-file"></i> Format: {{ res.mimetype_inner or res.mimetype or _("unknown") }}</li>
<li><i class="ckan-icon ckan-icon-lock"></i> {% snippet "snippets/license.html", pkg_dict=pkg, text_only=True %}</li>
</ul>
</section>
{% endif %}
#}
{% endblock %}

{% endblock %}
{% block resources_list %}
{% snippet "package/snippets/resources.html", pkg=pkg, active=res.id %}
{% endblock %}

{% block secondary_content %}
<section class="module module-narrow">
<h2 class="module-heading"><i class="icon-medium icon-info-sign"></i> Resource Information</h2>
<ul class="simple-list">
<li><i class="ckan-icon ckan-icon-calendar"></i> Last Updated: {{ h.render_datetime(res.last_modified) or _("unknown") }}</li>
<li><i class="ckan-icon ckan-icon-file"></i> Format: {{ res.mimetype_inner or res.mimetype or _("unknown") }}</li>
<li><i class="ckan-icon ckan-icon-lock"></i> {% snippet "snippets/license.html", pkg_dict=pkg, text_only=True %}</li>
</ul>
</section>

{% snippet "package/snippets/resources.html", pkg=pkg, active=res.id %}

{% snippet "snippets/social.html" %}

{# TODO: Embed this with javascript
<section class="module">
<div class="resource-preview module-content">
<div class="preview-header" style="display: none;">
<h3>Preview</h3>
{% if c.pkg.is_private %}
<span title="Cannot embed as resource is private." class="btn disabled">Embed</span>
{% else %}
<a class="btn btn-primary" data-toggle="modal" href=".modal-data-viewer-embed-dialog">Embed</a>
{% endif %}
</div>
<div id="ckanext-datapreview module-content">
{% snippet 'snippets/datapreview_embed_dialog.html' %}
</div>
</div>
</section>
#}
{% block resource_license %}
{% snippet "snippets/social.html" %}
{% endblock %}
{% endblock %}

{% block styles %}
Expand Down

0 comments on commit 0ac6b3d

Please sign in to comment.