summaryrefslogtreecommitdiff
path: root/app/helpers/core_helper.rb
blob: 05efb95149933649c6732b6ceef89c21f0e4df93 (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
#
# Misc. helpers needed throughout.
#
module CoreHelper

  #
  # insert common buttons (download, login, etc)
  #
  def home_page_buttons
    render 'common/home_page_buttons'
  end

  #
  # returns true if the configured service levels contain a level with a price attached
  #
  def paid_service_level?
    APP_CONFIG[:service_levels].present? && APP_CONFIG[:service_levels].detect{|k,v| v['rate'].present?}
  end

  #
  # a bunch of links to the different languages that are available.
  #
  def locales_links
    CommonLanguages.available.collect { |lang|
      link_to(lang.name,
        {:action => params[:action], :controller => params[:controller], :locale => lang.code},
        {:class => (lang.code == I18n.locale ? 'locale active' : 'locale')}
      )
    }.join(" ").html_safe
  end

  #
  # displays the datetime as time ago in words,
  # but has the absolute time in a tooltip.
  #
  def simple_date(datetime)
    content_tag :span, time_ago_in_words(datetime), :title => datetime.to_s, :class => 'date'
  end

end