Module: Jesus::Helpers
- Included in:
- Server
- Defined in:
- lib/jesus/server/helpers.rb
Instance Method Summary collapse
-
#class_if_current(link) ⇒ Object
Is this menu link the current page ?.
-
#confirm(message = 'Are you sure you want to do this ?') ⇒ Object
A confirmation, to be included in a link.
-
#flash(type, message) ⇒ Object
Defines a flash message.
-
#flash_tag(type) ⇒ Object
The flash message tag.
-
#process_action(process) ⇒ Object
Displays the actions links for a process.
-
#show(page, layout = true) ⇒ Object
Displays an erb page.
-
#tab(name, link) ⇒ Object
The menu link li.
Instance Method Details
#class_if_current(link) ⇒ Object
Is this menu link the current page ?
6 7 8 9 |
# File 'lib/jesus/server/helpers.rb', line 6 def class_if_current(link) link = '^/$' if link == '/' 'class="current"' if request.path_info =~ Regexp.new(link) end |
#confirm(message = 'Are you sure you want to do this ?') ⇒ Object
A confirmation, to be included in a link
32 33 34 |
# File 'lib/jesus/server/helpers.rb', line 32 def confirm(='Are you sure you want to do this ?') return "javascript:return confirm('" + + "');" end |
#flash(type, message) ⇒ Object
Defines a flash message
26 27 28 |
# File 'lib/jesus/server/helpers.rb', line 26 def flash(type, ) session[type] = end |
#flash_tag(type) ⇒ Object
The flash message tag
20 21 22 |
# File 'lib/jesus/server/helpers.rb', line 20 def flash_tag(type) "<div id='flash'>#{session.delete(type)}</div>" unless session[type].nil? end |
#process_action(process) ⇒ Object
Displays the actions links for a process
46 47 48 49 50 51 52 53 54 |
# File 'lib/jesus/server/helpers.rb', line 46 def process_action(process) case process[1][:state] when :up return '<li><a href="/command/stop/' + process[0] + '" onclick="' + confirm + '"><img src="/img/stop.png" alt="Stop Process" /></a></li>' + '<li><a href="/command/restart/' + process[0] + '" onclick="' + confirm + '"><img src="/img/restart.png" alt="Restart Process" /></a></li>' when :unmonitored return '<li><a href="/command/start/' + process[0] + '"><img src="/img/start.png" alt="Start Process" /></a></li>' end end |
#show(page, layout = true) ⇒ Object
Displays an erb page
39 40 41 |
# File 'lib/jesus/server/helpers.rb', line 39 def show(page, layout = true) erb page.to_sym, {:layout => layout} end |
#tab(name, link) ⇒ Object
The menu link li
13 14 15 |
# File 'lib/jesus/server/helpers.rb', line 13 def tab(name, link) "<li #{class_if_current(link)}><a href='#{link}'>#{name}</a></li>" end |