-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iar#178] Allow customization of robots.txt.
Serve `/robots.txt` from a template instead of from a static file to allow for customization by extensions and site owners. See ckan/ideas#178.
- Loading branch information
Showing
6 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
User-agent: * | ||
{% block all_user_agents -%} | ||
Disallow: /dataset/rate/ | ||
Disallow: /revision/ | ||
Disallow: /dataset/*/history | ||
Disallow: /api/ | ||
|
||
User-Agent: * | ||
Crawl-Delay: 10 | ||
{%- endblock %} | ||
|
||
{% block additional_user_agents -%} | ||
{%- endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# encoding: utf-8 | ||
|
||
from nose.tools import assert_equal | ||
|
||
import ckan.tests.helpers as helpers | ||
|
||
|
||
class TestTemplateController(helpers.FunctionalTestBase): | ||
|
||
def test_content_type(self): | ||
cases = { | ||
u'/robots.txt': u'text/plain; charset=utf-8', | ||
u'/page': u'text/html; charset=utf-8', | ||
u'/page.html': u'text/html; charset=utf-8', | ||
} | ||
app = self._get_test_app() | ||
for url, expected in cases.iteritems(): | ||
response = app.get(url, status=200) | ||
assert_equal(response.headers.get(u'Content-Type'), expected) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# encoding: utf-8 | ||
|
||
from nose.tools import assert_equal, ok_ | ||
|
||
import ckan.tests.helpers as helpers | ||
|
||
|
||
class TestRobotsTxt(helpers.FunctionalTestBase): | ||
|
||
def test_robots_txt(self): | ||
app = self._get_test_app() | ||
response = app.get(u'/robots.txt', status=200) | ||
assert_equal(response.headers.get(u'Content-Type'), u'text/plain; charset=utf-8') | ||
ok_(u'User-agent' in response) |