Sha256: 05ed2cb6bb56ffeea79aac2d7cdca977af0275c315d1f5ca3aa66afa6aabc009

Contents?: true

Size: 1.37 KB

Versions: 19

Compression:

Stored size: 1.37 KB

Contents

module ChaltronHelper

  def ldap_enabled?
    Devise.omniauth_providers.include? :ldap
  end

  #
  # Flash messages
  #
  def bootstrap_class_for(flash_type)
    {
      success: 'alert-success',
      error:   'alert-danger',
      alert:   'alert-warning',
      notice:  'alert-info'
    }[flash_type] || flash_type.to_s
  end

  def flash_message(message, type)
    content_tag(:div, message, class: "alert #{bootstrap_class_for(type)}") do
      content_tag(:strong, I18n.t("chaltron.flash.#{type}") + ': ') +
      message
    end
  end

  def back_link(opts = {})
    klass = opts[:class] || 'btn btn-primary'
    text  = opts[:text] || t('chaltron.common.back')
    ic    = opts[:icon]  || 'arrow-left'

    link_to :back, class: klass do
      icon(ic, text)
    end
  end

  #
  # Badge and label helpers
  #
  def badge(*args)
    badge_label(:badge, *args)
  end

  def tag_label(*args)
    badge_label(:label, *args)
  end

  #
  # Get current revision
  #
  def revision
    @revision || get_revision_number
  end

  private

  def get_revision_number
    version_file = "#{Rails.root}/REVISION"
    if File.exists?(version_file)
      v = IO.read(version_file).strip
      v.blank?? nil : v
    end
  end

  def badge_label(what, value, type = nil)
    klass = [what]
    klass << "#{what}-#{type}" if type.present?
    content_tag :span, value, class: "#{klass.join(' ')}"
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
chaltron-0.3.2 app/helpers/chaltron_helper.rb
chaltron-0.3.1 app/helpers/chaltron_helper.rb
chaltron-0.3.0 app/helpers/chaltron_helper.rb
chaltron-0.2.11 app/helpers/chaltron_helper.rb
chaltron-0.2.10 app/helpers/chaltron_helper.rb
chaltron-0.2.9 app/helpers/chaltron_helper.rb
chaltron-0.2.8 app/helpers/chaltron_helper.rb
chaltron-0.2.7 app/helpers/chaltron_helper.rb
chaltron-0.2.6 app/helpers/chaltron_helper.rb
chaltron-0.2.5 app/helpers/chaltron_helper.rb
chaltron-0.2.4 app/helpers/chaltron_helper.rb
chaltron-0.2.3 app/helpers/chaltron_helper.rb
chaltron-0.2.2 app/helpers/chaltron_helper.rb
chaltron-0.2.1 app/helpers/chaltron_helper.rb
chaltron-0.2.0 app/helpers/chaltron_helper.rb
chaltron-0.1.6 app/helpers/chaltron_helper.rb
chaltron-0.1.5 app/helpers/chaltron_helper.rb
chaltron-0.1.4 app/helpers/chaltron_helper.rb
chaltron-0.1.3 app/helpers/chaltron_helper.rb