Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #44 from tobias/context-path-support

Add support for context paths
  • Loading branch information...
commit 46fc1eb0d4e4ef691ef11e1f569f14ee3574c20f 2 parents 85ed076 + 5085486
@txus txus authored
View
9 lib/rack/webconsole/assets.rb
@@ -39,7 +39,7 @@ def call(env)
Webconsole::Repl.request = Rack::Request.new(env)
# Inject the html, css and js code to the view
- response_body.gsub!('</body>', "#{code}</body>")
+ response_body.gsub!('</body>', "#{code(env)}</body>")
headers['Content-Length'] = response_body.bytesize.to_s
@@ -53,10 +53,13 @@ def call(env)
# secure.
#
# @return [String] the injectable code.
- def code
+ def code(env)
html_code <<
css_code <<
- render(js_code, :TOKEN => Webconsole::Repl.token, :KEY_CODE => Webconsole.key_code)
+ render(js_code,
+ :TOKEN => Webconsole::Repl.token,
+ :KEY_CODE => Webconsole.key_code,
+ :CONTEXT => env['SCRIPT_NAME'] || "")
end
private
View
2  public/webconsole.js
@@ -24,7 +24,7 @@
webconsole.history.push(webconsole.query.val());
webconsole.pointer = webconsole.history.length - 1;
$.ajax({
- url: '/webconsole',
+ url: '$CONTEXT/webconsole',
type: 'POST',
dataType: 'json',
data: ({query: webconsole.query.val(), token: "$TOKEN"}),
View
6 spec/rack/webconsole/assets_spec.rb
@@ -12,16 +12,18 @@ module Rack
end
describe "#code" do
- it 'injects the token and key_code' do
+ it 'injects the token, key_code, and context path' do
Webconsole::Repl.stubs(:token).returns('fake_generated_token')
Webconsole.key_code = "96"
@assets = Webconsole::Assets.new(nil)
- assets_code = @assets.code
+ assets_code = @assets.code('SCRIPT_NAME' => '/hambiscuit')
assets_code.must_match /fake_generated_token/
assets_code.must_match /event\.which == 96/
+ assets_code.must_match %r{/hambiscuit/webconsole}
end
+
end
describe "#call" do
Please sign in to comment.
Something went wrong with that request. Please try again.