-
Notifications
You must be signed in to change notification settings - Fork 2k
/
resource_view.html
79 lines (78 loc) · 3.94 KB
/
resource_view.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{% import 'macros/form.html' as form %}
{% block resource_view %}
<div id="view-{{ resource_view['id'] }}" class="resource-view" data-id="{{ resource_view['id'] }}" data-title="{{ resource_view['title'] }}" data-description="{{ resource_view['descripion'] }}">
<a class="btn pull-right"
href="#embed-{{ resource_view['id'] }}"
data-module="resource-view-embed"
data-module-id="{{ resource_view['id'] }}"
data-module-url="{{ h.url('resource_view', id=package['name'], resource_id=resource['id'], view_id=resource_view['id'], qualified=True) }}">
<i class="icon-code"></i>
{{ _("Embed") }}
</a>
<p class="desc">{{ resource_view['description'] }}</p>
<div class="m-top ckanext-datapreview">
{% if not to_preview and h.resource_view_is_filterable(resource_view) %}
{% snippet 'package/snippets/resource_view_filters.html', resource=resource %}
{% endif %}
{% if not h.resource_view_is_iframed(resource_view) %}
{{ h.rendered_resource_view(resource_view, resource, package) }}
{% else %}
<div class="data-viewer-error js-hide">
<p class="text-error">
<i class="icon-info-sign"></i>
{{ _('This resource view is not available at the moment.') }}
<a href="#" data-toggle="collapse" data-target="#data-view-error">
{{ _('Click here for more information.') }}
</a>
</p>
<p id="data-view-error" class="collapse"></p>
<p>
<a href="{{ resource.url }}" class="btn btn-large resource-url-analytics" target="_blank">
<i class="icon-large icon-download"></i>
{{ _('Download resource') }}
</a>
</p>
</div>
{% if not to_preview %}
{% set current_filters = request.str_GET.get('filters') %}
{% if current_filters %}
{% set src = h.url(qualified=true, controller='package',
action='resource_view', id=package['name'],
resource_id=resource['id'],
view_id=resource_view['id'],
filters=current_filters) %}
{% else %}
{% set src = h.url(qualified=true, controller='package',
action='resource_view', id=package['name'],
resource_id=resource['id'],
view_id=resource_view['id']) %}
{% endif %}
{% else %}
{# When previewing we need to stick the whole resource_view as a param as there is no other way to pass to information on to the iframe #}
{% set src = h.url(qualified=true, controller='package', action='resource_view', id=package['name'], resource_id=resource['id']) + '?' + h.urlencode({'resource_view': h.dump_json(resource_view)}) %}
{% endif %}
<iframe src="{{ src }}" frameborder="0" width="100%" data-module="data-viewer">
<p>{{ _('Your browser does not support iframes.') }}</p>
</iframe>
{% endif %}
</div>
<div id="embed-{{ resource_view['id'] }}" class="modal resource-view-embed hide">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h3>{{ _("Embed resource view") }}</h3>
</div>
<div class="modal-body">
<p class="embed-content">{{ _("You can copy and paste the embed code into a CMS or blog software that supports raw HTML") }}</p>
<div class="row-fluid">
<div class="span6">
{{ form.input("width", label=_("Width"), value=700, classes=["control-full"]) }}
</div>
<div class="span6">
{{ form.input("height", label=_("Height"), value=400, classes=["control-full"]) }}
</div>
</div>
{{ form.textarea("code", label=_("Code"), value="", classes=["pre"], rows=3) }}
</div>
</div>
</div>
{% endblock %}