Brad Crittenden has proposed merging lp:~bac/launchpad/bug-644550 into lp:launchpad/devel.
Requested reviews: Launchpad code reviewers (launchpad-reviewers) Related bugs: #644550 Robots can index blueprints when it is not used https://bugs.launchpad.net/bugs/644550 = Summary = For projects that don't use Launchpad we need to block robots from indexing. == Proposed fix == Add the appropriate meta foo to do so. == Pre-implementation notes == Brief chat with Curtis == Implementation details == As above. Also got rid of all of the omit-tags as they were malformed. == Tests == bin/test -vvm lp.code -t test_specificationtarget == Demo and Q/A == Create new project and then click on the 'Blueprints' tag. Inspect the HTML to ensure the nofollow is in there. Or write your own spider and see what happens! = Launchpad lint = Checking for conflicts and issues in changed files. Linting changed files: lib/lp/blueprints/templates/unknown-specs.pt lib/lp/blueprints/browser/tests/test_specificationtarget.py -- https://code.launchpad.net/~bac/launchpad/bug-644550/+merge/36463 Your team Launchpad code reviewers is requested to review the proposed merge of lp:~bac/launchpad/bug-644550 into lp:launchpad/devel.
=== modified file 'lib/lp/blueprints/browser/tests/test_specificationtarget.py' --- lib/lp/blueprints/browser/tests/test_specificationtarget.py 2010-09-19 23:58:07 +0000 +++ lib/lp/blueprints/browser/tests/test_specificationtarget.py 2010-09-23 15:51:07 +0000 @@ -4,6 +4,8 @@ __metaclass__ = type +from BeautifulSoup import BeautifulSoup + from zope.security.proxy import removeSecurityProxy from canonical.launchpad.testing.pages import find_tag_by_id @@ -232,3 +234,43 @@ login_person(project_group.owner) view = create_initialized_view(project_group, '+specs') self.assertEqual(False, view.can_configure_blueprints) + + +class TestSpecificationsRobots(TestCaseWithFactory): + """Test the behaviour of specfications when usage is UNKNOWN.""" + + layer = DatabaseFunctionalLayer + + def setUp(self): + super(TestSpecificationsRobots, self).setUp() + self.product = self.factory.makeProduct() + self.naked_product = removeSecurityProxy(self.product) + + def _configure_project(self, usage): + self.naked_product.blueprints_usage = usage + view = create_initialized_view(self.product, '+specs') + soup = BeautifulSoup(view()) + robots = soup.find('meta', attrs={'name': 'robots'}) + return soup, robots + + def _verify_robots_not_blocked(self, usage): + soup, robots = self._configure_project(usage) + self.assertTrue(robots is None) + self.assertTrue(soup.find(True, id='specs-unknown') is None) + + def _verify_robots_are_blocked(self, usage): + soup, robots = self._configure_project(usage) + self.assertEqual('noindex,nofollow', robots['content']) + self.assertTrue(soup.find(True, id='specs-unknown') is not None) + + def test_UNKNOWN_blocks_robots(self): + self._verify_robots_are_blocked(ServiceUsage.UNKNOWN) + + def test_EXTERNAL_blocks_robots(self): + self._verify_robots_are_blocked(ServiceUsage.EXTERNAL) + + def test_NOT_APPLICABLE_blocks_robots(self): + self._verify_robots_are_blocked(ServiceUsage.NOT_APPLICABLE) + + def test_LAUNCHPAD_does_not_block_robots(self): + self._verify_robots_not_blocked(ServiceUsage.LAUNCHPAD) === modified file 'lib/lp/blueprints/templates/unknown-specs.pt' --- lib/lp/blueprints/templates/unknown-specs.pt 2010-09-16 16:47:37 +0000 +++ lib/lp/blueprints/templates/unknown-specs.pt 2010-09-23 15:51:07 +0000 @@ -7,25 +7,31 @@ i18n:domain="launchpad" > +<head> + <tal:head_epilogue metal:fill-slot="head_epilogue"> + <meta name="robots" content="noindex,nofollow" /> + </tal:head_epilogue> +</head> + <body> <div metal:fill-slot="main"> <div class="top-portlet"> <div id="specs-unknown"> <strong> - <div tal:omit-tag tal:condition="view/is_project"> + <tal:is_project condition="view/is_project"> <p> Launchpad does not know how <tal:project replace="view/context/displayname" /> tracks feature planning or documentation. </p> - </div> - - <div tal:omit-tag tal:condition="view/is_series"> + </tal:is_project> + + <tal:is_series condition="view/is_series"> <div - tal:omit-tag + tal:omit-tag="" tal:define="target python:view.context.product and view.context.product or view.context.distribution; - blueprints_usage target/blueprints_usage"> + blueprints_usage target/blueprints_usage"> <p tal:condition="blueprints_usage/enumvalue:EXTERNAL"> <tal:project replace="target/displayname" />'s <tal:project replace="view/context/displayname" /> series does @@ -43,11 +49,11 @@ planning or documentation. </p> </div> - </div> - - <div tal:omit-tag - tal:condition="python:not (view.is_project or view.is_series)"> - <div tal:omit-tag tal:define="blueprints_usage view/context/blueprints_usage"> + </tal:is_series> + + <tal:not_project_or_series + condition="python:not (view.is_project or view.is_series)"> + <div tal:omit-tag="" tal:define="blueprints_usage view/context/blueprints_usage"> <p tal:condition="blueprints_usage/enumvalue:EXTERNAL"> <tal:project replace="view/context/displayname" /> does not use launchpad for planning or documentation. @@ -62,20 +68,20 @@ planning or documentation. </p> </div> - </div> + </tal:not_project_or_series> </strong> - <div tal:omit-tag tal:condition="view/has_wiki"> - <p id="wiki-fallback" - tal:define="wiki view/context/wikiurl" - tal:condition="wiki"> - <tal:project replace="view/context/displayname" /> has a wiki, which - may be used for feature plannning and documentation.<br /> - <a tal:attributes="href view/context/wikiurl"> - <tal:project replace="view/context/displayname" /> wiki - </a> - </p> - </div> + <tal:has_wiki condition="view/has_wiki"> + <p id="wiki-fallback" + tal:define="wiki view/context/wikiurl" + tal:condition="wiki"> + <tal:project replace="view/context/displayname" /> has a wiki, which + may be used for feature plannning and documentation.<br /> + <a tal:attributes="href view/context/wikiurl"> + <tal:project replace="view/context/displayname" /> wiki + </a> + </p> + </tal:has_wiki> </div> <p id="configure-support"
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp