From cc03d1d54ddf153e314a26bb93b0b35df032e6fd Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 26 Feb 2021 17:26:04 +0100 Subject: [PATCH] adds twitter and opengraph tags to html encoding, to facilitate display in social media --- pygeoapi/templates/_base.html | 13 ++++++++++++- pygeoapi/templates/collections/collection.html | 2 ++ pygeoapi/templates/collections/items/item.html | 4 +++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pygeoapi/templates/_base.html b/pygeoapi/templates/_base.html index 3089984..ec77989 100644 --- a/pygeoapi/templates/_base.html +++ b/pygeoapi/templates/_base.html @@ -2,7 +2,7 @@ - {% block title %}{{ config['metadata']['identification']['title'] }} -{% endblock %} + {% block title %}{% endblock %}{% if not self.title() %}{{ config['metadata']['identification']['title'] }}{% endif %} @@ -13,6 +13,17 @@ + + + + + + + + + + + {% for link in data['links'] %} {% if (link['rel']=="self" and link['type']=="text/html") %} diff --git a/pygeoapi/templates/collections/collection.html b/pygeoapi/templates/collections/collection.html index 9f16f70..36d507a 100644 --- a/pygeoapi/templates/collections/collection.html +++ b/pygeoapi/templates/collections/collection.html @@ -1,5 +1,7 @@ {% extends "_base.html" %} {% block title %}{{ super() }} {{ data['title'] }} {% endblock %} +{% block desc %}{{ data.get('description','') | truncate(250) }}{% endblock %} +{% block tags %}{{ data.get('keywords',[]) | join(',') }}{% endblock %} {% block crumbs %}{{ super() }} / {% trans %}Collections{% endtrans %} / {{ data['title'] | truncate( 25 ) }} diff --git a/pygeoapi/templates/collections/items/item.html b/pygeoapi/templates/collections/items/item.html index d9be0a6..a5e5fdd 100644 --- a/pygeoapi/templates/collections/items/item.html +++ b/pygeoapi/templates/collections/items/item.html @@ -1,5 +1,7 @@ {% extends "_base.html" %} {% set ptitle = data['properties'][data['title_field']] or ("Item {}".format(data['id'])) %} +{% block desc %}{{ data.get('properties',{}).get('description',{}) | string | truncate(250) }}{% endblock %} +{% block tags %}{{ data['properties'].get('themes',[{}])[0].get('concepts',[]) | join(',') }}{% endblock %} {# Optionally renders an img element, otherwise standard value or link rendering #} {% macro render_item_value(v, width) -%} {% set val = v | string | trim %} @@ -20,7 +22,7 @@ {{ val | urlize() }} {% endif %} {%- endmacro %} -{% block title %}{{ ptitle }} - {{ super() }}{% endblock %} +{% block title %}{{ ptitle }}{% endblock %} {% block crumbs %}{{ super() }} / {% trans %}Collections{% endtrans %} {% for link in data['links'] %}