Skip to content

Commit

Permalink
fix: make sure maps of demo instances of uMap are no indexed (#2203)
Browse files Browse the repository at this point in the history
fix #2201
  • Loading branch information
yohanboniface authored Oct 10, 2024
2 parents 8635ebf + 7aa445f commit a2b8145
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions umap/templates/umap/map_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
{% umap_css %}
{{ block.super }}
{% umap_js locale=locale %}
{% if object.share_status != object.PUBLIC %}
<meta name="robots" content="noindex">
{% if UMAP_DEMO_SITE or object.share_status != object.PUBLIC %}
<meta name="robots" content="noindex,nofollow">
{% endif %}
<link rel="alternate"
type="application/json+oembed"
Expand Down
19 changes: 19 additions & 0 deletions umap/tests/test_map_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:description" content="{map.description}" />' 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()
)

0 comments on commit a2b8145

Please sign in to comment.