Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 30 additions & 39 deletions pygeoapi/templates/_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<meta property="og:description" content="{{ config['metadata']['identification']['description'] }}" />

<meta property="og:type" content="website" />
{% for link in data['links'] %}
{% for link in (links or data['links']) %}
{% if (link['rel']=="self" and link['type']=="text/html") %}
<link rel="canonical" href="{{ link['href'].split('?')[0] }}?f=html" />
{% elif (link['rel']!="canonical") %}
Expand Down Expand Up @@ -80,25 +80,11 @@
<a href="{{ config['server']['url'] }}">{% trans %}Home{% endtrans %}</a>
{% endblock %}
<span style="float: inline-end">
{% set links_found = namespace(json='', jsonld='') %}

{% for link in data['links'] %}
{% if link['rel'] == 'alternate' and link['type'] and link['type'] in ['application/json', 'application/geo+json', 'application/prs.coverage+json'] %}
{% set links_found.json = link.href | string | safe %}
<a href="{{ link['href'] }}">{% trans %}json{% endtrans %}</a>
{% elif link['rel'] == 'alternate' and link['type'] and link['type'] == 'application/ld+json' %}
{% set links_found.jsonld = link.href | string | safe %}
<a href="{{ link['href'] }}">{% trans %}jsonld{% endtrans %}</a>
{% endif %}
{% endfor %}

{% if links_found.json == '' %}
<a href="?f=json">{% trans %}json{% endtrans %}</a>
{% endif %}
{% if links_found.jsonld == '' %}
<a href="?f=jsonld">{% trans %}jsonld{% endtrans %}</a>
{% endif %}

{% for link in (links or data['links']) %}
{%- if link.get('rel') == 'alternate' -%}
<a href="{{link.get('href')}}">{{ link.get('type').split('/')[-1] }}</a>
{%- endif-%}
{% endfor %}
</span>
</div>
</div>
Expand All @@ -124,26 +110,31 @@
</footer>
{% block extrafoot %}
{% endblock %}
<script>

{% for link in (links or data['links']) %}
{%- if (link['rel']=="alternate" and link['type']=="application/ld+json") -%}
<script>
// Requests and embeds JSON-LD representation of current page
var xhr = new XMLHttpRequest();
{% if links_found.jsonld == '' -%}
var path = window.location.protocol + "//" + window.location.host + window.location.pathname + "?f=jsonld";
{%- else -%}
var path = "{{ links_found.jsonld }}";
fetch("{{ link.get('href') }}")
.then(response => {
if (!response.ok) {
console.log(`HTTP ${response.status}`);
} else {
return response.text();
}
})
.then(data => {
var head = document.getElementsByTagName('head')[0];
var jsonld_datablock = document.createElement('script');
jsonld_datablock.type = "application/ld+json";
jsonld_datablock.textContent = data.replace('docs/jsonldcontext.jsonld','');
head.appendChild(jsonld_datablock);
})
.catch(error => {
console.error("Failed to fetch:", error);
});
</script>
{%- endif %}
xhr.open('GET', path);
xhr.onload = function() {
if (xhr.status === 200) {
var head = document.getElementsByTagName('head')[0];
var jsonld_datablock = document.createElement('script');
jsonld_datablock.type = "application/ld+json";
//remove full context path, because search engines don't expect it here, pyld requires it.
jsonld_datablock.textContent = xhr.responseText.replace('docs/jsonldcontext.jsonld','');
head.appendChild(jsonld_datablock);
}
};
xhr.send();
</script>
{% endfor %}
</body>
</html>
86 changes: 2 additions & 84 deletions pygeoapi/templates/collections/collection.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,81 +33,6 @@ <h1>{{ data['title'] }}</h1>
</div>
</div>

