rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
- rails_autolink (1.1.6)
- rails (> 3.1)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (5.0.1)
rails (~> 5.0.1.0)
rails-settings-cached
rails_12factor
- rails_autolink
react-rails
redis (~> 3.2)
redis-rails
html = encode(account.note)
html = link_urls(html)
+ html = link_hashtags(html)
html.html_safe # rubocop:disable Rails/OutputSafety
end
end
def link_urls(html)
- auto_link(html, link: :urls, html: { rel: 'nofollow noopener', target: '_blank' }) do |text|
- truncate(text.gsub(/\Ahttps?:\/\/(www\.)?/, ''), length: 30)
+ html.gsub(URI.regexp(%w(http https))) do |match|
+ link_html(match)
end
end
end
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>"
+ end
+
def hashtag_html(match)
prefix, affix = match.split('#')
"#{prefix}<a href=\"#{tag_url(affix.downcase)}\" class=\"mention hashtag\">#<span>#{affix}</span></a>"