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.

77 lines
2.7 KiB

  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 = '', size: 36, path: nil)
  9. content_tag(:div, class: 'account') 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. content_tag(:div, '', class: 'account__avatar', style: "width: #{size}px; height: #{size}px; background-size: #{size}px #{size}px; background-image: url(#{full_asset_url('avatars/original/missing.png', skip_pipeline: true)})")
  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. content_tag(:div, '', class: 'account__avatar', style: "width: #{size}px; height: #{size}px; background-size: #{size}px #{size}px; background-image: url(#{full_asset_url(current_account&.user&.setting_auto_play_gif ? account.avatar_original_url : account.avatar_static_url)})")
  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 optional_link_to(condition, path, options = {}, &block)
  55. if condition
  56. link_to(path, options, &block)
  57. else
  58. content_tag(:div, &block)
  59. end
  60. end
  61. def sign_up_message
  62. if closed_registrations?
  63. t('auth.registration_closed', instance: site_hostname)
  64. elsif open_registrations?
  65. t('auth.register')
  66. elsif approved_registrations?
  67. t('auth.apply_for_account')
  68. end
  69. end
  70. end