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