summaryrefslogtreecommitdiff
path: root/app/helpers/application_helper.rb
blob: 23b2752aaa0aa5e0f6f8ecf7fe5ff2981aba80c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
module ApplicationHelper

  #
  # determine title for the page
  #
  def html_title
    if content_for?(:title)
      yield(:title)
    elsif @title
      [@title, ' - ', APP_CONFIG[:domain]].join
    else
      APP_CONFIG[:domain]
    end
  end

  #
  # markup for bootstrap icon
  #
  # http://twitter.github.io/bootstrap/base-css.html#icons
  #
  def icon(name, color=nil)
    "<span class=\"glyphicon glyphicon-#{name} #{color_class(color)}\"></span> ".html_safe
  end

  def big_icon(name, color=nil)
    "<i class=\"big-icon-#{name} #{color_class(color)}\"></i> ".html_safe
  end

  def huge_icon(name, color=nil)
    "<i class=\"huge-icon-#{name} #{color_class(color)}\"></i> ".html_safe
  end

  def color_class(color)
    if color.nil?
      nil
    elsif color == :black
      'icon-black'
    elsif color == :white
      'icon-white'
    end
  end

  # fairly strict sanitation for flash messages
  def format_flash(msg)
    sanitize(msg, tags: %w(em strong b br), attributes: [])
  end

end