From 72eef0ce1d1b6877160b247dc1bc226256514275 Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Sun, 28 Jun 2026 19:30:01 +0200 Subject: [PATCH 1/2] show alternate formats which are listed in links --- pygeoapi/templates/_base.html | 69 +++++++++++++++-------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/pygeoapi/templates/_base.html b/pygeoapi/templates/_base.html index 0aed269e3..bc082be81 100644 --- a/pygeoapi/templates/_base.html +++ b/pygeoapi/templates/_base.html @@ -37,7 +37,7 @@ - {% for link in data['links'] %} + {% for link in (links or data['links']) %} {% if (link['rel']=="self" and link['type']=="text/html") %} {% elif (link['rel']!="canonical") %} @@ -80,25 +80,11 @@ {% trans %}Home{% endtrans %} {% endblock %} - {% 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 %} - {% trans %}json{% endtrans %} - {% elif link['rel'] == 'alternate' and link['type'] and link['type'] == 'application/ld+json' %} - {% set links_found.jsonld = link.href | string | safe %} - {% trans %}jsonld{% endtrans %} - {% endif %} - {% endfor %} - - {% if links_found.json == '' %} - {% trans %}json{% endtrans %} - {% endif %} - {% if links_found.jsonld == '' %} - {% trans %}jsonld{% endtrans %} - {% endif %} - + {% for link in (links or data['links']) %} + {%- if link.get('rel') == 'alternate' -%} + {{ link.get('type').split('/')[-1] }} + {%- endif-%} + {% endfor %} @@ -124,26 +110,31 @@ {% block extrafoot %} {% endblock %} - {%- 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(); - + {% endfor %} From 727648c11a44c1b0f494f56d90831c0764b1fab0 Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Mon, 29 Jun 2026 10:45:43 +0300 Subject: [PATCH 2/2] move the links section to dedicated template, universal to all endpoints --- .../templates/collections/collection.html | 86 +------------------ .../templates/collections/items/item.html | 15 +--- pygeoapi/templates/partials/links.html | 15 ++++ 3 files changed, 19 insertions(+), 97 deletions(-) create mode 100644 pygeoapi/templates/partials/links.html diff --git a/pygeoapi/templates/collections/collection.html b/pygeoapi/templates/collections/collection.html index 4cfbfca0b..e54a52144 100644 --- a/pygeoapi/templates/collections/collection.html +++ b/pygeoapi/templates/collections/collection.html @@ -33,81 +33,6 @@

{{ data['title'] }}

- {% set ns = namespace(header_printed=false) %} - {% for link in data['links'] %} - {% if link['rel'] == 'license' %} - {% if not ns.header_printed %} -

{% trans %}License{% endtrans %}

- {% set ns.header_printed = true %} - {% endif %} - - {% endif %} - {% endfor %} - - {% if data['itemType'] == 'feature' or data['itemType'] == 'record' %} -

{% trans %}Browse{% endtrans %}

-
-

{% trans %}Queryables{% endtrans %}

- -

{% trans %}Schema{% endtrans %}

- - {% endif %} - - {% for provider in config['resources'][data['id']]['providers'] %} - {% if 'tile' in provider['type'] %} -

{% trans %}Tiles{% endtrans %}

- - {% endif %} - - {% if 'coverage' in provider['type'] %} -

{% trans %}Coverage{% endtrans %}

- -

{% trans %}Schema{% endtrans %}

- - {% endif %} - - {% endfor %} {%- if data['data_queries'] -%}

Data Queries

@@ -143,15 +68,6 @@

Parameters

{% endif %} -

{% trans %}Links{% endtrans %}

- {% if data['itemType'] == 'feature' %}

{% trans %}Reference Systems{% endtrans %}

{% endif %} + {% include "partials/links.html" %} + {% endblock %} diff --git a/pygeoapi/templates/collections/items/item.html b/pygeoapi/templates/collections/items/item.html index 705f9057c..162a1f78d 100644 --- a/pygeoapi/templates/collections/items/item.html +++ b/pygeoapi/templates/collections/items/item.html @@ -98,19 +98,8 @@

{{ ptitle }}

{% endif %} {% endfor %} - {% trans %}Links{% endtrans %} - - + + {% include "partials/link.html" %} diff --git a/pygeoapi/templates/partials/links.html b/pygeoapi/templates/partials/links.html new file mode 100644 index 000000000..ef5887e73 --- /dev/null +++ b/pygeoapi/templates/partials/links.html @@ -0,0 +1,15 @@ +

{% trans %}Links{% endtrans %}

+{% set ns = namespace(cat_title=None) %} + \ No newline at end of file