Module: Perus::Server::Helpers
- Included in:
- Form
- Defined in:
- lib/perus/server/helpers.rb
Instance Method Summary collapse
- #clean_arrows(text) ⇒ Object
- #command_actions ⇒ Object
- #command_metrics ⇒ Object
- #escape_quotes(text) ⇒ Object
- #load_site_information ⇒ Object
- #nav_item(path, name, li = true) ⇒ Object
- #url_prefix ⇒ Object
Instance Method Details
#clean_arrows(text) ⇒ Object
38 39 40 |
# File 'lib/perus/server/helpers.rb', line 38 def clean_arrows(text) text.gsub('<', '<').gsub('>', '>') end |
#command_actions ⇒ Object
28 29 30 31 |
# File 'lib/perus/server/helpers.rb', line 28 def command_actions commands = Perus::Pinger::Command.subclasses.reject(&:metric?) commands.reject(&:abstract?) end |
#command_metrics ⇒ Object
33 34 35 36 |
# File 'lib/perus/server/helpers.rb', line 33 def command_metrics metrics = Perus::Pinger::Command.subclasses.select(&:metric?) metrics.reject(&:abstract?) end |
#escape_quotes(text) ⇒ Object
42 43 44 |
# File 'lib/perus/server/helpers.rb', line 42 def escape_quotes(text) text.to_s.gsub('"', '"') end |
#load_site_information ⇒ Object
3 4 5 6 |
# File 'lib/perus/server/helpers.rb', line 3 def load_site_information @site_name = Server..site_name @groups = Group.all end |
#nav_item(path, name, li = true) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/perus/server/helpers.rb', line 8 def nav_item(path, name, li = true) # when hosted behind a fronting server such as nginx, path_info # will start with '/' not url_prefix adjusted_path = path if path.index(url_prefix) == 0 adjusted_path = path.sub(url_prefix, '/') end # admin links are highlighted for sub pages as well as their own # top level page. e.g 'groups' matches '/groups/1' if adjusted_path.start_with?('/admin/') klass = request.path_info.start_with?(adjusted_path) ? 'selected' : '' else klass = request.path_info == adjusted_path ? 'selected' : '' end anchor = "<a class=\"#{klass}\" href=\"#{path}\">#{name}</a>" li ? "<li>#{anchor}</li>" : anchor end |
#url_prefix ⇒ Object
46 47 48 |
# File 'lib/perus/server/helpers.rb', line 46 def url_prefix Server..url_prefix end |