Module: JhubertCommon::ViewHelpers

Defined in:
lib/jhubert_common/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#analytics(account_key = nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/jhubert_common/view_helpers.rb', line 7

def analytics( = nil)
  return unless Rails.env.production?
  html = "  <script type=\"text/javascript\">\n\n    var _gaq = _gaq || [];\n    _gaq.push(['_setAccount', '\#{account_key}']);\n    _gaq.push(['_trackPageview']);\n\n    (function() {\n      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n    })();\n\n  </script>\n"
  return html.html_safe    
end

#flashes(*keys) ⇒ Object



27
28
29
30
31
# File 'lib/jhubert_common/view_helpers.rb', line 27

def flashes(*keys)
  keys.collect do |key| 
    (:div, flash[key], { :class => "alert alert-#{key == :notice ? 'info' : key}" }, false) if flash[key]
  end.join.html_safe
end


3
4
5
# File 'lib/jhubert_common/view_helpers.rb', line 3

def link_to_with_class(label, path, class_name = 'current')
  ('li', link_to(label, path, :class => current_page?(path) ? class_name : ''), :class => current_page?(path) ? class_name : '' )
end

#utc_date(date) ⇒ Object



33
34
35
# File 'lib/jhubert_common/view_helpers.rb', line 33

def utc_date(date)
  raw %Q(<time class="utc-date" title="#{date}">#{date}</time>)
end