web-console 3.5.1 → 3.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.markdown +21 -7
- data/README.markdown +4 -9
- data/Rakefile +14 -12
- data/lib/web-console.rb +3 -1
- data/lib/web_console.rb +9 -6
- data/lib/web_console/context.rb +8 -6
- data/lib/web_console/errors.rb +2 -0
- data/lib/web_console/evaluator.rb +4 -2
- data/lib/web_console/exception_mapper.rb +12 -10
- data/lib/web_console/extensions.rb +3 -1
- data/lib/web_console/middleware.rb +11 -9
- data/lib/web_console/railtie.rb +15 -17
- data/lib/web_console/request.rb +5 -1
- data/lib/web_console/response.rb +10 -6
- data/lib/web_console/session.rb +2 -0
- data/lib/web_console/tasks/extensions.rake +15 -13
- data/lib/web_console/tasks/templates.rake +8 -6
- data/lib/web_console/template.rb +3 -1
- data/lib/web_console/templates/console.js.erb +5 -4
- data/lib/web_console/testing/erb_precompiler.rb +5 -3
- data/lib/web_console/testing/fake_middleware.rb +7 -5
- data/lib/web_console/testing/helper.rb +3 -1
- data/lib/web_console/version.rb +3 -1
- data/lib/web_console/view.rb +5 -3
- data/lib/web_console/whiny_request.rb +3 -1
- data/lib/web_console/whitelist.rb +5 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bb1461a9213387e0c8158f62623d63b0ecff23c0cc6ccd91433ab203eec3eb8b
|
4
|
+
data.tar.gz: 45336b5c06bff19cd02d1b651d5917934434367d0efcb546ec55afd9b0b66804
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 638a0796f7049de3544b8d342d72545d72c06a56e0ecc82dbc2974fd16b2e81ab91a56ff9615e61ef34bfded1dda8f29187b4792db3d2bd757fed7e27dcf5d27
|
7
|
+
data.tar.gz: b52c4650487ec31ef5ba20ec4fdf180016f730ddffe2a8bf9909a32db39c362a4ae2ae60a59441fe1c0fc1a177933d4e09e634a5af3b4f51b23b4b51dfe13321
|
data/CHANGELOG.markdown
CHANGED
@@ -2,15 +2,24 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 3.6.0
|
6
|
+
|
7
|
+
* [#254](https://github.com/rails/web-console/pull/254) Rescue ActionDispatch::RemoteIp::IpSpoofAttackError ([@wjordan])
|
8
|
+
* [#250](https://github.com/rails/web-console/pull/250) Close original body to comply with Rack SPEC ([@wagenet])
|
9
|
+
* [#249](https://github.com/rails/web-console/pull/249) Update for frozen-string-literal friendliness ([@pat])
|
10
|
+
* [#248](https://github.com/rails/web-console/pull/248) Fix copy on Safari ([@ybart])
|
11
|
+
* [#246](https://github.com/rails/web-console/pull/246) International keyboard special character input fixes ([@fl0l0u])
|
12
|
+
* [#244](https://github.com/rails/web-console/pull/244) Let WebConsole.logger respect Rails.logger ([@gsamokovarov])
|
13
|
+
|
5
14
|
## 3.5.1
|
6
15
|
|
7
|
-
* [239](https://github.com/rails/web-console/pull/239) Fix the ActionDispatch::DebugExceptions integration ([@gsamokovarov])
|
16
|
+
* [#239](https://github.com/rails/web-console/pull/239) Fix the ActionDispatch::DebugExceptions integration ([@gsamokovarov])
|
8
17
|
|
9
18
|
## 3.5.0
|
10
19
|
|
11
|
-
* [237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov])
|
12
|
-
* [236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh])
|
13
|
-
* [230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu])
|
20
|
+
* [#237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov])
|
21
|
+
* [#236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh])
|
22
|
+
* [#230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu])
|
14
23
|
|
15
24
|
## 3.4.0
|
16
25
|
|
@@ -22,7 +31,7 @@ Drop support for Rails `4.2.0`.
|
|
22
31
|
|
23
32
|
## 3.3.0
|
24
33
|
|
25
|
-
* [203](https://github.com/rails/web-console/pull/203) Map bindings to traces based on the trace __FILE__ and __LINE__ ([@gsamokovarov])
|
34
|
+
* [#203](https://github.com/rails/web-console/pull/203) Map bindings to traces based on the trace __FILE__ and __LINE__ ([@gsamokovarov])
|
26
35
|
|
27
36
|
## 3.2.1
|
28
37
|
|
@@ -55,8 +64,8 @@ Drop support for Rails `4.2.0`.
|
|
55
64
|
This is mainly a Rails 5 compatibility release. If you have the chance, please
|
56
65
|
go to 3.1.0 instead.
|
57
66
|
|
58
|
-
* [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors (@schneems)
|
59
|
-
* [#150](https://github.com/rails/web-console/pull/150) Revert #150. (@gsamokovarov)
|
67
|
+
* [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@schneems])
|
68
|
+
* [#150](https://github.com/rails/web-console/pull/150) Revert #150. ([@gsamokovarov])
|
60
69
|
|
61
70
|
## 2.2.1
|
62
71
|
|
@@ -108,3 +117,8 @@ go to 3.1.0 instead.
|
|
108
117
|
[@schneems]: https://github.com/schneems
|
109
118
|
[@betesh]: https://github.com/betesh
|
110
119
|
[@akirakoyasu]: https://github.com/akirakoyasu
|
120
|
+
[@wagenet]: https://github.com/wagenet
|
121
|
+
[@wjordan]: https://github.com/wjordan
|
122
|
+
[@pat]: https://github.com/pat
|
123
|
+
[@ybart]: https://github.com/ybart
|
124
|
+
[@fl0l0u]: https://github.com/fl0l0u
|
data/README.markdown
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
Documentation for:
|
3
3
|
<a href=https://github.com/rails/web-console/tree/v1.0.4>v1.0.4</a>
|
4
4
|
<a href=https://github.com/rails/web-console/tree/v2.2.1>v2.2.1</a>
|
5
|
-
<a href=https://github.com/rails/web-console/tree/v3.0.0>v3.0.0</a>
|
6
5
|
</p>
|
7
6
|
|
8
7
|
# Web Console [![Build Status](https://travis-ci.org/rails/web-console.svg?branch=master)](https://travis-ci.org/rails/web-console)
|
@@ -17,8 +16,7 @@ _Web Console_ is a debugging tool for your Ruby on Rails applications.
|
|
17
16
|
|
18
17
|
## Installation
|
19
18
|
|
20
|
-
|
21
|
-
application, add the following to your `Gemfile`.
|
19
|
+
Add the following to your `Gemfile`.
|
22
20
|
|
23
21
|
```ruby
|
24
22
|
group :development do
|
@@ -26,13 +24,10 @@ group :development do
|
|
26
24
|
end
|
27
25
|
```
|
28
26
|
|
29
|
-
After you save the `Gemfile` changes, make sure to run `bundle install` and
|
30
|
-
restart your server for the _Web Console_ to kick in.
|
31
|
-
|
32
27
|
## Usage
|
33
28
|
|
34
29
|
The web console allows you to create an interactive Ruby session in your
|
35
|
-
browser. Those sessions are launched automatically in case
|
30
|
+
browser. Those sessions are launched automatically in case of an error, but
|
36
31
|
they can also be launched manually in any page.
|
37
32
|
|
38
33
|
For example, calling `console` in a view will display a console in the current
|
@@ -56,8 +51,8 @@ end
|
|
56
51
|
|
57
52
|
The method is defined in `Kernel` and you can invoke it any application code.
|
58
53
|
|
59
|
-
Only one `console` invocation is allowed
|
60
|
-
have multiple ones,
|
54
|
+
Only one `console` invocation per request is allowed. If you happen to
|
55
|
+
have multiple ones, `WebConsole::DoubleRenderError` will be raised.
|
61
56
|
|
62
57
|
## Configuration
|
63
58
|
|
data/Rakefile
CHANGED
@@ -1,26 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
begin
|
2
|
-
require
|
4
|
+
require "bundler/setup"
|
3
5
|
rescue LoadError
|
4
|
-
puts
|
6
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
5
7
|
end
|
6
8
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
9
|
+
require "socket"
|
10
|
+
require "rake/testtask"
|
11
|
+
require "tmpdir"
|
12
|
+
require "securerandom"
|
13
|
+
require "json"
|
14
|
+
require "web_console/testing/erb_precompiler"
|
13
15
|
|
14
16
|
EXPANDED_CWD = File.expand_path(File.dirname(__FILE__))
|
15
17
|
|
16
18
|
Rake::TestTask.new(:test) do |t|
|
17
|
-
t.libs <<
|
18
|
-
t.libs <<
|
19
|
-
t.pattern =
|
19
|
+
t.libs << "lib"
|
20
|
+
t.libs << "test"
|
21
|
+
t.pattern = "test/**/*_test.rb"
|
20
22
|
t.verbose = false
|
21
23
|
end
|
22
24
|
|
23
|
-
Dir[
|
25
|
+
Dir["lib/web_console/tasks/**/*.rake"].each { |task| load task }
|
24
26
|
|
25
27
|
Bundler::GemHelper.install_tasks
|
26
28
|
|
data/lib/web-console.rb
CHANGED
data/lib/web_console.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/dependencies/autoload"
|
4
|
+
require "active_support/logger"
|
3
5
|
|
4
6
|
module WebConsole
|
5
7
|
extend ActiveSupport::Autoload
|
@@ -16,13 +18,14 @@ module WebConsole
|
|
16
18
|
autoload :Middleware
|
17
19
|
autoload :Context
|
18
20
|
|
19
|
-
autoload_at
|
21
|
+
autoload_at "web_console/errors" do
|
20
22
|
autoload :Error
|
21
23
|
autoload :DoubleRenderError
|
22
24
|
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
def self.logger
|
27
|
+
Rails.logger || (@logger ||= ActiveSupport::Logger.new($stderr))
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
|
-
require
|
31
|
+
require "web_console/railtie"
|
data/lib/web_console/context.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# A context lets you get object names related to the current session binding.
|
3
5
|
class Context
|
@@ -17,12 +19,12 @@ module WebConsole
|
|
17
19
|
private
|
18
20
|
|
19
21
|
GLOBAL_OBJECTS = [
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
"instance_variables",
|
23
|
+
"local_variables",
|
24
|
+
"methods",
|
25
|
+
"class_variables",
|
26
|
+
"Object.constants",
|
27
|
+
"global_variables"
|
26
28
|
]
|
27
29
|
|
28
30
|
def global
|
data/lib/web_console/errors.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# Simple Ruby code evaluator.
|
3
5
|
#
|
@@ -8,7 +10,7 @@ module WebConsole
|
|
8
10
|
# Cleanses exceptions raised inside #eval.
|
9
11
|
cattr_reader :cleaner
|
10
12
|
@@cleaner = ActiveSupport::BacktraceCleaner.new
|
11
|
-
@@cleaner.add_silencer { |line| line.start_with?(File.expand_path(
|
13
|
+
@@cleaner.add_silencer { |line| line.start_with?(File.expand_path("..", __FILE__)) }
|
12
14
|
|
13
15
|
def initialize(binding = TOPLEVEL_BINDING)
|
14
16
|
@binding = binding
|
@@ -25,7 +27,7 @@ module WebConsole
|
|
25
27
|
def format_exception(exc)
|
26
28
|
backtrace = cleaner.clean(Array(exc.backtrace) - caller)
|
27
29
|
|
28
|
-
format = "#{exc.class.name}: #{exc}\n"
|
30
|
+
format = "#{exc.class.name}: #{exc}\n".dup
|
29
31
|
format << backtrace.map { |trace| "\tfrom #{trace}\n" }.join
|
30
32
|
format
|
31
33
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
class ExceptionMapper
|
3
5
|
def initialize(exception)
|
@@ -15,19 +17,19 @@ module WebConsole
|
|
15
17
|
|
16
18
|
private
|
17
19
|
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
def guess_binding_for_index(index)
|
21
|
+
file, line = @backtrace[index].to_s.split(":")
|
22
|
+
line = line.to_i
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
+
@bindings.find do |binding|
|
25
|
+
binding.eval("__FILE__") == file && binding.eval("__LINE__") == line
|
26
|
+
end
|
24
27
|
end
|
25
|
-
end
|
26
28
|
|
27
|
-
|
28
|
-
|
29
|
-
|
29
|
+
def guess_the_first_application_binding
|
30
|
+
@bindings.find do |binding|
|
31
|
+
binding.eval("__FILE__").to_s.start_with?(Rails.root.to_s)
|
32
|
+
end
|
30
33
|
end
|
31
|
-
end
|
32
34
|
end
|
33
35
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Kernel
|
2
4
|
module_function
|
3
5
|
|
@@ -24,7 +26,7 @@ module ActionDispatch
|
|
24
26
|
class DebugExceptions
|
25
27
|
def render_exception_with_web_console(request, exception)
|
26
28
|
render_exception_without_web_console(request, exception).tap do
|
27
|
-
backtrace_cleaner = request.get_header(
|
29
|
+
backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
|
28
30
|
error = ExceptionWrapper.new(backtrace_cleaner, exception).exception
|
29
31
|
|
30
32
|
# Get the original exception if ExceptionWrapper decides to follow it.
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/string/strip"
|
2
4
|
|
3
5
|
module WebConsole
|
4
6
|
class Middleware
|
5
|
-
TEMPLATES_PATH = File.expand_path(
|
7
|
+
TEMPLATES_PATH = File.expand_path("../templates", __FILE__)
|
6
8
|
|
7
9
|
cattr_accessor :mount_point
|
8
|
-
@@mount_point =
|
10
|
+
@@mount_point = "/__web_console"
|
9
11
|
|
10
12
|
cattr_accessor :whiny_requests
|
11
13
|
@@whiny_requests = true
|
@@ -27,13 +29,13 @@ module WebConsole
|
|
27
29
|
|
28
30
|
status, headers, body = call_app(env)
|
29
31
|
|
30
|
-
if session = Session.from(Thread.current)
|
32
|
+
if (session = Session.from(Thread.current)) && acceptable_content_type?(headers)
|
31
33
|
response = Response.new(body, status, headers)
|
32
34
|
template = Template.new(env, session)
|
33
35
|
|
34
36
|
response.headers["X-Web-Console-Session-Id"] = session.id
|
35
37
|
response.headers["X-Web-Console-Mount-Point"] = mount_point
|
36
|
-
response.write(template.render(
|
38
|
+
response.write(template.render("index"))
|
37
39
|
response.finish
|
38
40
|
else
|
39
41
|
[ status, headers, body ]
|
@@ -54,12 +56,12 @@ module WebConsole
|
|
54
56
|
private
|
55
57
|
|
56
58
|
def acceptable_content_type?(headers)
|
57
|
-
Mime::Type.parse(headers[
|
59
|
+
Mime::Type.parse(headers["Content-Type"].to_s).first == Mime[:html]
|
58
60
|
end
|
59
61
|
|
60
62
|
def json_response(opts = {})
|
61
63
|
status = opts.fetch(:status, 200)
|
62
|
-
headers = {
|
64
|
+
headers = { "Content-Type" => "application/json; charset = utf-8" }
|
63
65
|
body = yield.to_json
|
64
66
|
|
65
67
|
Rack::Response.new(body, status, headers).finish
|
@@ -121,13 +123,13 @@ module WebConsole
|
|
121
123
|
|
122
124
|
def respond_with_unavailable_session(id)
|
123
125
|
json_response(status: 404) do
|
124
|
-
{ output: format(I18n.t(
|
126
|
+
{ output: format(I18n.t("errors.unavailable_session"), id: id) }
|
125
127
|
end
|
126
128
|
end
|
127
129
|
|
128
130
|
def respond_with_unacceptable_request
|
129
131
|
json_response(status: 406) do
|
130
|
-
{ output: I18n.t(
|
132
|
+
{ output: I18n.t("errors.unacceptable_request") }
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
data/lib/web_console/railtie.rb
CHANGED
@@ -1,20 +1,18 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails/railtie"
|
2
4
|
|
3
5
|
module WebConsole
|
4
6
|
class Railtie < ::Rails::Railtie
|
5
7
|
config.web_console = ActiveSupport::OrderedOptions.new
|
6
8
|
config.web_console.whitelisted_ips = %w( 127.0.0.1 ::1 )
|
7
9
|
|
8
|
-
initializer
|
9
|
-
require
|
10
|
-
require
|
11
|
-
|
12
|
-
if logger = ::Rails.logger
|
13
|
-
WebConsole.logger = logger
|
14
|
-
end
|
10
|
+
initializer "web_console.initialize" do
|
11
|
+
require "bindex"
|
12
|
+
require "web_console/extensions"
|
15
13
|
end
|
16
14
|
|
17
|
-
initializer
|
15
|
+
initializer "web_console.development_only" do
|
18
16
|
unless (config.web_console.development_only == false) || Rails.env.development?
|
19
17
|
abort <<-END.strip_heredoc
|
20
18
|
Web Console is activated in the #{Rails.env} environment. This is
|
@@ -32,13 +30,13 @@ module WebConsole
|
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
|
-
initializer
|
33
|
+
initializer "web_console.insert_middleware" do |app|
|
36
34
|
app.middleware.insert_before ActionDispatch::DebugExceptions, Middleware
|
37
35
|
end
|
38
36
|
|
39
|
-
initializer
|
37
|
+
initializer "web_console.mount_point" do
|
40
38
|
if mount_point = config.web_console.mount_point
|
41
|
-
Middleware.mount_point = mount_point.chomp(
|
39
|
+
Middleware.mount_point = mount_point.chomp("/")
|
42
40
|
end
|
43
41
|
|
44
42
|
if root = Rails.application.config.relative_url_root
|
@@ -46,26 +44,26 @@ module WebConsole
|
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
|
-
initializer
|
47
|
+
initializer "web_console.template_paths" do
|
50
48
|
if template_paths = config.web_console.template_paths
|
51
49
|
Template.template_paths.unshift(*Array(template_paths))
|
52
50
|
end
|
53
51
|
end
|
54
52
|
|
55
|
-
initializer
|
53
|
+
initializer "web_console.whitelisted_ips" do
|
56
54
|
if whitelisted_ips = config.web_console.whitelisted_ips
|
57
55
|
Request.whitelisted_ips = Whitelist.new(whitelisted_ips)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
|
-
initializer
|
59
|
+
initializer "web_console.whiny_requests" do
|
62
60
|
if config.web_console.key?(:whiny_requests)
|
63
61
|
Middleware.whiny_requests = config.web_console.whiny_requests
|
64
62
|
end
|
65
63
|
end
|
66
64
|
|
67
|
-
initializer
|
68
|
-
config.i18n.load_path.concat(Dir[File.expand_path(
|
65
|
+
initializer "i18n.load_path" do
|
66
|
+
config.i18n.load_path.concat(Dir[File.expand_path("../locales/*.yml", __FILE__)])
|
69
67
|
end
|
70
68
|
end
|
71
69
|
end
|
data/lib/web_console/request.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# Web Console tailored request object.
|
3
5
|
class Request < ActionDispatch::Request
|
@@ -6,7 +8,7 @@ module WebConsole
|
|
6
8
|
@@whitelisted_ips = Whitelist.new
|
7
9
|
|
8
10
|
# Define a vendor MIME type. We can call it using Mime[:web_console_v2].
|
9
|
-
Mime::Type.register
|
11
|
+
Mime::Type.register "application/vnd.web-console.v2", :web_console_v2
|
10
12
|
|
11
13
|
# Returns whether a request came from a whitelisted IP.
|
12
14
|
#
|
@@ -19,6 +21,8 @@ module WebConsole
|
|
19
21
|
# Determines the remote IP using our much stricter whitelist.
|
20
22
|
def strict_remote_ip
|
21
23
|
GetSecureIp.new(self, whitelisted_ips).to_s
|
24
|
+
rescue ActionDispatch::RemoteIp::IpSpoofAttackError
|
25
|
+
"[Spoofed]"
|
22
26
|
end
|
23
27
|
|
24
28
|
# Returns whether the request is acceptable.
|
data/lib/web_console/response.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# A response object that writes content before the closing </body> tag, if
|
3
5
|
# possible.
|
@@ -7,13 +9,15 @@ module WebConsole
|
|
7
9
|
def write(content)
|
8
10
|
raw_body = Array(body).first.to_s
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
else
|
13
|
-
raw_body << content
|
14
|
-
end
|
12
|
+
# We're done with the original body object, so make sure to close it to comply with the Rack SPEC
|
13
|
+
body.close if body.respond_to?(:close)
|
15
14
|
|
16
|
-
self.body =
|
15
|
+
self.body =
|
16
|
+
if position = raw_body.rindex("</body>")
|
17
|
+
raw_body.dup.insert(position, content)
|
18
|
+
else
|
19
|
+
raw_body.dup << content
|
20
|
+
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def finish
|
data/lib/web_console/session.rb
CHANGED
@@ -1,23 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
namespace :ext do
|
2
|
-
rootdir = Pathname(
|
4
|
+
rootdir = Pathname("extensions")
|
3
5
|
|
4
|
-
desc
|
5
|
-
task chrome:
|
6
|
+
desc "Build Chrome Extension"
|
7
|
+
task chrome: "chrome:build"
|
6
8
|
|
7
9
|
namespace :chrome do
|
8
|
-
dist = Pathname(
|
10
|
+
dist = Pathname("dist/crx")
|
9
11
|
extdir = rootdir.join(dist)
|
10
|
-
manifest_json = rootdir.join(
|
12
|
+
manifest_json = rootdir.join("chrome/manifest.json")
|
11
13
|
|
12
14
|
directory extdir
|
13
15
|
|
14
|
-
task build: [ extdir,
|
16
|
+
task build: [ extdir, "lib:templates" ] do
|
15
17
|
cd rootdir do
|
16
|
-
cp_r [
|
18
|
+
cp_r [ "img/", "tmp/lib/" ], dist
|
17
19
|
`cd chrome && git ls-files`.split("\n").each do |src|
|
18
20
|
dest = dist.join(src)
|
19
21
|
mkdir_p dest.dirname
|
20
|
-
cp Pathname(
|
22
|
+
cp Pathname("chrome").join(src), dest
|
21
23
|
end
|
22
24
|
end
|
23
25
|
end
|
@@ -34,7 +36,7 @@ namespace :ext do
|
|
34
36
|
cd(extdir) { sh "zip -r ../crx-web-console-#{version}.zip ./" }
|
35
37
|
end
|
36
38
|
|
37
|
-
desc
|
39
|
+
desc "Launch a browser with the chrome extension."
|
38
40
|
task run: [ :build ] do
|
39
41
|
cd(rootdir) { sh "sh ./script/run_chrome.sh --load-extension=#{dist}" }
|
40
42
|
end
|
@@ -45,15 +47,15 @@ namespace :ext do
|
|
45
47
|
end
|
46
48
|
|
47
49
|
namespace :lib do
|
48
|
-
templates = Pathname(
|
49
|
-
tmplib = rootdir.join(
|
50
|
-
js_erb = FileList.new(templates.join(
|
50
|
+
templates = Pathname("lib/web_console/templates")
|
51
|
+
tmplib = rootdir.join("tmp/lib/")
|
52
|
+
js_erb = FileList.new(templates.join("**/*.js.erb"))
|
51
53
|
dirs = js_erb.pathmap("%{^#{templates},#{tmplib}}d")
|
52
54
|
|
53
55
|
task templates: dirs + js_erb.pathmap("%{^#{templates},#{tmplib}}X")
|
54
56
|
|
55
57
|
dirs.each { |d| directory d }
|
56
|
-
rule
|
58
|
+
rule ".js" => [ "%{^#{tmplib},#{templates}}X.js.erb" ] do |t|
|
57
59
|
File.write(t.name, WebConsole::Testing::ERBPrecompiler.new(t.source).build)
|
58
60
|
end
|
59
61
|
end
|
@@ -1,14 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
namespace :templates do
|
2
|
-
desc
|
4
|
+
desc "Run tests for templates"
|
3
5
|
task test: [ :daemonize, :npm, :rackup, :wait, :mocha, :kill, :exit ]
|
4
6
|
task serve: [ :npm, :rackup ]
|
5
7
|
|
6
|
-
workdir = Pathname(EXPANDED_CWD).join(
|
8
|
+
workdir = Pathname(EXPANDED_CWD).join("test/templates")
|
7
9
|
pid = Pathname(Dir.tmpdir).join("web_console_test.pid")
|
8
10
|
runner = URI.parse("http://#{ENV['IP'] || '127.0.0.1'}:#{ENV['PORT'] || 29292}/html/test_runner.html")
|
9
11
|
rackup = "rackup --host #{runner.host} --port #{runner.port}"
|
10
12
|
result = nil
|
11
|
-
browser =
|
13
|
+
browser = "phantomjs"
|
12
14
|
|
13
15
|
def need_to_wait?(uri)
|
14
16
|
Net::HTTP.start(uri.host, uri.port) { |http| http.get(uri.path) }
|
@@ -20,13 +22,13 @@ namespace :templates do
|
|
20
22
|
rackup += " -D --pid #{pid}"
|
21
23
|
end
|
22
24
|
|
23
|
-
task :
|
24
|
-
Dir.chdir(workdir) { system
|
25
|
+
task npm: [ :phantomjs ] do
|
26
|
+
Dir.chdir(workdir) { system "npm install --silent" }
|
25
27
|
end
|
26
28
|
|
27
29
|
task :phantomjs do
|
28
30
|
unless system("which #{browser} >/dev/null")
|
29
|
-
browser =
|
31
|
+
browser = "./node_modules/.bin/phantomjs"
|
30
32
|
Dir.chdir(workdir) { system("test -f #{browser} || npm install --silent phantomjs-prebuilt") }
|
31
33
|
end
|
32
34
|
end
|
data/lib/web_console/template.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# A facade that handles template rendering and composition.
|
3
5
|
#
|
@@ -6,7 +8,7 @@ module WebConsole
|
|
6
8
|
class Template
|
7
9
|
# Lets you customize the default templates folder location.
|
8
10
|
cattr_accessor :template_paths
|
9
|
-
@@template_paths = [ File.expand_path(
|
11
|
+
@@template_paths = [ File.expand_path("../templates", __FILE__) ]
|
10
12
|
|
11
13
|
def initialize(env, session)
|
12
14
|
@env = env
|
@@ -494,7 +494,7 @@ REPLConsole.prototype.getSuggestion = function(keyword) {
|
|
494
494
|
hint.className = 'console-hint';
|
495
495
|
hint.dataset.keyword = found;
|
496
496
|
hint.innerText = found.substr(self.suggestKeyword.length);
|
497
|
-
// clear hinting information after timeout in a few time
|
497
|
+
// clear hinting information after timeout in a few time
|
498
498
|
if (self.suggestTimeout) clearTimeout(self.suggestTimeout);
|
499
499
|
self.suggestTimeout = setTimeout(function() { self.renderInput() }, self.suggestWait);
|
500
500
|
}
|
@@ -710,9 +710,10 @@ REPLConsole.prototype.onKeyDown = function(ev) {
|
|
710
710
|
}
|
711
711
|
|
712
712
|
if (ev.ctrlKey || ev.metaKey) {
|
713
|
-
// Set focus to our clipboard in case they hit the "v" key
|
714
|
-
this.clipboard.focus();
|
715
713
|
if (ev.keyCode == 86) {
|
714
|
+
// Set focus to our clipboard when they hit the "v" key
|
715
|
+
this.clipboard.focus();
|
716
|
+
|
716
717
|
// Pasting to clipboard doesn't happen immediately,
|
717
718
|
// so we have to wait for a while to get the pasted text.
|
718
719
|
var _this = this;
|
@@ -732,7 +733,7 @@ REPLConsole.prototype.onKeyDown = function(ev) {
|
|
732
733
|
*/
|
733
734
|
REPLConsole.prototype.onKeyPress = function(ev) {
|
734
735
|
// Only write to the console if it's a single key press.
|
735
|
-
if (ev.ctrlKey || ev.metaKey) { return; }
|
736
|
+
if (ev.ctrlKey && !ev.altKey || ev.metaKey) { return; }
|
736
737
|
var keyCode = ev.keyCode || ev.which;
|
737
738
|
this.insertAtCurrent(String.fromCharCode(keyCode));
|
738
739
|
ev.stopPropagation();
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "web_console/testing/helper"
|
4
|
+
require "web_console/testing/fake_middleware"
|
3
5
|
|
4
6
|
module WebConsole
|
5
7
|
module Testing
|
@@ -8,7 +10,7 @@ module WebConsole
|
|
8
10
|
def initialize(path)
|
9
11
|
@erb = ERB.new(File.read(path))
|
10
12
|
@view = FakeMiddleware.new(
|
11
|
-
view_path: Helper.gem_root.join(
|
13
|
+
view_path: Helper.gem_root.join("lib/web_console/templates"),
|
12
14
|
).view
|
13
15
|
end
|
14
16
|
|
@@ -1,12 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "action_view"
|
4
|
+
require "web_console"
|
5
|
+
require "web_console/testing/helper"
|
6
|
+
Mime = { web_console_v2: "fake" }
|
5
7
|
|
6
8
|
module WebConsole
|
7
9
|
module Testing
|
8
10
|
class FakeMiddleware
|
9
|
-
I18n.load_path.concat(Dir[Helper.gem_root.join(
|
11
|
+
I18n.load_path.concat(Dir[Helper.gem_root.join("lib/web_console/locales/*.yml")])
|
10
12
|
|
11
13
|
DEFAULT_HEADERS = { "Content-Type" => "application/javascript" }
|
12
14
|
|
data/lib/web_console/version.rb
CHANGED
data/lib/web_console/view.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
class View < ActionView::Base
|
3
5
|
# Execute a block only on error pages.
|
@@ -15,7 +17,7 @@ module WebConsole
|
|
15
17
|
# leaking globals, unless you explicitly want to.
|
16
18
|
def render_javascript(template)
|
17
19
|
assign(template: template)
|
18
|
-
render(template: template, layout:
|
20
|
+
render(template: template, layout: "layouts/javascript")
|
19
21
|
end
|
20
22
|
|
21
23
|
# Render inlined string to be used inside of JavaScript code.
|
@@ -23,7 +25,7 @@ module WebConsole
|
|
23
25
|
# The inlined string is returned as an actual JavaScript string. You
|
24
26
|
# don't need to wrap the result yourself.
|
25
27
|
def render_inlined_string(template)
|
26
|
-
render(template: template, layout:
|
28
|
+
render(template: template, layout: "layouts/inlined_string")
|
27
29
|
end
|
28
30
|
|
29
31
|
# Custom ActionView::Base#render wrapper which silences all the log
|
@@ -31,7 +33,7 @@ module WebConsole
|
|
31
33
|
#
|
32
34
|
# Helps to keep the Rails logs clean during errors.
|
33
35
|
def render(*)
|
34
|
-
if logger = WebConsole.logger
|
36
|
+
if (logger = WebConsole.logger) && logger.respond_to?(:silence)
|
35
37
|
WebConsole.logger.silence { super }
|
36
38
|
else
|
37
39
|
super
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module WebConsole
|
2
4
|
# Noisy wrapper around +Request+.
|
3
5
|
#
|
@@ -21,7 +23,7 @@ module WebConsole
|
|
21
23
|
end
|
22
24
|
|
23
25
|
def logger
|
24
|
-
env[
|
26
|
+
env["action_dispatch.logger"] || WebConsole.logger
|
25
27
|
end
|
26
28
|
|
27
29
|
def request
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ipaddr"
|
2
4
|
|
3
5
|
module WebConsole
|
4
6
|
# Whitelist of allowed networks that can access Web Console.
|
@@ -20,7 +22,7 @@ module WebConsole
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def to_s
|
23
|
-
@networks.map(&method(:human_readable_ipaddr)).join(
|
25
|
+
@networks.map(&method(:human_readable_ipaddr)).join(", ")
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
@@ -38,7 +40,7 @@ module WebConsole
|
|
38
40
|
end
|
39
41
|
|
40
42
|
def human_readable_ipaddr(ipaddr)
|
41
|
-
ipaddr.to_range.to_s.split(
|
43
|
+
ipaddr.to_range.to_s.split("..").uniq.join("/")
|
42
44
|
end
|
43
45
|
end
|
44
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: web-console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Somerville
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2018-04-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: railties
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.7.3
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: A debugging tool for your Ruby on Rails applications.
|