home_helper.rb 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # frozen_string_literal: true
  2. module HomeHelper
  3. def default_props
  4. {
  5. locale: I18n.locale,
  6. }
  7. end
  8. def account_link_to(account, button = '', path: nil)
  9. content_tag(:div, class: 'account account--minimal') do
  10. content_tag(:div, class: 'account__wrapper') do
  11. section = if account.nil?
  12. content_tag(:div, class: 'account__display-name') do
  13. content_tag(:div, class: 'account__avatar-wrapper') do
  14. image_tag(full_asset_url('avatars/original/missing.png', skip_pipeline: true), class: 'account__avatar')
  15. end +
  16. content_tag(:span, class: 'display-name') do
  17. content_tag(:strong, t('about.contact_missing')) +
  18. content_tag(:span, t('about.contact_unavailable'), class: 'display-name__account')
  19. end
  20. end
  21. else
  22. link_to(path || ActivityPub::TagManager.instance.url_for(account), class: 'account__display-name') do
  23. content_tag(:div, class: 'account__avatar-wrapper') do
  24. image_tag(full_asset_url(current_account&.user&.setting_auto_play_gif ? account.avatar_original_url : account.avatar_static_url), class: 'account__avatar', width: 46, height: 46)
  25. end +
  26. content_tag(:span, class: 'display-name') do
  27. content_tag(:bdi) do
  28. content_tag(:strong, display_name(account, custom_emojify: true), class: 'display-name__html emojify')
  29. end +
  30. content_tag(:span, "@#{account.acct}", class: 'display-name__account')
  31. end
  32. end
  33. end
  34. section + button
  35. end
  36. end
  37. end
  38. def obscured_counter(count)
  39. if count <= 0
  40. '0'
  41. elsif count == 1
  42. '1'
  43. else
  44. '1+'
  45. end
  46. end
  47. def custom_field_classes(field)
  48. if field.verified?
  49. 'verified'
  50. else
  51. 'emojify'
  52. end
  53. end
  54. def sign_up_message
  55. if closed_registrations?
  56. t('auth.registration_closed', instance: site_hostname)
  57. elsif open_registrations?
  58. t('auth.register')
  59. elsif approved_registrations?
  60. t('auth.apply_for_account')
  61. end
  62. end
  63. end