Skip to content

Commit

Permalink
Add the attribute to external links (#12832)
Browse files Browse the repository at this point in the history
* Add the  attribute to external links

* Change the  header value to

* Indicate the canonical URL for the page

* Add the rel attribute to the profile external link

Co-authored-by: Antti Hukkanen <antti.hukkanen@mainiotech.fi>
  • Loading branch information
andreslucena and ahukkanen authored May 6, 2024
1 parent 071d337 commit 3554ab4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion decidim-core/app/cells/decidim/profile/details.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<%= icon detail[:icon] %>
<span>
<% if detail[:url].present? %>
<%= link_to(detail[:url], detail[:text]) %>
<%= link_to(detail[:url], detail[:text], rel: "nofollow noopener noreferrer") %>
<% else %>
<%= detail[:text] %>
<% end %>
Expand Down
3 changes: 2 additions & 1 deletion decidim-core/app/controllers/decidim/links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class LinksController < Decidim::ApplicationController
rescue_from URI::InvalidURIError, with: :modal

def new
headers["X-Robots-Tag"] = "noindex"
headers["X-Robots-Tag"] = "none"
headers["Link"] = %(<#{url_for}>; rel="canonical")
end

private
Expand Down
2 changes: 1 addition & 1 deletion decidim-core/app/views/decidim/links/_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
<button class="button button__lg button__transparent-secondary" data-dialog-close="external-domain-warning">
<%= t("decidim.links.warning.cancel") %>
</button>
<%= link_to t("decidim.links.warning.proceed"), external_url.to_s , target: "_blank", class: "button button__lg button__secondary" %>
<%= link_to t("decidim.links.warning.proceed"), external_url.to_s , target: "_blank", class: "button button__lg button__secondary", rel: "nofollow noopener noreferrer" %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion decidim-core/app/views/decidim/links/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</code>

<div class="form__wrapper-block">
<%= link_to t("decidim.links.warning.proceed"), external_url.to_s, class: "button button__lg button__secondary ml-auto" %>
<%= link_to t("decidim.links.warning.proceed"), external_url.to_s, class: "button button__lg button__secondary ml-auto", rel: "nofollow noopener noreferrer" %>
</div>

<% end %>

0 comments on commit 3554ab4

Please sign in to comment.