2019-10-25 05:50:09 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module AccountsHelper
|
|
|
|
def display_name(account, **options)
|
2022-03-26 10:53:34 +09:00
|
|
|
str = account.display_name.presence || account.username
|
|
|
|
|
2019-10-25 05:50:09 +09:00
|
|
|
if options[:custom_emojify]
|
2022-03-26 10:53:34 +09:00
|
|
|
prerender_custom_emojis(h(str), account.emojis)
|
2019-10-25 05:50:09 +09:00
|
|
|
else
|
2022-03-26 10:53:34 +09:00
|
|
|
str
|
2019-10-25 05:50:09 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def acct(account)
|
|
|
|
if account.local?
|
2020-02-04 02:44:54 +09:00
|
|
|
"@#{account.acct}@#{site_hostname}"
|
2019-10-25 05:50:09 +09:00
|
|
|
else
|
2019-12-31 03:20:43 +09:00
|
|
|
"@#{account.pretty_acct}"
|
2019-10-25 05:50:09 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def account_action_button(account)
|
2022-10-20 21:35:29 +09:00
|
|
|
return if account.memorial? || account.moved?
|
2019-10-25 05:50:09 +09:00
|
|
|
|
2022-10-20 21:35:29 +09:00
|
|
|
link_to ActivityPub::TagManager.instance.url_for(account), class: 'button logo-button', target: '_new' do
|
|
|
|
safe_join([logo_as_symbol, t('accounts.follow')])
|
2019-10-25 05:50:09 +09:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-10-27 20:14:01 +09:00
|
|
|
def hide_followers_count?(account)
|
2023-04-09 18:25:30 +09:00
|
|
|
Setting.hide_followers_count || account.user&.settings&.[]('hide_followers_count')
|
2019-10-27 20:14:01 +09:00
|
|
|
end
|
|
|
|
|
2019-10-25 05:50:09 +09:00
|
|
|
def account_description(account)
|
2019-10-27 20:14:01 +09:00
|
|
|
prepend_stats = [
|
2019-10-25 05:50:09 +09:00
|
|
|
[
|
2021-07-08 04:13:08 +09:00
|
|
|
number_to_human(account.statuses_count, precision: 3, strip_insignificant_zeros: true),
|
2019-10-25 05:50:09 +09:00
|
|
|
I18n.t('accounts.posts', count: account.statuses_count),
|
|
|
|
].join(' '),
|
|
|
|
|
|
|
|
[
|
2021-07-08 04:13:08 +09:00
|
|
|
number_to_human(account.following_count, precision: 3, strip_insignificant_zeros: true),
|
2019-10-25 05:50:09 +09:00
|
|
|
I18n.t('accounts.following', count: account.following_count),
|
|
|
|
].join(' '),
|
2019-10-27 20:14:01 +09:00
|
|
|
]
|
2019-10-25 05:50:09 +09:00
|
|
|
|
2019-10-27 20:14:01 +09:00
|
|
|
unless hide_followers_count?(account)
|
|
|
|
prepend_stats << [
|
2021-07-08 04:13:08 +09:00
|
|
|
number_to_human(account.followers_count, precision: 3, strip_insignificant_zeros: true),
|
2019-10-25 05:50:09 +09:00
|
|
|
I18n.t('accounts.followers', count: account.followers_count),
|
2019-10-27 20:14:01 +09:00
|
|
|
].join(' ')
|
|
|
|
end
|
2019-10-25 05:50:09 +09:00
|
|
|
|
2019-10-27 20:14:01 +09:00
|
|
|
[prepend_stats.join(', '), account.note].join(' · ')
|
2019-10-25 05:50:09 +09:00
|
|
|
end
|
|
|
|
end
|