settings_helper.rb 1020 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. module SettingsHelper
  3. def filterable_languages
  4. LanguagesHelper::SUPPORTED_LOCALES.keys
  5. end
  6. def hash_to_object(hash)
  7. HashObject.new(hash)
  8. end
  9. def session_device_icon(session)
  10. device = session.detection.device
  11. if device.mobile?
  12. 'mobile'
  13. elsif device.tablet?
  14. 'tablet'
  15. else
  16. 'desktop'
  17. end
  18. end
  19. def compact_account_link_to(account)
  20. return if account.nil?
  21. link_to ActivityPub::TagManager.instance.url_for(account), class: 'name-tag', title: account.acct do
  22. safe_join([image_tag(account.avatar.url, width: 15, height: 15, alt: display_name(account), class: 'avatar'), content_tag(:span, account.acct, class: 'username')], ' ')
  23. end
  24. end
  25. def picture_hint(hint, picture)
  26. if picture.original_filename.nil?
  27. hint
  28. else
  29. link = link_to t('generic.delete'), settings_profile_picture_path(picture.name.to_s), data: { method: :delete }
  30. safe_join([hint, link], '<br/>'.html_safe)
  31. end
  32. end
  33. end