diff --git a/pandora/app/views.py b/pandora/app/views.py index a16d4251..c26ecc7c 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -89,11 +89,17 @@ def opensearch_xml(request): 'application/xml' ) -def robots_txt(request, url): - return HttpResponse( - 'User-agent: *\nDisallow:\nSitemap: %s\n' % request.build_absolute_uri('/sitemap.xml'), - 'text/plain' - ) +def robots_txt(request): + if settings.CONFIG['site'].get('public'): + robots_txt = '''User-agent: * +Disallow: +Sitemap: {} +'''.format(request.build_absolute_uri('/sitemap.xml')) + else: + robots_txt = '''User-agent: * +Disallow: / +''' + return HttpResponse(robots_txt, 'text/plain') def getPage(request, data): ''' @@ -113,7 +119,7 @@ def getPage(request, data): name = data['name'] page, created = models.Page.objects.get_or_create(name=name) if created: - page.text= '' + page.text = '' page.save() response = json_response({'name': page.name, 'text': page.text}) return render_to_json_response(response) diff --git a/pandora/config.0xdb.jsonc b/pandora/config.0xdb.jsonc index bea67c42..5fe0733b 100644 --- a/pandora/config.0xdb.jsonc +++ b/pandora/config.0xdb.jsonc @@ -1110,6 +1110,7 @@ "https": true, "id": "0xdb", "name": "0xDB", + "public": true, "sendReferrer": false, "url": "0xDB.org" }, diff --git a/pandora/config.indiancinema.jsonc b/pandora/config.indiancinema.jsonc index f1716ae1..6b0aa500 100644 --- a/pandora/config.indiancinema.jsonc +++ b/pandora/config.indiancinema.jsonc @@ -1579,10 +1579,11 @@ // E-mail address uses by the system (from) "system": "system@indiancine.ma" }, - "folderdepth": 4, + "folderdepth": 4, "https": true, "id": "indiancinema", "name": "Indiancine.ma", + "public": true, "sendReferrer": true, "url": "indiancine.ma" }, diff --git a/pandora/config.padma.jsonc b/pandora/config.padma.jsonc index ab552ec2..0d5b953a 100644 --- a/pandora/config.padma.jsonc +++ b/pandora/config.padma.jsonc @@ -1063,6 +1063,7 @@ "https": true, "id": "padma", "name": "Pad.ma", + "public": false, "sendReferrer": true, "url": "pad.ma" }, diff --git a/pandora/config.pandora.jsonc b/pandora/config.pandora.jsonc index fded3f9d..2f26e2d5 100644 --- a/pandora/config.pandora.jsonc +++ b/pandora/config.pandora.jsonc @@ -1002,6 +1002,8 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution. "https": false, "id": "pandora", "name": "pan.do/ra", + // Set to true to allow search engines to index the site + "public": false, "sendReferrer": true, "url": "pandora.local" }, diff --git a/pandora/urls.py b/pandora/urls.py index 2ced85a5..ee4042bb 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -54,10 +54,6 @@ urlpatterns = [ url(r'^texts/$', text.views.text), url(r'^texts/(?P.*?)/\d+$', text.views.text), url(r'^texts/(?P.*?)$', text.views.text), - url(r'^robots.txt$', serve_static_file, { - 'location': os.path.join(settings.STATIC_ROOT, 'robots.txt'), - 'content_type': 'text/plain' - }), url(r'^favicon.ico$', serve_static_file, { 'location': os.path.join(settings.STATIC_ROOT, 'png/icon.16.png'), 'content_type': 'image/x-icon'