Sha256: bf3f9454254edca4ca87356d97624b3b7e8b6cec5ff447e20dc039e9d04b1681

Contents?: true

Size: 870 Bytes

Versions: 4

Compression:

Stored size: 870 Bytes

Contents

module Navigation
  def url_path(*path_parts)
    [ path_prefix, path_parts ].join("/").squeeze('/')
  end

  alias_method :u, :url_path

  def h(text)
    Rack::Utils.escape_html(text)
  end

  def path_prefix
    request.env['SCRIPT_NAME']
  end

  def tabs
    [
      {:name => 'Overview', :path => '/overview'},
      {:name => 'DLQ Console', :path => '/dlq_console'}
    ]
  end

  def csrf_token
    # Set up by Rack::Protection
    session[:csrf]
  end

  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

  def partial(template, local_vars = {})
    @partial = true
    erb(template.to_sym, {:layout => false}, local_vars)
  ensure
    @partial = false
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sqs_web-0.0.4 lib/sqs_web/application/navigation.rb
sqs_web-0.0.3 lib/sqs_web/application/navigation.rb
sqs_web-0.0.2 lib/sqs_web/application/navigation.rb
sqs_web-0.0.1 lib/sqs_web/application/navigation.rb