The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

107 lines
3.9 KiB

  1. # frozen_string_literal: true
  2. module AccountsHelper
  3. def display_name(account, **options)
  4. if options[:custom_emojify]
  5. Formatter.instance.format_display_name(account, options)
  6. else
  7. account.display_name.presence || account.username
  8. end
  9. end
  10. def acct(account)
  11. if account.local?
  12. "@#{account.acct}@#{Rails.configuration.x.local_domain}"
  13. else
  14. "@#{account.acct}"
  15. end
  16. end
  17. def account_action_button(account)
  18. if user_signed_in?
  19. if account.id == current_user.account_id
  20. link_to settings_profile_url, class: 'button logo-button' do
  21. safe_join([svg_logo, t('settings.edit_profile')])
  22. end
  23. elsif current_account.following?(account) || current_account.requested?(account)
  24. link_to account_unfollow_path(account), class: 'button logo-button button--destructive', data: { method: :post } do
  25. safe_join([svg_logo, t('accounts.unfollow')])
  26. end
  27. elsif !(account.memorial? || account.moved?)
  28. link_to account_follow_path(account), class: "button logo-button#{account.blocking?(current_account) ? ' disabled' : ''}", data: { method: :post } do
  29. safe_join([svg_logo, t('accounts.follow')])
  30. end
  31. end
  32. elsif !(account.memorial? || account.moved?)
  33. link_to account_remote_follow_path(account), class: 'button logo-button modal-button', target: '_new' do
  34. safe_join([svg_logo, t('accounts.follow')])
  35. end
  36. end
  37. end
  38. def minimal_account_action_button(account)
  39. if user_signed_in?
  40. return if account.id == current_user.account_id
  41. if current_account.following?(account) || current_account.requested?(account)
  42. link_to account_unfollow_path(account), class: 'icon-button active', data: { method: :post }, title: t('accounts.unfollow') do
  43. fa_icon('user-times fw')
  44. end
  45. elsif !(account.memorial? || account.moved?)
  46. link_to account_follow_path(account), class: "icon-button#{account.blocking?(current_account) ? ' disabled' : ''}", data: { method: :post }, title: t('accounts.follow') do
  47. fa_icon('user-plus fw')
  48. end
  49. end
  50. elsif !(account.memorial? || account.moved?)
  51. link_to account_remote_follow_path(account), class: 'icon-button modal-button', target: '_new', title: t('accounts.follow') do
  52. fa_icon('user-plus fw')
  53. end
  54. end
  55. end
  56. def account_badge(account, all: false)
  57. if account.bot?
  58. content_tag(:div, content_tag(:div, t('accounts.roles.bot'), class: 'account-role bot'), class: 'roles')
  59. elsif (Setting.show_staff_badge && account.user_staff?) || all
  60. content_tag(:div, class: 'roles') do
  61. if all && !account.user_staff?
  62. content_tag(:div, t('admin.accounts.roles.user'), class: 'account-role')
  63. elsif account.user_admin?
  64. content_tag(:div, t('accounts.roles.admin'), class: 'account-role admin')
  65. elsif account.user_moderator?
  66. content_tag(:div, t('accounts.roles.moderator'), class: 'account-role moderator')
  67. end
  68. end
  69. end
  70. end
  71. def account_description(account)
  72. prepend_str = [
  73. [
  74. number_to_human(account.statuses_count, strip_insignificant_zeros: true),
  75. I18n.t('accounts.posts', count: account.statuses_count),
  76. ].join(' '),
  77. [
  78. number_to_human(account.following_count, strip_insignificant_zeros: true),
  79. I18n.t('accounts.following', count: account.following_count),
  80. ].join(' '),
  81. [
  82. number_to_human(account.followers_count, strip_insignificant_zeros: true),
  83. I18n.t('accounts.followers', count: account.followers_count),
  84. ].join(' '),
  85. ].join(', ')
  86. [prepend_str, account.note].join(' · ')
  87. end
  88. def svg_logo
  89. content_tag(:svg, tag(:use, 'xlink:href' => '#mastodon-svg-logo'), 'viewBox' => '0 0 216.4144 232.00976')
  90. end
  91. def svg_logo_full
  92. content_tag(:svg, tag(:use, 'xlink:href' => '#mastodon-svg-logo-full'), 'viewBox' => '0 0 713.35878 175.8678')
  93. end
  94. end