闭社主体 forked from https://github.com/tootsuite/mastodon
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.

59 lines
2.2 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 || 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(#{account.avatar.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. end