settings_helper.rb 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. safe_join(
  11. [
  12. t('simple_form.hints.featured_tag.name'),
  13. safe_join(
  14. links_for_featured_tags(recently_used_tags),
  15. ', '
  16. ),
  17. ],
  18. ' '
  19. )
  20. end
  21. def session_device_icon(session)
  22. device = session.detection.device
  23. if device.mobile?
  24. 'mobile'
  25. elsif device.tablet?
  26. 'tablet'
  27. else
  28. 'desktop'
  29. end
  30. end
  31. def compact_account_link_to(account)
  32. return if account.nil?
  33. link_to ActivityPub::TagManager.instance.url_for(account), class: 'name-tag', title: account.acct do
  34. safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: '', class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
  35. end
  36. end
  37. private
  38. def links_for_featured_tags(tags)
  39. tags.map { |tag| post_link_to_featured_tag(tag) }
  40. end
  41. def post_link_to_featured_tag(tag)
  42. link_to(
  43. "##{tag.display_name}",
  44. settings_featured_tags_path(featured_tag: { name: tag.name }),
  45. method: :post
  46. )
  47. end
  48. end