artist urls in reltags should open in new window by default

This commit is contained in:
Albert Yi
2018-10-26 11:52:06 -07:00
parent 77a576d5ed
commit 28414800f8
2 changed files with 4 additions and 4 deletions

View File

@@ -107,13 +107,13 @@ module ApplicationHelper
time_tag(time.strftime("%Y-%m-%d %H:%M"), time) time_tag(time.strftime("%Y-%m-%d %H:%M"), time)
end 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 = url
text = text.gsub(%r!\Ahttps?://!i, "") if strip_scheme text = text.gsub(%r!\Ahttps?://!i, "") if strip_scheme
text = text.truncate(truncate) if truncate text = text.truncate(truncate) if truncate
if url =~ %r!\Ahttps?://!i if url =~ %r!\Ahttps?://!i
link_to text, url, {rel: :nofollow} link_to text, url, {rel: :nofollow}.merge(link_options)
else else
url url
end end

View File

@@ -19,10 +19,10 @@
<% artist.sorted_urls.each do |url| %> <% artist.sorted_urls.each do |url| %>
<li> <li>
<% if url.is_active %> <% 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?" %> <%= 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 %> <% else %>
<del><%= external_link_to url.url, truncate: 64, strip_scheme: true %></del> <del><%= external_link_to url.url, truncate: 64, strip_scheme: true, link_options: {target: "_blank"} %></del>
<% end %> <% end %>
</li> </li>
<% end %> <% end %>