Skip to content

Commit

Permalink
Merge aa4c5e6 into e21cabf
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jul 21, 2016
2 parents e21cabf + aa4c5e6 commit ee7d7e8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES.rst
Expand Up @@ -6,6 +6,10 @@ There's a frood who really knows where his towel is.
1.2b2 (unreleased)
^^^^^^^^^^^^^^^^^^

- Use the `X-Robots-Tag` header to avoid indexing of image scales on default view;
this will reduce the number of 404 (Not Found) responses generated by crawlers visiting the site in search of volatile content.
[hvelarde]

- Enforce usage of plone.api >= 1.4.11 to avoid `TypeError` while running upgrade step to profile 14.
[hvelarde]

Expand Down
4 changes: 3 additions & 1 deletion buildout.cfg
Expand Up @@ -23,7 +23,9 @@ recipe = zc.recipe.egg
eggs = z3c.checkversions [buildout]

[code-analysis]
recipe = plone.recipe.codeanalysis[recommended]
# XXX: https://github.com/schlamar/flake8-todo/pull/6
#recipe = plone.recipe.codeanalysis[recommended]
recipe = plone.recipe.codeanalysis
directory = ${buildout:directory}/src/collective/cover
clean-lines = True
clean-lines-exclude = ${buildout:directory}/src/collective/cover/static/js/vendor/
Expand Down
4 changes: 4 additions & 0 deletions src/collective/cover/browser/cover.py
Expand Up @@ -34,6 +34,10 @@ class View(grok.View):
grok.require('zope2.View')
grok.name('view')

def update(self):
"""Forbid image indexing as scales are volatile."""
self.request.RESPONSE.setHeader('X-Robots-Tag', 'noimageindex')


class Standard(grok.View):
grok.context(ICover)
Expand Down
1 change: 1 addition & 0 deletions src/collective/cover/tests/test_basic_tile.robot
Expand Up @@ -28,6 +28,7 @@ ${edit_link_selector} a.edit-tile-link
*** Test cases ***

Test Basic Tile
[Tags] issue_637
# XXX: test is randomly failing under Plone 4.2 only
Run keyword if '${CMFPLONE_VERSION}' >= '4.3' Remove Tags Mandelbug

Expand Down
4 changes: 4 additions & 0 deletions src/collective/cover/tests/test_robot.py
Expand Up @@ -33,6 +33,10 @@
(PLONE_VERSION.startswith('4.3') and DEXTERITY_ONLY):
noncritical.append('issue_615')

# FIXME: https://github.com/collective/collective.cover/issues/637
if PLONE_VERSION.startswith('4.3') and DEXTERITY_ONLY:
noncritical.append('issue_637')


def test_suite():
suite = unittest.TestSuite()
Expand Down
7 changes: 7 additions & 0 deletions src/collective/cover/tests/test_views.py
Expand Up @@ -47,6 +47,13 @@ def test_default_view_render(self):
self.assertEqual(
len(html.xpath('.//div[contains(text(),"My Description")]')), 0)

def test_default_view_forbids_image_indexing(self):
view = api.content.get_view(u'view', self.c1, self.request)
view() # render the view to get the response
response = self.request.RESPONSE
self.assertIn('x-robots-tag', response.headers)
self.assertEqual(response.getHeader('x-robots-tag'), 'noimageindex')

def test_alternate_view_registration(self):
portal_types = self.portal['portal_types']
view_methods = portal_types['collective.cover.content'].view_methods
Expand Down

0 comments on commit ee7d7e8

Please sign in to comment.