You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
991 B

8 years ago
8 years ago
  1. module ApplicationHelper
  2. def unique_tag(date, id, type)
  3. "tag:#{Rails.configuration.x.local_domain},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
  4. end
  5. def unique_tag_to_local_id(tag, expected_type)
  6. matches = Regexp.new("objectId=([\\d]+):objectType=#{expected_type}").match(tag)
  7. return matches[1] unless matches.nil?
  8. end
  9. def local_id?(id)
  10. id.start_with?("tag:#{Rails.configuration.x.local_domain}")
  11. end
  12. def linkify(status)
  13. mention_hash = {}
  14. status.mentions.each { |m| mention_hash[m.acct] = m }
  15. coder = HTMLEntities.new
  16. auto_link(coder.encode(status.text), link: :urls, html: { rel: 'nofollow noopener' }).gsub(Account::MENTION_RE) do |m|
  17. account = mention_hash[Account::MENTION_RE.match(m)[1]]
  18. "#{m.split('@').first}<a href=\"#{url_for_target(account)}\" class=\"mention\">@<span>#{account.acct}</span></a>"
  19. end.html_safe
  20. end
  21. def active_nav_class(path)
  22. current_page?(path) ? 'active' : ''
  23. end
  24. end