From 18b8fc60bb08b2df03fa74537ea51cdd7fcfd39a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 20 Dec 2015 00:19:16 +0000 Subject: [PATCH] Add rel=nofollow to links to tagless nodes in browse pages --- .rubocop_todo.yml | 2 +- app/helpers/browse_helper.rb | 4 ++++ app/views/browse/_relation_member.html.erb | 2 +- app/views/browse/_way.html.erb | 2 +- app/views/browse/changeset.html.erb | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 287fcd9f9..b317054b6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -85,7 +85,7 @@ Metrics/MethodLength: # Offense count: 1 # Configuration parameters: CountComments. Metrics/ModuleLength: - Max: 126 + Max: 129 # Offense count: 4 # Configuration parameters: CountKeywordArgs. diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 3723186b8..6c9e108dc 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -52,6 +52,10 @@ module BrowseHelper end end + def link_follow(object) + "nofollow" if object.tags.empty? + end + def format_key(key) if url = wiki_link("key", key) link_to h(key), url, :title => t("browse.tag_details.wiki_link.key", :key => key) diff --git a/app/views/browse/_relation_member.html.erb b/app/views/browse/_relation_member.html.erb index 0d17de349..87b7e301b 100644 --- a/app/views/browse/_relation_member.html.erb +++ b/app/views/browse/_relation_member.html.erb @@ -1,6 +1,6 @@ <% member_class = link_class(relation_member.member_type.downcase, relation_member.member) - linked_name = link_to printable_name(relation_member.member), { :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, :title => link_title(relation_member.member) + linked_name = link_to printable_name(relation_member.member), { :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, :title => link_title(relation_member.member), :rel => link_follow(relation_member.member) type_str = t'browse.relation_member.type.' + relation_member.member_type.downcase %>
  • <%= diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index b1dffb9ef..489b9cf07 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -15,7 +15,7 @@