Module: ApplicationHelper

Defined in:
app/helpers/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#add_javascript_pack_tag(name, **options) ⇒ Object



56
57
58
59
60
# File 'app/helpers/application_helper.rb', line 56

def add_javascript_pack_tag(name, **options)
  content_for(:additional_javascript_pack_tag) do
    javascript_pack_tag(name, **options)
  end
end

#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



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_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


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

def link_to_other(text, path, **options)
  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, class: "nav-link"
  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