Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#fluentd_ui_logoObject



8
9
10
# File 'app/helpers/application_helper.rb', line 8

def 
  image_tag(ENV["FLUENTD_UI_LOGO"] || "/fluentd-logo-right-text.png")
end

#has_td_agent_system?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'app/helpers/application_helper.rb', line 4

def has_td_agent_system?
  File.exist?("/etc/init.d/td-agent")
end

#icon(classes, inner = nil) ⇒ Object



39
40
41
# File 'app/helpers/application_helper.rb', line 39

def icon(classes, inner=nil)
  %Q!<i class="fa #{classes}">#{inner}</i> !.html_safe
end

#language_menuObject



20
21
22
23
24
25
26
27
28
# File 'app/helpers/application_helper.rb', line 20

def language_menu
  html = ""
  I18n.available_locales.each do |locale|
    text = (locale == current_locale ? icon("fa-check") : "")
    text << language_name(locale)
    html << %Q|<li>#{link_to text , "?lang=#{locale}"}</li>|
  end
  raw html
end

#language_name(locale) ⇒ Object



12
13
14
15
16
17
18
# File 'app/helpers/application_helper.rb', line 12

def language_name(locale)
  # NOTE: these are fixed terms, not i18n-ed
  {
    en: "English",
    ja: "日本語",
  }[locale] || locale
end


30
31
32
33
34
35
36
37
# File 'app/helpers/application_helper.rb', line 30

def link_to_other(text, path)
  if current_page?(path)
    # NOTE: sb-admin set style for element name instead of class name, such as ".nav a". So use "a" element even if it isn't a link.
    (:a, text, class: "current")
  else
    link_to text, path
  end
end

#page_head(head, &block) ⇒ Object



50
51
52
53
54
# File 'app/helpers/application_helper.rb', line 50

def page_head(head, &block)
  content_for(:page_head) do
    head.html_safe + block.try(:call).to_s
  end
end

#page_title(title, &block) ⇒ Object



43
44
45
46
47
48
# File 'app/helpers/application_helper.rb', line 43

def page_title(title, &block)
  content_for(:page_title) do
    title
  end
  page_head(title, &block) unless content_for?(:page_head)
end