Mark links in notes and fetch source data box as external.
This commit is contained in:
@@ -78,8 +78,7 @@ module ApplicationHelper
|
||||
time_tag(time.strftime("%Y-%m-%d %H:%M"), time)
|
||||
end
|
||||
|
||||
def external_link_to(url, truncate: nil, strip: false, **link_options)
|
||||
text = url
|
||||
def external_link_to(url, text = url, truncate: nil, strip: false, **link_options)
|
||||
text = text.gsub(%r!\Ahttps?://!i, "") if strip == :scheme
|
||||
text = text.gsub(%r!\Ahttps?://(?:www\.)?!i, "") if strip == :subdomain
|
||||
text = text.truncate(truncate) if truncate
|
||||
|
||||
@@ -61,7 +61,7 @@ module NoteSanitizer
|
||||
:elements => ALLOWED_ELEMENTS,
|
||||
:attributes => ALLOWED_ATTRIBUTES,
|
||||
:add_attributes => {
|
||||
"a" => { "rel" => "nofollow" },
|
||||
"a" => { "rel" => "external noreferrer nofollow" },
|
||||
},
|
||||
:protocols => {
|
||||
"a" => {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<% if @source.artist_name.blank? %>
|
||||
<em>None</em>
|
||||
<% else %>
|
||||
<%= link_to @source.artist_name, @source.profile_url, id: "source-info-artist-profile" %>
|
||||
<%= external_link_to @source.profile_url, @source.artist_name, id: "source-info-artist-profile" %>
|
||||
|
||||
<% if @source.artists.empty? %>
|
||||
(<%= link_to "Create new artist", new_artist_path(artist: { source: @source.canonical_url }), id: "source-info-create-new-artist" %>)
|
||||
@@ -35,7 +35,7 @@
|
||||
<% else %>
|
||||
<ul>
|
||||
<% @source.tags.each do |tag, href| %>
|
||||
<li><%= link_to tag, href, rel: :nofollow %></li>
|
||||
<li><%= external_link_to href, tag %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user