truncate urls on display on post replacements page #3322

This commit is contained in:
r888888888
2017-10-09 16:59:56 -07:00
parent 0bb2dae5f6
commit 51867a8c64
2 changed files with 10 additions and 4 deletions

View File

@@ -93,9 +93,15 @@ module ApplicationHelper
time_tag(time.strftime("%Y-%m-%d %H:%M"), time)
end
def external_link_to(url)
def external_link_to(url, options = {})
if options[:truncate]
text = truncate(url, length: options[:truncate])
else
text = url
end
if url =~ %r!\Ahttps?://!i
link_to url, url, {rel: :nofollow}
link_to text, url, {rel: :nofollow}
else
url
end

View File

@@ -25,11 +25,11 @@
<td>
<dl>
<dt>Original Source</dt>
<dd><%= external_link_to post_replacement.original_url %></dd>
<dd><%= external_link_to post_replacement.original_url, truncate: 64 %></dd>
<dt>Replacement Source</dt>
<dd>
<% if post_replacement.replacement_url.present? %>
<%= external_link_to post_replacement.replacement_url %>
<%= external_link_to post_replacement.replacement_url, truncate: 64 %>
<% else %>
<em>file</em>
<% end %>