about summary refs log tree commit diff
path: root/app/lib/formatter.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-01-24 17:05:44 +0100
committerEugen Rochko <eugen@zeonfederated.com>2017-01-24 17:05:44 +0100
commit80cefd5b3cd9c8efa435f684a33fe1562696b74a (patch)
treedd3eab3219fb7c4757c8d67ae5178b43f8ec075b /app/lib/formatter.rb
parentb06a375ee49e80279b1a9529d1ca892548e55fc7 (diff)
Fix #204, fix #515 - URL truncating is now a style so copypasting is not
affected, replaced onClick handler with onMouseUp/Down to detect text
selection not trigger onClick handler then
Diffstat (limited to 'app/lib/formatter.rb')
-rw-r--r--app/lib/formatter.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 3565611bc..1fa5b83fb 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -65,8 +65,11 @@ class Formatter
   end
 
   def link_html(url)
-    link_text = truncate(url.gsub(/\Ahttps?:\/\/(www\.)?/, ''), length: 30)
-    "<a rel=\"nofollow noopener\" target=\"_blank\" href=\"#{url}\">#{link_text}</a>"
+    prefix = url.match(/\Ahttps?:\/\/(www\.)?/).to_s
+    text   = url[prefix.length, 30]
+    suffix = url[prefix.length + 30..-1]
+
+    "<a rel=\"nofollow noopener\" target=\"_blank\" href=\"#{url}\"><span class=\"invisible\">#{prefix}</span><span class=\"ellipsis\">#{text}</span><span class=\"invisible\">#{suffix}</span></a>"
   end
 
   def hashtag_html(match)