Browse Source

#688: send robots.txt as plain text

Rafał Pitoń 8 years ago
parent
commit
fe0692bfa9
2 changed files with 5 additions and 1 deletions
  1. 1 0
      misago/core/tests/test_views.py
  2. 4 1
      misago/urls.py

+ 1 - 0
misago/core/tests/test_views.py

@@ -26,6 +26,7 @@ class RobotsTxtViewTests(TestCase):
     def test_robots_txt_returns_200(self):
     def test_robots_txt_returns_200(self):
         """robots.txt has no showstoppers"""
         """robots.txt has no showstoppers"""
         response = self.client.get('/robots.txt')
         response = self.client.get('/robots.txt')
+        self.assertEqual(response['Content-type'], 'text/plain')
         self.assertContains(response, '/api/')
         self.assertContains(response, '/api/')
 
 
 
 

+ 4 - 1
misago/urls.py

@@ -14,7 +14,10 @@ urlpatterns = [
     url(r'^', include('misago.search.urls')),
     url(r'^', include('misago.search.urls')),
 
 
     # default robots.txt
     # default robots.txt
-    url(r'^robots.txt$', TemplateView.as_view(template_name='misago/robots.txt')),
+    url(r'^robots.txt$', TemplateView.as_view(
+        content_type='text/plain',
+        template_name='misago/robots.txt'
+    )),
 
 
     # "misago:index" link symbolises "root" of Misago links space
     # "misago:index" link symbolises "root" of Misago links space
     # any request with path that falls below this one is assumed to be directed
     # any request with path that falls below this one is assumed to be directed