settings_helper.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # frozen_string_literal: true
  2. module SettingsHelper
  3. def filterable_languages
  4. LanguagesHelper.sorted_locale_keys(LanguagesHelper::SUPPORTED_LOCALES.keys)
  5. end
  6. def ui_languages
  7. LanguagesHelper.sorted_locale_keys(I18n.available_locales)
  8. end
  9. def featured_tags_hint(recently_used_tags)
  10. recently_used_tags.present? &&
  11. safe_join(
  12. [
  13. t('simple_form.hints.featured_tag.name'),
  14. safe_join(
  15. links_for_featured_tags(recently_used_tags),
  16. ', '
  17. ),
  18. ],
  19. ' '
  20. )
  21. end
  22. def session_device_icon(session)
  23. device = session.detection.device
  24. if device.mobile?
  25. 'smartphone'
  26. elsif device.tablet?
  27. 'tablet'
  28. else
  29. 'desktop_mac'
  30. end
  31. end
  32. def compact_account_link_to(account)
  33. return if account.nil?
  34. link_to ActivityPub::TagManager.instance.url_for(account), class: 'name-tag', title: account.acct do
  35. safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
  36. end
  37. end
  38. private
  39. def links_for_featured_tags(tags)
  40. tags.map { |tag| post_link_to_featured_tag(tag) }
  41. end
  42. def post_link_to_featured_tag(tag)
  43. link_to(
  44. "##{tag.display_name}",
  45. settings_featured_tags_path(featured_tag: { name: tag.name }),
  46. method: :post
  47. )
  48. end
  49. end