├── .gitignore
├── Gemfile
├── Gemfile.lock
├── MIT-LICENSE
├── README.md
├── Rakefile
├── app
├── controllers
│ └── rails_web_console
│ │ └── console_controller.rb
└── views
│ └── rails_web_console
│ └── console
│ └── index.html.erb
├── bin
└── rails
├── config
└── routes.rb
├── lib
├── rails-web-console.rb
└── rails_web_console
│ ├── engine.rb
│ └── version.rb
├── rails-web-console.gemspec
└── test_app
├── Gemfile
├── Gemfile.lock
├── Rakefile
├── bin
├── bundle
├── rails
└── rake
├── config.ru
├── config
├── application.rb
├── boot.rb
├── environment.rb
├── environments
│ ├── development.rb
│ └── production.rb
├── initializers
│ └── session_store.rb
├── routes.rb
└── secrets.yml
├── log
└── .keep
└── public
├── 404.html
├── 422.html
├── 500.html
└── favicon.ico
/.gitignore:
--------------------------------------------------------------------------------
1 | .bundle/
2 | log/*.log
3 | pkg/
4 | /test_app/log/*.log
5 | /test_app/tmp
6 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source "https://rubygems.org"
2 |
3 | # Declare your gem's dependencies in rails_web_console.gemspec.
4 | # Bundler will treat runtime dependencies like base dependencies, and
5 | # development dependencies will be added by default to the :development group.
6 | gemspec
7 |
8 | # Declare any dependencies that are still in development here instead of in
9 | # your gemspec. These might include edge Rails or gems from your path or
10 | # Git. Remember to move these dependencies to your gemspec before releasing
11 | # your gem to rubygems.org.
12 |
13 | # To use debugger
14 | # gem 'debugger'
15 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | PATH
2 | remote: .
3 | specs:
4 | rails-web-console (0.4.0)
5 | railties (>= 3.1.0)
6 |
7 | GEM
8 | remote: https://rubygems.org/
9 | specs:
10 | actionpack (4.2.6)
11 | actionview (= 4.2.6)
12 | activesupport (= 4.2.6)
13 | rack (~> 1.6)
14 | rack-test (~> 0.6.2)
15 | rails-dom-testing (~> 1.0, >= 1.0.5)
16 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
17 | actionview (4.2.6)
18 | activesupport (= 4.2.6)
19 | builder (~> 3.1)
20 | erubis (~> 2.7.0)
21 | rails-dom-testing (~> 1.0, >= 1.0.5)
22 | rails-html-sanitizer (~> 1.0, >= 1.0.2)
23 | activesupport (4.2.6)
24 | i18n (~> 0.7)
25 | json (~> 1.7, >= 1.7.7)
26 | minitest (~> 5.1)
27 | thread_safe (~> 0.3, >= 0.3.4)
28 | tzinfo (~> 1.1)
29 | builder (3.2.2)
30 | erubis (2.7.0)
31 | i18n (0.7.0)
32 | json (1.8.3)
33 | loofah (2.0.3)
34 | nokogiri (>= 1.5.9)
35 | mini_portile2 (2.0.0)
36 | minitest (5.8.4)
37 | nokogiri (1.6.7.2)
38 | mini_portile2 (~> 2.0.0.rc2)
39 | rack (1.6.4)
40 | rack-test (0.6.3)
41 | rack (>= 1.0)
42 | rails-deprecated_sanitizer (1.0.3)
43 | activesupport (>= 4.2.0.alpha)
44 | rails-dom-testing (1.0.7)
45 | activesupport (>= 4.2.0.beta, < 5.0)
46 | nokogiri (~> 1.6.0)
47 | rails-deprecated_sanitizer (>= 1.0.1)
48 | rails-html-sanitizer (1.0.3)
49 | loofah (~> 2.0)
50 | railties (4.2.6)
51 | actionpack (= 4.2.6)
52 | activesupport (= 4.2.6)
53 | rake (>= 0.8.7)
54 | thor (>= 0.18.1, < 2.0)
55 | rake (11.1.2)
56 | thor (0.19.1)
57 | thread_safe (0.3.5)
58 | tzinfo (1.2.2)
59 | thread_safe (~> 0.1)
60 |
61 | PLATFORMS
62 | ruby
63 |
64 | DEPENDENCIES
65 | rails-web-console!
66 |
67 | BUNDLED WITH
68 | 1.11.2
69 |
--------------------------------------------------------------------------------
/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2014 Rodrigo Rosenfeld Rosas
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RailsWebConsole (No longer maintained)
2 |
3 | ## Important note
4 |
5 | I've switched my Rails projects to Roda, so I'm no longer using rails-web-console. But I still
6 | use the same features. That's why I created the [rack_web_console](https://github.com/rosenfeld/rack_web_console)
7 | project. It only depends on Rack, so it can be used both in Roda projects as well as Rails ones,
8 | or whatever other Rack-based framework/library. It works the same way, but if someone feels they'd
9 | like to take over this project, just let me know.
10 |
11 | ## Documentation
12 |
13 | A Rails mountable engine for running Ruby scripts on the browser in the context of a
14 | controller action.
15 |
16 | ## Dependencies
17 |
18 | It doesn't assume anything about Sprockets being available and will embed any JS directly into
19 | the views to avoid any dependencies on Sprockets.
20 |
21 | ActionView is required though but it's not declared as a dependency in the gemspec as it's a
22 | separate gem just as of Rails 4.1.x, so it would prevent this gem from working with older Rails
23 | versions, but you should make sure your Rails application include support to ActionView.
24 |
25 | ## Browser support
26 |
27 | All modern browsers and IE >= 8 should be supported.
28 |
29 | ## Minimal Ruby supported version
30 |
31 | 1.9 is the minimal required version due to usage of `require_relative` and the new hash syntax.
32 |
33 | Patches for supporting older Ruby versions won't be accepted.
34 |
35 | ## Install
36 |
37 | In your Gemfile, put the dependency like this:
38 |
39 | ```ruby
40 | gem 'rails-web-console', group: :development
41 | ```
42 |
43 | This will automatically mount it in /console. If you want to specify a different mount point,
44 | use:
45 |
46 | ```ruby
47 | gem 'rails-web-console', require: 'rails_web_console/engine', group: :development
48 | ```
49 |
50 | And add this to your config/routes.rb:
51 |
52 | ```ruby
53 | mount RailsWebConsole::Engine => '/inspect' if Rails.env.development?
54 | ```
55 |
56 | If you intend to use this in production environment (strongly discouraged), be sure to protect console routes. Do it on your own risk!
57 |
58 | ## Usage
59 |
60 | Just access "/console" (or whatever path you've chosen) in your browser.
61 |
62 | ## Support for older versions of Rails
63 |
64 | I won't be supporting older versions of Rails to keep the source as simple as possible.
65 |
66 | Take a look at older releases of this gem for supporting older Rails.
67 |
68 |
69 | Copyright (c) 2014 [Rodrigo Rosenfeld Rosas], released under the MIT license
70 |
71 | [](https://bitdeli.com/free "Bitdeli Badge")
72 |
--------------------------------------------------------------------------------
/Rakefile:
--------------------------------------------------------------------------------
1 | begin
2 | require 'bundler/setup'
3 | rescue LoadError
4 | puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5 | end
6 |
7 | Bundler::GemHelper.install_tasks
8 |
--------------------------------------------------------------------------------
/app/controllers/rails_web_console/console_controller.rb:
--------------------------------------------------------------------------------
1 | require 'stringio'
2 |
3 | module RailsWebConsole
4 | class ConsoleController < ::ActionController::Base
5 | if _process_action_callbacks.any?{|a| a.filter == :verify_authenticity_token}
6 | # ActionController::Base no longer protects from forgery in Rails 5
7 | skip_before_filter :verify_authenticity_token
8 | end
9 | layout false
10 |
11 | def index
12 | end
13 |
14 | SCRIPT_LIMIT = defined?(::WEB_CONSOLE_SCRIPT_LIMIT) ? ::WEB_CONSOLE_SCRIPT_LIMIT : 1000
15 | WARNING_LIMIT_MSG = "WARNING: stored script in session was limited to the first " +
16 | "#{SCRIPT_LIMIT} chars to avoid issues with cookie overflow\n"
17 | def run
18 | # we limit up to 1k to avoid ActionDispatch::Cookies::CookieOverflow (4k) which we
19 | # can't rescue since it happens in a middleware
20 | script = params[:script]
21 | # we allow users to ignore the limit if they are using another session storage mechanism
22 | script = script[0...SCRIPT_LIMIT] unless defined?(::WEB_CONSOLE_IGNORE_SCRIPT_LIMIT)
23 | session[:script] = script
24 | stdout_orig = $stdout
25 | $stdout = StringIO.new
26 | begin
27 | puts WARNING_LIMIT_MSG if params[:script].size > SCRIPT_LIMIT &&
28 | !defined?(::WEB_CONSOLE_IGNORE_SCRIPT_LIMIT)
29 | result_eval = eval params[:script], binding
30 | $stdout.rewind
31 | result = %Q{