logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

application_helper.rb (1496B)


  1. # frozen_string_literal: true
  2. module ApplicationHelper
  3. def active_nav_class(path)
  4. current_page?(path) ? 'active' : ''
  5. end
  6. def active_link_to(label, path, **options)
  7. link_to label, path, options.merge(class: active_nav_class(path))
  8. end
  9. def show_landing_strip?
  10. !user_signed_in? && !single_user_mode?
  11. end
  12. def open_registrations?
  13. Setting.open_registrations
  14. end
  15. def open_deletion?
  16. Setting.open_deletion
  17. end
  18. def add_rtl_body_class(other_classes)
  19. other_classes = "#{other_classes} rtl" if locale_direction == 'rtl'
  20. other_classes
  21. end
  22. def locale_direction
  23. if [:ar, :fa, :he].include?(I18n.locale)
  24. 'rtl'
  25. else
  26. 'ltr'
  27. end
  28. end
  29. def favicon_path
  30. env_suffix = Rails.env.production? ? '' : '-dev'
  31. "/favicon#{env_suffix}.ico"
  32. end
  33. def title
  34. Rails.env.production? ? site_title : "#{site_title} (Dev)"
  35. end
  36. def can?(action, record)
  37. return false if record.nil?
  38. policy(record).public_send("#{action}?")
  39. end
  40. def fa_icon(icon, attributes = {})
  41. class_names = attributes[:class]&.split(' ') || []
  42. class_names << 'fa'
  43. class_names += icon.split(' ').map { |cl| "fa-#{cl}" }
  44. content_tag(:i, nil, attributes.merge(class: class_names.join(' ')))
  45. end
  46. def custom_emoji_tag(custom_emoji)
  47. image_tag(custom_emoji.image.url, class: 'emojione', alt: ":#{custom_emoji.shortcode}:")
  48. end
  49. def opengraph(property, content)
  50. tag(:meta, content: content, property: property)
  51. end
  52. end