Merge pull request #1758 from umap-project/minimal-ogp

feat: add minimal OpenGraph links
This commit is contained in:
Yohan Boniface 2024-04-17 14:34:44 +02:00 committed by GitHub
commit e8b5331054
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 0 deletions

View file

@ -7,6 +7,7 @@ def settings(request):
return {
"UMAP_FEEDBACK_LINK": djsettings.UMAP_FEEDBACK_LINK,
"SITE_NAME": djsettings.SITE_NAME,
"SITE_URL": djsettings.SITE_URL,
"ENABLE_ACCOUNT_LOGIN": djsettings.ENABLE_ACCOUNT_LOGIN,
"UMAP_READONLY": djsettings.UMAP_READONLY,
"UMAP_DEMO_SITE": djsettings.UMAP_DEMO_SITE,

View file

@ -18,6 +18,10 @@
type="application/json+oembed"
href="{{ oembed_absolute_uri }}?url={{ quoted_absolute_uri }}&format=json"
title="{{ map.name }} oEmbed URL" />
<meta property="og:url" content="{{ SITE_URL }}{{ map.get_absolute_url }}" />
<meta property="og:title" content="{{ map.name }}" />
<meta property="og:description" content="{{ map.description }}" />
<meta property="og:site_name" content="{{ SITE_NAME }}" />
{% endblock extra_head %}
{% block content %}
{% block map_init %}

View file

@ -847,3 +847,16 @@ def test_oembed_link(client, map, datalayer):
f'?url=http%3A%2F%2Ftestserver%2Fen%2Fmap%2Ftest-map_{map.id}&format=json"'
) in response.content.decode()
assert 'title="test map oEmbed URL" />' in response.content.decode()
def test_ogp_links(client, map, datalayer):
response = client.get(map.get_absolute_url())
assert response.status_code == 200
content = response.content.decode()
assert (
f'<meta property="og:url" content="http://umap.org{map.get_absolute_url()}" />'
in content
)
assert f'<meta property="og:title" content="{map.name}" />' in content
assert f'<meta property="og:description" content="{map.description}" />' in content
assert '<meta property="og:site_name" content="uMap" />' in content