From 28414800f8bf94adb3ca77831a373c8c9c8d978e Mon Sep 17 00:00:00 2001 From: Albert Yi Date: Fri, 26 Oct 2018 11:52:06 -0700 Subject: [PATCH] artist urls in reltags should open in new window by default --- app/helpers/application_helper.rb | 4 ++-- app/views/related_tags/_source_tags.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0a6d6bfc9..bb105419c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -107,13 +107,13 @@ module ApplicationHelper time_tag(time.strftime("%Y-%m-%d %H:%M"), time) end - def external_link_to(url, truncate: nil, strip_scheme: false) + def external_link_to(url, truncate: nil, strip_scheme: false, link_options: {}) text = url text = text.gsub(%r!\Ahttps?://!i, "") if strip_scheme text = text.truncate(truncate) if truncate if url =~ %r!\Ahttps?://!i - link_to text, url, {rel: :nofollow} + link_to text, url, {rel: :nofollow}.merge(link_options) else url end diff --git a/app/views/related_tags/_source_tags.html.erb b/app/views/related_tags/_source_tags.html.erb index 3808645ff..2de52e296 100644 --- a/app/views/related_tags/_source_tags.html.erb +++ b/app/views/related_tags/_source_tags.html.erb @@ -19,10 +19,10 @@ <% artist.sorted_urls.each do |url| %>
  • <% if url.is_active %> - <%= external_link_to url.url, truncate: 64, strip_scheme: true %> + <%= external_link_to url.url, truncate: 64, strip_scheme: true, link_options: {target: "_blank"} %> <%= link_to tag.i(class: "fas fa-minus-circle"), artist_url_path(id: url.id, artist_url: { is_active: false }), remote: true, method: :put, "data-confirm": "This will mark the URL as inactive. Continue?" %> <% else %> - <%= external_link_to url.url, truncate: 64, strip_scheme: true %> + <%= external_link_to url.url, truncate: 64, strip_scheme: true, link_options: {target: "_blank"} %> <% end %>
  • <% end %>