1
0
Fork 0
dokkan-data-rails/app/helpers/application_helper.rb

49 lines
1,009 B
Ruby
Raw Permalink Normal View History

2015-09-29 19:02:43 -04:00
module ApplicationHelper
2015-10-06 11:30:39 -04:00
def nav_link_to(text, path)
options = current_controller?(path) ? { class: 'active' } : {}
content_tag(:li, options) { link_to text, path }
end
def bootstrap_class_for(flash_type)
bootstrap_classes[flash_type] || flash_type.to_s
end
def glyph(icon, options = {})
options = options.reverse_merge(default_glyph_options)
classes = options[:color] + " " + options[:classes]
content_tag(:i, class: "glyphicon glyphicon-#{icon} " + classes) {}
end
2015-10-06 13:55:12 -04:00
def login_path(provider)
"/auth/#{provider.to_s}"
end
2015-10-07 16:28:31 -04:00
def page_title
2015-10-08 21:52:03 -04:00
controller_name.to_s.humanize.titleize
2015-10-07 16:28:31 -04:00
end
2015-10-06 11:30:39 -04:00
private
def bootstrap_classes
{
'alert' => 'alert-warning',
'error' => 'alert-danger',
'notice' => 'alert-info',
'success' => 'alert-success'
}
end
def default_glyph_options
{
:color => '',
:classes => ''
}
end
def current_controller?(path)
path.split('/')[1] == params[:controller]
2015-10-01 11:56:40 -04:00
end
2015-09-29 19:02:43 -04:00
end