Skip to content

Commit 53e03e0

Browse files
committed
Added rel='nofollow' attribute to the 'missing link'
1 parent ff9c10e commit 53e03e0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

trac/resource.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,10 @@ def render_resource_link(env, context, resource, format='default'):
431431
from genshi.builder import Element, tag
432432
link = get_resource_description(env, resource, format, context=context)
433433
if not isinstance(link, Element):
434-
class_ = 'missing' if not resource_exists(env, resource) else None
435-
link = tag.a(link, class_=class_,
436-
href=get_resource_url(env, resource, context.href))
434+
exists = resource_exists(env, resource)
435+
link = tag.a(link, class_='missing' if not exists else None,
436+
href=get_resource_url(env, resource, context.href),
437+
rel='nofollow' if not exists else None)
437438

438439
return link
439440

trac/tests/resource.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ def test_render_missing_Link_missing_resource(self):
6666
wp = WikiPage(self.env, 'WikiStart')
6767
context = web_context(self.req)
6868
link = resource.render_resource_link(self.env, context, wp.resource)
69-
html = '<a class="missing" href="/trac.cgi/wiki/WikiStart">WikiStart</a>'
69+
html = '<a class="missing" href="/trac.cgi/wiki/WikiStart" ' + \
70+
'rel="nofollow">WikiStart</a>'
7071
self.assertEqual(html, str(link))
7172

7273

0 commit comments

Comments
 (0)