From 3554ab4547cbc7fbd91777c855a48a32054c03b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Pereira=20de=20Lucena?= Date: Mon, 6 May 2024 20:34:06 +0200 Subject: [PATCH] Add the attribute to external links (#12832) * 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 --- decidim-core/app/cells/decidim/profile/details.erb | 2 +- decidim-core/app/controllers/decidim/links_controller.rb | 3 ++- decidim-core/app/views/decidim/links/_modal.html.erb | 2 +- decidim-core/app/views/decidim/links/new.html.erb | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/decidim-core/app/cells/decidim/profile/details.erb b/decidim-core/app/cells/decidim/profile/details.erb index 5aa31e0cf6586..7172437ba559a 100644 --- a/decidim-core/app/cells/decidim/profile/details.erb +++ b/decidim-core/app/cells/decidim/profile/details.erb @@ -9,7 +9,7 @@ <%= icon detail[:icon] %> <% if detail[:url].present? %> - <%= link_to(detail[:url], detail[:text]) %> + <%= link_to(detail[:url], detail[:text], rel: "nofollow noopener noreferrer") %> <% else %> <%= detail[:text] %> <% end %> diff --git a/decidim-core/app/controllers/decidim/links_controller.rb b/decidim-core/app/controllers/decidim/links_controller.rb index a1bb3339b0b23..90b0331c38d4a 100644 --- a/decidim-core/app/controllers/decidim/links_controller.rb +++ b/decidim-core/app/controllers/decidim/links_controller.rb @@ -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 diff --git a/decidim-core/app/views/decidim/links/_modal.html.erb b/decidim-core/app/views/decidim/links/_modal.html.erb index 86b32595bdb78..8d7ac1e782e49 100644 --- a/decidim-core/app/views/decidim/links/_modal.html.erb +++ b/decidim-core/app/views/decidim/links/_modal.html.erb @@ -16,6 +16,6 @@ - <%= 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" %> <% end %> diff --git a/decidim-core/app/views/decidim/links/new.html.erb b/decidim-core/app/views/decidim/links/new.html.erb index 562b87c53501b..def3f57c8f05a 100644 --- a/decidim-core/app/views/decidim/links/new.html.erb +++ b/decidim-core/app/views/decidim/links/new.html.erb @@ -12,7 +12,7 @@
- <%= 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" %>
<% end %>