Module: ResqueWeb::ApplicationHelper

Defined in:
app/helpers/resque_web/application_helper.rb

Constant Summary collapse

PER_PAGE =
20

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#subtabsObject (readonly)

Returns the value of attribute subtabs.



32
33
34
# File 'app/helpers/resque_web/application_helper.rb', line 32

def subtabs
  @subtabs
end

Instance Method Details

#current_subtab?(name) ⇒ Boolean

Returns:

  • (Boolean)


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

def current_subtab?(name)
  params[:id] == name.to_s
end

#current_tabObject



24
25
26
# File 'app/helpers/resque_web/application_helper.rb', line 24

def current_tab
  params[:controller].gsub(/resque_web\//, "#{root_path}")
end

#current_tab?(name) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/helpers/resque_web/application_helper.rb', line 28

def current_tab?(name)
  params[:controller] == name.to_s
end

#pagination(options = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/helpers/resque_web/application_helper.rb', line 42

def pagination(options = {})
  start    = options[:start] || 1
  per_page = options[:per_page] || PER_PAGE
  total    = options[:total] || 0
  return if total < per_page

  markup = ""
  if start - per_page >= 0
    markup << link_to(raw("&laquo; less"), params.merge(:start => start - per_page), :class => 'btn less')
  end

  if start + per_page <= total
    markup << link_to(raw("more &raquo;"), params.merge(:start => start + per_page), :class => 'btn more')
  end

   :p, raw(markup), :class => 'pagination'
end

#poll(polling = false) ⇒ Object



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

def poll(polling=false)
  if polling
    text = "Last Updated: #{Time.now.strftime("%H:%M:%S")}".html_safe
  else
    text = "<a href='#{h(request.path)}' rel='poll'>Live Poll</a>".html_safe
  end
   :p, text, :class => 'poll'
end

#subtab(name) ⇒ Object



34
35
36
# File 'app/helpers/resque_web/application_helper.rb', line 34

def subtab(name)
   :li, link_to(name, "#{current_tab}/#{name}"), :class => current_subtab?(name) ? "current" : nil
end

#tab(name, path) ⇒ Object



20
21
22
# File 'app/helpers/resque_web/application_helper.rb', line 20

def tab(name,path)
   :li, link_to(name.capitalize, path), :class => current_tab?(name) ? "active" : nil
end

#tabsObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/resque_web/application_helper.rb', line 6

def tabs
  t = {'overview' => ResqueWeb::Engine.app.url_helpers.overview_path,
   'working'  => ResqueWeb::Engine.app.url_helpers.working_index_path,
   'failures' => ResqueWeb::Engine.app.url_helpers.failures_path,
   'queues' => ResqueWeb::Engine.app.url_helpers.queues_path,
   'workers' => ResqueWeb::Engine.app.url_helpers.workers_path,
   'stats' => ResqueWeb::Engine.app.url_helpers.stats_path
  }
  ResqueWeb::Plugins.plugins.each do |p|
    p.tabs.each { |tab| t.merge!(tab) }
  end
  t
end