{% set ns = namespace(header_printed=false) %}
{% for link in data['links'] %}
{% if link['rel'] == 'license' %}
{% if not ns.header_printed %}
<h3>{% trans %}License{% endtrans %}</h3>
{% set ns.header_printed = true %}
{% endif %}
<ul>
<li>
<div>
<a title="{{ link['title'] }}" href="{{ link['href'] }}">{{ link['title'] or link['href'] }}<a>
</li>
</ul>
{% endif %}
{% endfor %}

{% if data['itemType'] == 'feature' or data['itemType'] == 'record' %}
<h3>{% trans %}Browse{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Browse Items{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/items">
{% trans %}Browse through the items of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
<h3>{% trans %}Queryables{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Queryables{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/queryables">
{% trans %}Display Queryables of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
<h3>{% trans %}Schema{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Schema{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/schema">
{% trans %}Display Schema of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
{% endif %}

{% for provider in config['resources'][data['id']]['providers'] %}
{% if 'tile' in provider['type'] %}
<h3>{% trans %}Tiles{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Tiles{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/tiles">{% trans %}Display Tiles of{% endtrans %} "{{ data['title'] }}"</a>
</div>
</li>
</ul>
{% endif %}

{% if 'coverage' in provider['type'] %}
<h3>{% trans %}Coverage{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Coverage{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/coverage">
{% trans %}Display Coverage of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
<h3>{% trans %}Schema{% endtrans %}</h3>
<ul>
<li>
<div>
<a title="{% trans %}Display Schema{% endtrans %}" href="{{ data['collections_path'] }}/{{ data['id'] }}/schema">
{% trans %}Display Schema of{% endtrans %} "{{ data['title'] }}"</a></div>
</li>
</ul>
{% endif %}

{% endfor %}
{%- if data['data_queries'] -%}
<h3>Data Queries</h3>
<table class="table table-striped table-bordered">
Expand Down Expand Up @@ -143,15 +68,6 @@ <h3>Parameters</h3>
</table>
{% endif %}

<h3>{% trans %}Links{% endtrans %}</h3>
<ul>
{% for link in data['links'] %}
<li>
<a title="{{ link['rel'] }}" href="{{ link['href'] }}">
<span>{{ link['title'] }}</span> (<span>{{ link['type'] }}</span>)
</a></li>
{% endfor %}
</ul>
{% if data['itemType'] == 'feature' %}
<h3>{% trans %}Reference Systems{% endtrans %}</h3>
<ul>
Expand All @@ -172,6 +88,8 @@ <h3>{% trans %}Storage CRS{% endtrans %}</h3>
</ul>
{% endif %}

{% include "partials/links.html" %}

</section>
{% endblock %}

Expand Down
15 changes: 2 additions & 13 deletions pygeoapi/templates/collections/items/item.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,8 @@ <h1>{{ ptitle }}</h1>
{% endif %}
{% endfor %}
<tr>
<td>{% trans %}Links{% endtrans %}</td>
<td>
<ul>
{% for l in data['links'] %}
{% if l['href'] %}
<li><a href="{{ l['href'] }}" title="{{ l['title'] or l['href'].split('/') }}">{{ l['title'] or (l['href'].split('/') | last) | truncate( 25 ) }}</a>
{% if l['type'] %}
({{ l['type'] }})
{% endif %}
</li>
{% endif %}
{% endfor %}
</ul>
<td colspane="2">
{% include "partials/link.html" %}
</td>
</tr>
</tbody>
Expand Down
15 changes: 15 additions & 0 deletions pygeoapi/templates/partials/links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h3>{% trans %}Links{% endtrans %}</h3>
{% set ns = namespace(cat_title=None) %}
<ul>
{% for link in (links or data['links'])|sort(attribute='rel') %}
{% if link['rel'] != ns.cat_title %}
{% set ns.cat_title = link['rel'] %}
<li class="list-unstyled text-capitalize" style="margin-left:-2rem">
<b>{{ns.cat_title.split('/').pop()}}</b></li>
{% endif %}
<li>
<a title="{{ link['title'] }}" href="{{ link['href'] }}">
{{ link['title'] or link['href'] }}<a>
</li>
{% endfor %}
</ul>
Loading