fix: make sure maps of demo instances of uMap are no indexed (#2203)

fix #2201
This commit is contained in:
Yohan Boniface 2024-10-10 21:00:27 +02:00 committed by GitHub
commit a2b8145cde
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 2 deletions

View file

@ -17,8 +17,8 @@
{% umap_css %} {% umap_css %}
{{ block.super }} {{ block.super }}
{% umap_js locale=locale %} {% umap_js locale=locale %}
{% if object.share_status != object.PUBLIC %} {% if UMAP_DEMO_SITE or object.share_status != object.PUBLIC %}
<meta name="robots" content="noindex"> <meta name="robots" content="noindex,nofollow">
{% endif %} {% endif %}
<link rel="alternate" <link rel="alternate"
type="application/json+oembed" type="application/json+oembed"

View file

@ -861,3 +861,22 @@ def test_ogp_links(client, map, datalayer):
assert f'<meta property="og:title" content="{map.name}" />' 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 f'<meta property="og:description" content="{map.description}" />' in content
assert '<meta property="og:site_name" content="uMap" />' in content assert '<meta property="og:site_name" content="uMap" />' in content
def test_non_public_map_should_have_noindex_meta(client, map, datalayer):
map.share_status = Map.OPEN
map.save()
response = client.get(map.get_absolute_url())
assert response.status_code == 200
assert (
'<meta name="robots" content="noindex,nofollow">' in response.content.decode()
)
def test_demo_instance_should_have_noindex(client, map, datalayer, settings):
settings.UMAP_DEMO_SITE = True
response = client.get(map.get_absolute_url())
assert response.status_code == 200
assert (
'<meta name="robots" content="noindex,nofollow">' in response.content.decode()
)