Skip to content

Commit

Permalink
[bug 680739] Template articles should not get indexed.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Sep 6, 2011
1 parent ff520d9 commit b3f469d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/wiki/templates/wiki/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
{% set localizable_url = url('wiki.document', document.parent.slug, locale=settings.WIKI_DEFAULT_LANGUAGE) %}
{% endif %}

{% if document.is_template %}
{% set meta = (('robots', 'noindex'),) %}
{% endif %}

{% block content %}
<article id="wiki-doc" class="main">
{{ related_articles(related, document) }}
Expand Down
3 changes: 3 additions & 0 deletions apps/wiki/templates/wiki/mobile/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
{% set is_mobile_page = True %} {# TODO: set based on showfor selection or...? #}
{% set classes = 'document' %}
{% set canonical_url = document.get_absolute_url() %}
{% if document.is_template %}
{% set meta = (('robots', 'noindex'),) %}
{% endif %}

{% block content %}
<article id="wiki-doc">
Expand Down
18 changes: 18 additions & 0 deletions apps/wiki/tests/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,24 @@ def test_obsolete_no_vote(self):
doc = pq(response.content)
assert not doc('#helpful-vote')

def test_templates_noindex(self):
"""Document templates should have a noindex meta tag."""
# Create a document and verify there is no robots:noindex
r = revision(save=True, content='Some text.', is_approved=True)
response = self.client.get(r.document.get_absolute_url())
eq_(200, response.status_code)
doc = pq(response.content)
eq_(0, len(doc('meta[name=robots]')))

# Convert the document to a template and verify robots:noindex
d = r.document
d.title = 'Template:test'
d.save()
response = self.client.get(r.document.get_absolute_url())
eq_(200, response.status_code)
doc = pq(response.content)
eq_('noindex', doc('meta[name=robots]')[0].attrib['content'])


class RevisionTests(TestCaseBase):
"""Tests for the Revision template"""
Expand Down

0 comments on commit b3f469d

Please sign in to comment.