adds twitter and opengraph tags to html encoding, to facilitate display in social media

This commit is contained in:
Paul
2021-02-26 17:26:04 +01:00
committed by Paul van Genuchten
parent c0c2ba541f
commit cc03d1d54d
3 changed files with 17 additions and 2 deletions
+12 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="{{ config['server']['encoding'] }}">
<title>{% block title %}{{ config['metadata']['identification']['title'] }} -{% endblock %}</title>
<title>{% block title %}{% endblock %}{% if not self.title() %}{{ config['metadata']['identification']['title'] }}{% endif %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="language" content="{{ config['server']['language'] }}">
<meta name="description" content="{{ config['metadata']['identification']['title'] }}">
@@ -13,6 +13,17 @@
<!--[if lt IE 9]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.js"></script>
<![endif]-->
<meta name="twitter:image:src" content="{% block thumb %}{% endblock %}{% if not self.thumb() %}{{'{}/static/img/logo.png'.format(config['server']['url']) }}{% endif %}" />
<meta property="og:image" content="{{ self.thumb() }}{% if not self.thumb() %}{{'{}/static/img/logo.png'.format(config['server']['url']) }}{% endif %}" />
<meta name="twitter:site" content="{{ config['metadata']['identification']['title'] }}" />
<meta property="og:site_name" content="{{ config['metadata']['identification']['title'] }}" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="{{ self.title() }}{% if not self.title() %}{{ config['metadata']['identification']['title'] }}{% endif %}" />
<meta property="og:title" content="{{ self.title() }}{% if not self.title() %}{{ config['metadata']['identification']['title'] }}{% endif %}" />
<meta name="twitter:description" content="{{ config['metadata']['identification']['description']}}" />
<meta property="og:description" content="{{ config['metadata']['identification']['description']}}" />
<meta property="og:type" content="website" />
{% for link in data['links'] %}
{% if (link['rel']=="self" and link['type']=="text/html") %}
<link rel="canonical" href="{{ link['href'].split('?')[0] }}?f=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() }}
/ <a href="{{ data['collections_path'] }}">{% trans %}Collections{% endtrans %}</a>
/ <a href="./{{ data['id'] }}">{{ data['title'] | truncate( 25 ) }}</a>
@@ -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() }}
/ <a href="{{ data['collections_path'] }}">{% trans %}Collections{% endtrans %}</a>
{% for link in data['links'] %}