accounts_helper.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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_description(account)
  25. prepend_str = [
  26. [
  27. number_to_human(account.statuses_count, precision: 3, strip_insignificant_zeros: true),
  28. I18n.t('accounts.posts', count: account.statuses_count),
  29. ].join(' '),
  30. [
  31. number_to_human(account.following_count, precision: 3, strip_insignificant_zeros: true),
  32. I18n.t('accounts.following', count: account.following_count),
  33. ].join(' '),
  34. [
  35. number_to_human(account.followers_count, precision: 3, strip_insignificant_zeros: true),
  36. I18n.t('accounts.followers', count: account.followers_count),
  37. ].join(' '),
  38. ].join(', ')
  39. [prepend_str, account.note].join(' · ')
  40. end
  41. end