Module: ResqueWeb::ApplicationHelper
- Defined in:
- app/helpers/resque_web/application_helper.rb
Constant Summary collapse
- PER_PAGE =
20
Instance Attribute Summary collapse
-
#subtabs ⇒ Object
readonly
Returns the value of attribute subtabs.
Instance Method Summary collapse
- #current_subtab?(name) ⇒ Boolean
- #current_tab ⇒ Object
- #current_tab?(name) ⇒ Boolean
- #pagination(options = {}) ⇒ Object
- #poll(polling = false) ⇒ Object
- #subtab(name) ⇒ Object
- #tab(name, path) ⇒ Object
- #tabs ⇒ Object
Instance Attribute Details
#subtabs ⇒ Object (readonly)
Returns the value of attribute subtabs.
28 29 30 |
# File 'app/helpers/resque_web/application_helper.rb', line 28 def subtabs @subtabs end |
Instance Method Details
#current_subtab?(name) ⇒ Boolean
34 35 36 |
# File 'app/helpers/resque_web/application_helper.rb', line 34 def current_subtab?(name) params[:id] == name.to_s end |
#current_tab ⇒ Object
20 21 22 |
# File 'app/helpers/resque_web/application_helper.rb', line 20 def current_tab params[:controller].gsub(/resque_web\//, "#{root_path}") end |
#current_tab?(name) ⇒ Boolean
24 25 26 |
# File 'app/helpers/resque_web/application_helper.rb', line 24 def current_tab?(name) params[:controller] == name.to_s end |
#pagination(options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/helpers/resque_web/application_helper.rb', line 38 def pagination( = {}) start = [:start] || 1 per_page = [:per_page] || PER_PAGE total = [:total] || 0 return if total < per_page markup = "" if start - per_page >= 0 markup << link_to(raw("« less"), params.merge(:start => start - per_page), :class => 'btn less') end if start + per_page <= total markup << link_to(raw("more »"), params.merge(:start => start + per_page), :class => 'btn more') end content_tag :p, raw(markup), :class => 'pagination' end |
#poll(polling = false) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'app/helpers/resque_web/application_helper.rb', line 56 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 content_tag :p, text, :class => 'poll' end |
#subtab(name) ⇒ Object
30 31 32 |
# File 'app/helpers/resque_web/application_helper.rb', line 30 def subtab(name) content_tag :li, link_to(name, "#{current_tab}/#{name}"), :class => current_subtab?(name) ? "current" : nil end |
#tab(name, path) ⇒ Object
16 17 18 |
# File 'app/helpers/resque_web/application_helper.rb', line 16 def tab(name,path) content_tag :li, link_to(name.capitalize, path), :class => current_tab?(name) ? "active" : nil end |
#tabs ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/resque_web/application_helper.rb', line 6 def tabs {'overview' => overview_path, 'working' => working_index_path, 'failures' => failures_path, 'queues' => queues_path, 'workers' => workers_path, 'stats' => stats_path } end |