accounts_helper.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # frozen_string_literal: true
  2. module AccountsHelper
  3. def display_name(account, **options)
  4. str = account.display_name.presence || account.username
  5. if options[:custom_emojify]
  6. prerender_custom_emojis(h(str), account.emojis)
  7. else
  8. str
  9. end
  10. end
  11. def acct(account)
  12. if account.local?
  13. "@#{account.acct}@#{site_hostname}"
  14. else
  15. "@#{account.pretty_acct}"
  16. end
  17. end
  18. def account_action_button(account)
  19. return if account.memorial? || account.moved?
  20. link_to ActivityPub::TagManager.instance.url_for(account), class: 'button logo-button', target: '_new' do
  21. safe_join([logo_as_symbol, t('accounts.follow')])
  22. end
  23. end
  24. def account_formatted_stat(value)
  25. number_to_human(value, precision: 3, strip_insignificant_zeros: true)
  26. end
  27. def account_description(account)
  28. prepend_str = [
  29. [
  30. account_formatted_stat(account.statuses_count),
  31. I18n.t('accounts.posts', count: account.statuses_count),
  32. ].join(' '),
  33. [
  34. account_formatted_stat(account.following_count),
  35. I18n.t('accounts.following', count: account.following_count),
  36. ].join(' '),
  37. [
  38. account_formatted_stat(account.followers_count),
  39. I18n.t('accounts.followers', count: account.followers_count),
  40. ].join(' '),
  41. ].join(', ')
  42. [prepend_str, account.note].join(' · ')
  43. end
  44. end