Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#fluentd_status_iconObject



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

def fluentd_status_icon
  return unless Fluentd.instance
  Fluentd.instance.agent.running? ? icon('fa-circle running') : icon('fa-circle stopped')
end

#fluentd_status_messageObject



17
18
19
20
# File 'app/helpers/application_helper.rb', line 17

def fluentd_status_message
  return unless Fluentd.instance
  Fluentd.instance.agent.running? ? I18n.t('messages.fluentd_status_running') : I18n.t('messages.fluentd_status_stopped')
end

#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") || File.exist?("/opt/td-agent/embedded/bin/fluentd")
end

#icon(classes, inner = nil) ⇒ Object



49
50
51
# File 'app/helpers/application_helper.rb', line 49

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

#language_menuObject



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

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



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

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


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

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



60
61
62
63
64
# File 'app/helpers/application_helper.rb', line 60

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



53
54
55
56
57
58
# File 'app/helpers/application_helper.rb', line 53

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