Module: Navigation
- Included in:
- SqsWeb
- Defined in:
- lib/sqs_web/application/navigation.rb
Instance Method Summary collapse
- #csrf_token ⇒ Object
- #csrf_token_tag ⇒ Object
- #h(text) ⇒ Object
- #partial(template, local_vars = {}) ⇒ Object
- #path_prefix ⇒ Object
- #tabs ⇒ Object
- #url_path(*path_parts) ⇒ Object (also: #u)
Instance Method Details
#csrf_token ⇒ Object
23 24 25 26 |
# File 'lib/sqs_web/application/navigation.rb', line 23 def csrf_token # Set up by Rack::Protection session[:csrf] end |
#csrf_token_tag ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/sqs_web/application/navigation.rb', line 28 def csrf_token_tag # If csrf_token is nil, and we submit a blank string authenticity_token # param, Rack::Protection will fail. if csrf_token "<input type='hidden' name='authenticity_token' value='#{h csrf_token}'>" end end |
#h(text) ⇒ Object
8 9 10 |
# File 'lib/sqs_web/application/navigation.rb', line 8 def h(text) Rack::Utils.escape_html(text) end |
#partial(template, local_vars = {}) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/sqs_web/application/navigation.rb', line 36 def partial(template, local_vars = {}) @partial = true erb(template.to_sym, {:layout => false}, local_vars) ensure @partial = false end |
#path_prefix ⇒ Object
12 13 14 |
# File 'lib/sqs_web/application/navigation.rb', line 12 def path_prefix request.env['SCRIPT_NAME'] end |
#tabs ⇒ Object
16 17 18 19 20 21 |
# File 'lib/sqs_web/application/navigation.rb', line 16 def tabs [ {:name => 'Overview', :path => '/overview'}, {:name => 'DLQ Console', :path => '/dlq_console'} ] end |
#url_path(*path_parts) ⇒ Object Also known as: u
2 3 4 |
# File 'lib/sqs_web/application/navigation.rb', line 2 def url_path(*path_parts) [ path_prefix, path_parts ].join("/").squeeze('/') end |