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.

58 lines
1.4 KiB

8 years ago
8 years ago
  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 [:ar, :fa, :he].include?(I18n.locale)
  20. other_classes
  21. end
  22. def favicon_path
  23. env_suffix = Rails.env.production? ? '' : '-dev'
  24. "/favicon#{env_suffix}.ico"
  25. end
  26. def title
  27. Rails.env.production? ? site_title : "#{site_title} (Dev)"
  28. end
  29. def can?(action, record)
  30. return false if record.nil?
  31. policy(record).public_send("#{action}?")
  32. end
  33. def fa_icon(icon, attributes = {})
  34. class_names = attributes[:class]&.split(' ') || []
  35. class_names << 'fa'
  36. class_names += icon.split(' ').map { |cl| "fa-#{cl}" }
  37. content_tag(:i, nil, attributes.merge(class: class_names.join(' ')))
  38. end
  39. def custom_emoji_tag(custom_emoji)
  40. image_tag(custom_emoji.image.url, class: 'emojione', alt: ":#{custom_emoji.shortcode}:")
  41. end
  42. def opengraph(property, content)
  43. tag(:meta, content: content, property: property)
  44. end
  45. end