diff options
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 18aec6dbe..56207c4bb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -12,6 +12,17 @@ module ApplicationHelper id.start_with?("tag:#{Rails.configuration.x.local_domain}") end + def linkify(status) + mention_hash = {} + status.mentions.each { |m| mention_hash[m.acct] = m } + coder = HTMLEntities.new + + auto_link(coder.encode(status.text), link: :urls, html: { rel: 'nofollow noopener' }).gsub(Account::MENTION_RE) do |m| + account = mention_hash[Account::MENTION_RE.match(m)[1]] + return "#{m.split('@').first}<a href=\"#{url_for_target(account)}\" class=\"mention\">@<span>#{account.acct}</span></a>" + end.html_safe + end + def active_nav_class(path) current_page?(path) ? 'active' : '' end |