pax_global_header 0000666 0000000 0000000 00000000064 14475705407 0014527 g ustar 00root root 0000000 0000000 52 comment=a3b7c2a89c13f8e9960a34df41674be5d3e47dcd web-console-4.2.1/ 0000775 0000000 0000000 00000000000 14475705407 0013750 5 ustar 00root root 0000000 0000000 web-console-4.2.1/.devcontainer/ 0000775 0000000 0000000 00000000000 14475705407 0016507 5 ustar 00root root 0000000 0000000 web-console-4.2.1/.devcontainer/devcontainer.json 0000664 0000000 0000000 00000001656 14475705407 0022073 0 ustar 00root root 0000000 0000000 // For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/ruby { "name": "Ruby", // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile "image": "mcr.microsoft.com/devcontainers/ruby:1-3.2-bullseye", "features": { "ghcr.io/devcontainers/features/github-cli:1": {} }, // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "bundle install" // Configure tool-specific properties. // "customizations": {}, // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" } web-console-4.2.1/.github/ 0000775 0000000 0000000 00000000000 14475705407 0015310 5 ustar 00root root 0000000 0000000 web-console-4.2.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14475705407 0017345 5 ustar 00root root 0000000 0000000 web-console-4.2.1/.github/workflows/ci.yml 0000664 0000000 0000000 00000001437 14475705407 0020470 0 ustar 00root root 0000000 0000000 name: CI on: - push - pull_request permissions: contents: read jobs: test: runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false matrix: ruby: ['2.7', '3.0', '3.1', '3.2', 'head'] rails: [ '6.0', '6.1', '7.0', 'edge' ] script: [test] experimental: [false] include: - ruby: '2.7' rails: '7.0' script: templates:test experimental: true env: RAILS_VERSION: ${{ matrix.rails }} steps: - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: Run tests run: bundle exec rake ${{ matrix.script }} web-console-4.2.1/.gitignore 0000664 0000000 0000000 00000000316 14475705407 0015740 0 ustar 00root root 0000000 0000000 .bundle/ log/*.log pkg/ coverage/ test/dummy/db/*.sqlite3 test/dummy/db/*.sqlite3-journal test/dummy/log/*.log test/dummy/tmp/ test/dummy/.sass-cache Gemfile.lock node_modules/ package-lock.json dist/ tmp/ web-console-4.2.1/.rubocop.yml 0000664 0000000 0000000 00000007072 14475705407 0016230 0 ustar 00root root 0000000 0000000 AllCops: TargetRubyVersion: 2.4 # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop # to ignore them, so only the ones explicitly set in this file are enabled. DisabledByDefault: true Exclude: - '**/templates/**/*' - '**/vendor/**/*' # Prefer &&/|| over and/or. Style/AndOr: Enabled: true # Do not use braces for hash literals when they are the last argument of a # method call. Style/BracesAroundHashParameters: Enabled: true EnforcedStyle: context_dependent # Align `when` with `case`. Layout/CaseIndentation: Enabled: true # Align comments with method definitions. Layout/CommentIndentation: Enabled: true Layout/ElseAlignment: Enabled: true # Align `end` with the matching keyword or starting expression except for # assignments, where it should be aligned with the LHS. Layout/EndAlignment: Enabled: true EnforcedStyleAlignWith: variable AutoCorrect: true Layout/EmptyLineAfterMagicComment: Enabled: true # In a regular class definition, no empty lines around the body. Layout/EmptyLinesAroundClassBody: Enabled: true # In a regular method definition, no empty lines around the body. Layout/EmptyLinesAroundMethodBody: Enabled: true # In a regular module definition, no empty lines around the body. Layout/EmptyLinesAroundModuleBody: Enabled: true Layout/FirstParameterIndentation: Enabled: true # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. Style/HashSyntax: Enabled: true # Method definitions after `private` or `protected` isolated calls need one # extra level of indentation. Layout/IndentationConsistency: Enabled: true EnforcedStyle: rails # Two spaces, no tabs (for indentation). Layout/IndentationWidth: Enabled: true Layout/LeadingCommentSpace: Enabled: true Layout/SpaceAfterColon: Enabled: true Layout/SpaceAfterComma: Enabled: true Layout/SpaceAroundEqualsInParameterDefault: Enabled: true Layout/SpaceAroundKeyword: Enabled: true Layout/SpaceAroundOperators: Enabled: true Layout/SpaceBeforeComma: Enabled: true Layout/SpaceBeforeFirstArg: Enabled: true Style/DefWithParentheses: Enabled: true # Defining a method with parameters needs parentheses. Style/MethodDefParentheses: Enabled: true Style/FrozenStringLiteralComment: Enabled: true EnforcedStyle: always Exclude: - 'actionview/test/**/*.builder' - 'actionview/test/**/*.ruby' - 'actionpack/test/**/*.builder' - 'actionpack/test/**/*.ruby' - 'activestorage/db/migrate/**/*.rb' # Use `foo {}` not `foo{}`. Layout/SpaceBeforeBlockBraces: Enabled: true # Use `foo { bar }` not `foo {bar}`. Layout/SpaceInsideBlockBraces: Enabled: true # Use `{ a: 1 }` not `{a:1}`. Layout/SpaceInsideHashLiteralBraces: Enabled: true Layout/SpaceInsideParens: Enabled: true # Check quotes usage according to lint rule below. Style/StringLiterals: Enabled: true EnforcedStyle: double_quotes # Detect hard tabs, no hard tabs. Layout/Tab: Enabled: true # Blank lines should not have any spaces. Layout/TrailingBlankLines: Enabled: true # No trailing whitespace. Layout/TrailingWhitespace: Enabled: true # Use quotes for string literals when they are enough. Style/UnneededPercentQ: Enabled: true # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. Lint/RequireParentheses: Enabled: true Lint/StringConversionInInterpolation: Enabled: true Style/RedundantReturn: Enabled: true AllowMultipleReturnValues: true Style/Semicolon: Enabled: true AllowAsExpressionSeparator: true # Prefer Foo.method over Foo::method Style/ColonMethodCall: Enabled: true web-console-4.2.1/CHANGELOG.markdown 0000664 0000000 0000000 00000022761 14475705407 0017013 0 ustar 00root root 0000000 0000000 # CHANGELOG ## main (unreleased) # 4.2.1 * Support to Rails 7.1 * Support to Rack 3.0 ## 4.2.0 * [#308](https://github.com/rails/web-console/pull/308) Fix web-console inline templates rendering ([@voxik]) * [#306](https://github.com/rails/web-console/pull/306) Support Ruby 3.0 and above ([@ryanwood]) ## 4.1.0 * [#304](https://github.com/rails/web-console/pull/304) Add support for Rails 6.1 ([@stephannv]) * [#298](https://github.com/rails/web-console/pull/298) Prevent deprecation warnings by removing template formats ([@mikelkew]) * [#297](https://github.com/rails/web-console/pull/297) Use MutationObserver instead of Mutation Events ([@mikelkew]) * [#296](https://github.com/rails/web-console/pull/296) Add CSP nonce to injected scripts and styles ([@mikelkew]) ## 4.0.4 * [fb483743](https://github.com/rails/web-console/commit/fb483743a6a2a4168cdc0b2e03f48fc393991b73) Fix a crash on webrick with Rack 2.2.3 ([@gsamokovarov]) ## 4.0.3 * [#291](https://github.com/rails/web-console/pull/291) Deprecate config.web_console.whitelisted_ips ([@JuanitoFatas]) * [#290](https://github.com/rails/web-console/pull/290) Fix Content-Length for rack >= 2.1.0 ([@p8]) ## 4.0.2 * [#285](https://github.com/rails/web-console/pull/285) Increase timeout on paste ([@celvro]) ## 4.0.1 * [#279](https://github.com/rails/web-console/pull/279) Fix initial config.web_console.permissions value ([@patorash]) ## 4.0.0 * [61ce65b5](https://github.com/rails/web-console/commit/61ce65b599f56809de1bd8da6590a80acbd92017) Move to config.web_console.permissions ([@gsamokovarov]) * [96127ac1](https://github.com/rails/web-console/commit/96127aac143e1e653fffdc4bb65e1ce0b5ff342d) Introduce Binding#console as an alternative interface ([@gsamokovarov]) * [d4591ca5](https://github.com/rails/web-console/commit/d4591ca5396ed15a08818f3da11134852a485b27) Introduce Rails 6 support ([@gsamokovarov]) * [f97d8a88](https://github.com/rails/web-console/commit/f97d8a889a38366485e5c5e8985995c19bf61d13) Introduce Ruby 2.6 support ([@gsamokovarov]) * [d6deacd9](https://github.com/rails/web-console/commit/d6deacd9d5fcaabf3e3051d6985b53f924f86956) Drop Rails 5 support ([@gsamokovarov]) * [90fda878](https://github.com/rails/web-console/commit/90fda8789d402f05647c18f8cdf8e5c3d01692dd) Drop Ruby 2.4 support ([@gsamokovarov]) * [#265](https://github.com/rails/web-console/pull/265) Add support for nested exceptions ([@yuki24]) ## 3.7.0 * [#263](https://github.com/rails/web-console/pull/263) Show binding changes ([@causztic]) * [#258](https://github.com/rails/web-console/pull/258) Support Ctrl-A, Ctrl-W and Ctrl-U ([@gsamokovarov]) * [#257](https://github.com/rails/web-console/pull/257) Always try to keep the console underneath the website content ([@gsamokovarov]) ## 3.6.2 * [#255](https://github.com/rails/web-console/pull/255) Fix the truncated HTML body, because of wrong Content-Length header ([@timomeh]) ## 3.6.1 * [#252](https://github.com/rails/web-console/pull/252) Fix improper injection in Rack bodies like ActionDispatch::Response::RackBody ([@gsamokovarov]) ## 3.6.0 * [#254](https://github.com/rails/web-console/pull/254) Rescue ActionDispatch::RemoteIp::IpSpoofAttackError ([@wjordan]) * [#250](https://github.com/rails/web-console/pull/250) Close original body to comply with Rack SPEC ([@wagenet]) * [#249](https://github.com/rails/web-console/pull/249) Update for frozen-string-literal friendliness ([@pat]) * [#248](https://github.com/rails/web-console/pull/248) Fix copy on Safari ([@ybart]) * [#246](https://github.com/rails/web-console/pull/246) International keyboard special character input fixes ([@fl0l0u]) * [#244](https://github.com/rails/web-console/pull/244) Let WebConsole.logger respect Rails.logger ([@gsamokovarov]) ## 3.5.1 * [#239](https://github.com/rails/web-console/pull/239) Fix the ActionDispatch::DebugExceptions integration ([@gsamokovarov]) ## 3.5.0 * [#237](https://github.com/rails/web-console/pull/237) Bindex integration for JRuby 9k support ([@gsamokovarov]) * [#236](https://github.com/rails/web-console/pull/236) Remove unused Active Support lazy load hook ([@betesh]) * [#230](https://github.com/rails/web-console/pull/230) Handle invalid remote addresses ([@akirakoyasu]) ## 3.4.0 * [#205](https://github.com/rails/web-console/pull/205) Introduce autocompletion ([@sh19910711]) ## 3.3.1 Drop support for Rails `4.2.0`. ## 3.3.0 * [#203](https://github.com/rails/web-console/pull/203) Map bindings to traces based on the trace __FILE__ and __LINE__ ([@gsamokovarov]) ## 3.2.1 * [#202](https://github.com/rails/web-console/pull/202) Use first binding when there is no application binding ([@sh19910711]) ## 3.2.0 * [#198](https://github.com/rails/web-console/pull/198) Pick the first application trace binding on errors ([@sh19910711]) * [#189](https://github.com/rails/web-console/pull/189) Silence ActionView rendering information ([@gsamokovarov]) ## 3.1.1 * [#185](https://github.com/rails/web-console/pull/185) Fix `rails console` startup ([@gsamokovarov]) ## 3.1.0 * [#182](https://github.com/rails/web-console/pull/182) Let `#console` live in `Kernel` ([@schneems]) * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@gsamokovarov]) * [#180](https://github.com/rails/web-console/pull/180) Autoload Web Console constants for faster Rails boot time ([@herminiotorres]) ## 3.0.0 * [#173](https://github.com/rails/web-console/pull/173) Revert "Change config.development_only default until 4.2.4 is released" ([@gsamokovarov]) * [#171](https://github.com/rails/web-console/pull/171) Fixed blocked IP logging ([@gsamokovarov]) * [#162](https://github.com/rails/web-console/pull/162) Render the console inside the body tag ([@gsamokovarov]) * [#165](https://github.com/rails/web-console/pull/165) Revamped integrations for CRuby and Rubinius ([@gsamokovarov]) ## 2.3.0 This is mainly a Rails 5 compatibility release. If you have the chance, please go to 3.1.0 instead. * [#181](https://github.com/rails/web-console/pull/181) Log internal Web Console errors ([@schneems]) * [#150](https://github.com/rails/web-console/pull/150) Revert #150. ([@gsamokovarov]) ## 2.2.1 * [#150](https://github.com/rails/web-console/pull/150) Change config.development_only default until 4.2.4 is released ([@gsamokovarov]) ## 2.2.0 * [#140](https://github.com/rails/web-console/pull/140) Add the ability to close the console on each page ([@sh19910711]) * [#135](https://github.com/rails/web-console/pull/135) Run the console only in development mode and raise warning in tests ([@frenesim]) * [#134](https://github.com/rails/web-conscle/pull/134) Force development only web console by default ([@gsamokovarov]) * [#123](https://github.com/rails/web-console/pull/123) Replace deprecated `alias_method_chain` with `alias_method` ([@jonatack]) ## 2.1.3 * Fix remote code execution vulnerability in Web Console. CVE-2015-3224. ## 2.1.2 * [#115](https://github.com/rails/web-console/pull/115) Show proper binding when raising an error in a template ([@gsamokovarov]) * [#114](https://github.com/rails/web-console/pull/114) Fix templates non rendering, because of missing template suffix ([@gsamokovarov]) ## 2.1.1 * [#112](https://github.com/rails/web-console/pull/112) Always allow application/x-www-form-urlencoded content type ([@gsamokovarov]) ## 2.1.0 * [#109](https://github.com/rails/web-console/pull/109) Revamp unavailable session response message ([@gsamokovarov]) * [#107](https://github.com/rails/web-console/pull/107) Fix pasting regression for all browsers ([@parterburn]) * [#105](https://github.com/rails/web-console/pull/105) Lock scroll bottom on console window resize ([@noahpatterson]) * [#104](https://github.com/rails/web-console/pull/104) Always whitelist localhost and inform users why no console is displayed ([@gsamokovarov]) * [#100](https://github.com/rails/web-console/pull/100) Accept text/plain as acceptable content type for Puma ([@gsamokovarov]) * [#98](https://github.com/rails/web-console/pull/98) Add arbitrary big z-index to the console ([@bglbruno]) * [#88](https://github.com/rails/web-console/pull/88) Spelling fixes ([@jeffnv]) * [#86](https://github.com/rails/web-console/pull/86) Disable autofocus when initializing the console ([@ryandao]) * [#84](https://github.com/rails/web-console/pull/84) Allow Rails 5 as dependency in gemspec ([@jonatack]) * [#69](https://github.com/rails/web-console/pull/69) Introduce middleware for request dispatch and console rendering ([@gsamokovarov]) [@stephannv]: https://github.com/stephannv [@mikelkew]: https://github.com/mikelkew [@jonatack]: https://github.com/jonatack [@ryandao]: https://github.com/ryandao [@jeffnv]: https://github.com/jeffnv [@gsamokovarov]: https://github.com/gsamokovarov [@bglbruno]: https://github.com/bglbruno [@noahpatterson]: https://github.com/noahpatterson [@parterburn]: https://github.com/parterburn [@sh19910711]: https://github.com/sh19910711 [@frenesim]: https://github.com/frenesim [@herminiotorres]: https://github.com/herminiotorres [@schneems]: https://github.com/schneems [@betesh]: https://github.com/betesh [@akirakoyasu]: https://github.com/akirakoyasu [@wagenet]: https://github.com/wagenet [@wjordan]: https://github.com/wjordan [@pat]: https://github.com/pat [@ybart]: https://github.com/ybart [@fl0l0u]: https://github.com/fl0l0u [@timomeh]: https://github.com/timomeh [@causztic]: https://github.com/causztic [@yuki24]: https://github.com/yuki24 [@patorash]: https://github.com/patorash [@celvro]: https://github.com/celvro [@JuanitoFatas]: https://github.com/JuanitoFatas [@p8]: https://github.com/p8 [@voxik]: https://github.com/voxik [@ryanwood]: https://github.com/ryanwood web-console-4.2.1/Gemfile 0000664 0000000 0000000 00000001006 14475705407 0015240 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } gemspec if ENV["RAILS_VERSION"] == "edge" gem "rails", github: "rails/rails", branch: "main" elsif ENV["RAILS_VERSION"] gem "activesupport", "~> #{ENV["RAILS_VERSION"]}.0" else gem "rails" end gem "rack" group :development do platform :ruby do gem "byebug" end gem "puma" end group :test do gem "rake" gem "mocha", require: false gem "simplecov", require: false end web-console-4.2.1/MIT-LICENSE 0000664 0000000 0000000 00000002132 14475705407 0015402 0 ustar 00root root 0000000 0000000 Copyright 2014-2016 Hailey Somerville, Genadi Samokovarov, Guillermo Iguaran and Ryan Dao Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. web-console-4.2.1/README.markdown 0000664 0000000 0000000 00000013516 14475705407 0016457 0 ustar 00root root 0000000 0000000
Current version: 4.2.1 | Documentation for: v1.0.4 v2.2.1 v3.7.0
# Web Console [](https://github.com/rails/web-console/actions/workflows/ci.yml) _Web Console_ is a debugging tool for your Ruby on Rails applications. - [Installation](#installation) - [Configuration](#configuration) - [Usage](#usage) - [FAQ](#faq) - [Credits](#credits) ## Installation Add the following to your `Gemfile`: ```ruby group :development do gem 'web-console' end ``` ## Usage The web console allows you to create an interactive Ruby session in your browser. Those sessions are launched automatically in case of an error and can also be launched manually in any page. For example, calling `console` in a view will display a console in the current page in the context of the view binding. ```html <% console %> ``` Calling `console` in a controller will result in a console in the context of the controller action: ```ruby class PostsController < ApplicationController def new console @post = Post.new end end ``` The method is defined in `Kernel` and you can invoke it any application code. Only one `console` invocation per request is allowed. If you happen to have multiple ones, `WebConsole::DoubleRenderError` will be raised. ## Configuration _Web Console_ allows you to execute arbitrary code on the server. Therefore, be very careful who you give access to. ### config.web_console.permissions By default, only requests coming from IPv4 and IPv6 localhosts are allowed. `config.web_console.permissions` lets you control which IP's have access to the console. You can allow single IP's or whole networks. Say you want to share your console with `192.168.0.100`: ```ruby class Application < Rails::Application config.web_console.permissions = '192.168.0.100' end ``` If you want to allow the whole private network: ```ruby Rails.application.configure do config.web_console.permissions = '192.168.0.0/16' end ``` Take a note that IPv4 and IPv6 localhosts are always allowed. This wasn't the case in 2.0. ### config.web_console.whiny_requests When a console cannot be shown for a given IP address or content type, messages such as the following is printed in the server logs: > Cannot render console from 192.168.1.133! Allowed networks: > 127.0.0.0/127.255.255.255, ::1 If you don't want to see this message anymore, set this option to `false`: ```ruby Rails.application.configure do config.web_console.whiny_requests = false end ``` ### config.web_console.template_paths If you want to style the console yourself, then you can place `style.css` at a directory pointed by `config.web_console.template_paths`: ```ruby Rails.application.configure do config.web_console.template_paths = 'app/views/web_console' end ``` You may want to check the [templates] folder at the source tree for the files you may override. ### config.web_console.mount_point Usually the middleware of _Web Console_ is mounted at `/__web_console`. If there is a need to change the path, then you can specify it by `config.web_console.mount_point`: ```ruby Rails.application.configure do config.web_console.mount_point = '/path/to/web_console' end ``` ## FAQ ### Where did /console go? The remote terminal emulator was extracted in its own gem which is no longer bundled with _Web Console_. If you miss this feature, check out [rvt]. ### Why do I constantly get unavailable session errors? All of _Web Console_ sessions are stored in memory. If you happen to run on a multi-process server (like Unicorn), you may encounter unavailable session errors while the server is still running. This is because a request may hit a different worker (process) that doesn't have the desired session in memory. To avoid that, if you use such servers in development, configure them so they serve requests only out of one process. #### Passenger Enable sticky sessions for [Passenger on Nginx] or [Passenger on Apache] to prevent unavailable session errors. ### How to inspect local and instance variables? The interactive console executes Ruby code. Invoking `instance_variables` and `local_variables` will give you what you want. ### Why does the console only appear on error pages but not when I call it? This can be happening if you are using `Rack::Deflater`. Be sure that `WebConsole::Middleware` is used after `Rack::Deflater`. The easiest way to do this is to insert `Rack::Deflater` as early as possible ```ruby Rails.application.configure do config.middleware.insert(0, Rack::Deflater) end ``` ### Why am I getting an undefined method `web_console`? Make sure your configuration lives in `config/environments/development.rb`. ## Credits * Shoutout to [Hailey Somerville] for [better_errors]. * Kudos to [John Mair] for [binding_of_caller] and [debug_inspector]. * Thanks to [Charles Oliver Nutter] for all the _JRuby_ feedback. * Hugs and kisses to all of our [contributors]! [better_errors]: https://github.com/BetterErrors/better_errors [debug_inspector]: https://github.com/banister/debug_inspector [binding_of_caller]: https://github.com/banister/binding_of_caller [Hailey Somerville]: https://github.com/haileys [John Mair]: https://github.com/banister [Charles Oliver Nutter]: https://github.com/headius [templates]: https://github.com/rails/web-console/tree/main/lib/web_console/templates [rvt]: https://github.com/gsamokovarov/rvt [contributors]: https://github.com/rails/web-console/graphs/contributors [Passenger on Nginx]: https://www.phusionpassenger.com/library/config/nginx/reference/#passengerstickysessions [Passenger on Apache]: https://www.phusionpassenger.com/library/config/apache/reference/#passengerstickysessions web-console-4.2.1/Rakefile 0000664 0000000 0000000 00000001146 14475705407 0015417 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true begin require "bundler/setup" rescue LoadError puts "You must `gem install bundler` and `bundle install` to run rake tasks" end require "socket" require "rake/testtask" require "tmpdir" require "securerandom" require "json" require "web_console/testing/erb_precompiler" EXPANDED_CWD = File.expand_path(File.dirname(__FILE__)) Rake::TestTask.new(:test) do |t| t.libs << "lib" t.libs << "test" t.pattern = "test/**/*_test.rb" t.verbose = false end Dir["lib/web_console/tasks/**/*.rake"].each { |task| load task } Bundler::GemHelper.install_tasks task default: :test web-console-4.2.1/extensions/ 0000775 0000000 0000000 00000000000 14475705407 0016147 5 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/README.markdown 0000664 0000000 0000000 00000000303 14475705407 0020644 0 ustar 00root root 0000000 0000000 # Web Console Browser Extensions ## Development ### Quickstart ``` $ git clone https://github.com/rails/web-console.git $ cd web-console $ bundle install $ bundle exec rake ext:chrome:run ``` web-console-4.2.1/extensions/chrome/ 0000775 0000000 0000000 00000000000 14475705407 0017424 5 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/chrome/html/ 0000775 0000000 0000000 00000000000 14475705407 0020370 5 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/chrome/html/devtools.html 0000664 0000000 0000000 00000000111 14475705407 0023106 0 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/chrome/html/panel.html 0000664 0000000 0000000 00000000322 14475705407 0022352 0 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/chrome/js/ 0000775 0000000 0000000 00000000000 14475705407 0020040 5 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/chrome/js/background.js 0000664 0000000 0000000 00000004744 14475705407 0022526 0 ustar 00root root 0000000 0000000 var sessions = {}; var ports = {}; initPanelMessage(); initReqRes(); initHttpListener(); initNavListener(); function panelMessage(tabId, type, msg) { msg = msg || {}; msg.type = type; if (ports[tabId]) { ports[tabId].postMessage(msg); } } function sendSession(tabId) { panelMessage(tabId, 'update-session', sessions[tabId]); } function removeConsole(tabId) { panelMessage(tabId, 'remove-console'); } function initPanelMessage() { chrome.runtime.onConnect.addListener(onConnect); function handleMessage(msg) { if (msg.type === 'session') { sendSession(msg.tabId); } } function onConnect(newPort) { ports[newPort.name] = newPort; newPort.onMessage.addListener(handleMessage); } } function initReqRes() { chrome.runtime.onMessage.addListener(handleMessage); function extractProps(xhr) { var props = {}; for (var key in xhr) { if (typeof xhr[key] === 'string' || typeof xhr[key] === 'number') { props[key] = xhr[key]; } } return props; } function handleMessage(req, sender, sendResponse) { if (req.type === 'request') { var url = sessions[req.tabId].remoteHost + '/' + req.url; REPLConsole.request(req.method, url, req.params, function(xhr) { sendResponse(extractProps(xhr)); }); } return true; } } function initHttpListener() { var requestFilter = { types: [ 'main_frame' ], urls: [ 'http://*/*', 'https://*/*' ] }; // Fired when a request is completed. chrome.webRequest.onCompleted.addListener( onResponse, requestFilter, [ 'responseHeaders' ] ); function getHeaders(details) { return details.responseHeaders.reduce(reduceFunc, {}); } function reduceFunc(obj, header) { obj[header.name] = header.value; return obj; } function onResponse(details) { var headers = getHeaders(details); var sessionId; if (sessionId = headers['x-web-console-session-id']) { sessions[details.tabId] = { sessionId: sessionId, mountPoint: headers['x-web-console-mount-point'], remoteHost: details.url.match(/([^:]+:\/\/[^\/]+)\/?/)[1] }; } } } function initNavListener() { // Fired when a document is completely loaded and initialized. chrome.webNavigation.onCompleted.addListener(function(details) { if (filter(details)) { sendSession(details.tabId); removeConsole(details.tabId); } }); function filter(details) { return details.frameId === 0 && sessions[details.tabId]; } } web-console-4.2.1/extensions/chrome/js/devtools.js 0000664 0000000 0000000 00000000220 14475705407 0022227 0 ustar 00root root 0000000 0000000 var label = 'Console (Rails)'; var icon = 'img/icon_128.png'; var html = 'html/panel.html'; chrome.devtools.panels.create(label, icon, html); web-console-4.2.1/extensions/chrome/js/panel.js 0000664 0000000 0000000 00000002214 14475705407 0021474 0 ustar 00root root 0000000 0000000 var tabId = chrome.devtools.inspectedWindow.tabId; var port = chrome.runtime.connect({ name: tabId.toString() }); var repl; // We need to avoid the sandbox of Chrome DevTools via the messaging system. REPLConsole.request = function(method, url, params, callback) { chrome.runtime.sendMessage({ tabId: tabId, type: 'request', method: method, url: url, params: params }, callback); }; // Handle messages from the background script. port.onMessage.addListener(function(msg) { if (msg.type === 'update-session') { updateSession(msg); } else if (msg.type === 'remove-console') { removeConsole(); } }); function updateSession(info) { if (repl) { repl.sessionId = info.sessionId; repl.mountPoint = info.mountPoint; } else { var options = { sessionId: info.sessionId, mountPoint: info.mountPoint }; repl = REPLConsole.installInto('console', options); } } function removeConsole() { var script = 'if (REPLConsole && REPLConsole.currentSession) REPLConsole.currentSession.uninstall()'; chrome.devtools.inspectedWindow.eval(script); } port.postMessage({ type: 'session', tabId: tabId }); removeConsole(); web-console-4.2.1/extensions/chrome/manifest.json 0000664 0000000 0000000 00000000624 14475705407 0022127 0 ustar 00root root 0000000 0000000 { "name": "Rails Web Console", "version": "0.0.0", "manifest_version": 2, "background": { "scripts": ["lib/console.js", "js/background.js"] }, "icons": { "128": "img/icon_128.png" }, "devtools_page": "html/devtools.html", "permissions": [ "webRequest", "webNavigation", "http://*/*", "https://*/*" ], "homepage_url": "https://github.com/rails/web-console" } web-console-4.2.1/extensions/img/ 0000775 0000000 0000000 00000000000 14475705407 0016723 5 ustar 00root root 0000000 0000000 web-console-4.2.1/extensions/img/icon_128.png 0000664 0000000 0000000 00000007040 14475705407 0020754 0 ustar 00root root 0000000 0000000 PNG IHDR >a sBIT|d pHYs B(x tEXtSoftware www.inkscape.org< IDATx{pTU?w# !eH1hdj٩QkuuTT``Ĕ,S[V`25[?NA H$1ژ1Fʀy@پ_:}{sOKeee2b@t@t@t@t@t@t@t@t@t@t@t@t@F l1X,ֿ@$6oݻȈ1o>nԟ@$6mĚ5kXh{e1=jq.\Ⱦ}(((iaxD4ygyGBUU\x1[ǓO>ygNee%}}}|WQ+Z֮]{f+V099ɅV駟uĊ+$ΨWB P]]O<1%I'++3g 4cQSSs%%%̛7I0ԴRRݛQPP@aa!'OiRGeÆ ޛOii)NǣI}5$d$(~}Gss3sդȈ*N!A ݜ?ÁjU&55~.pс ))IQX)R ~;Fyy9iiiXV***'9r ~+%a rss1,_ڐr\G^^6$QVVp: ڊlfŊRPPɓ'a| #Iv7" evYt){wp8p:\z5cŋ8F6