-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Chrome Extension #151
Add Chrome Extension #151
Conversation
63279d9
to
5366360
Compare
@@ -0,0 +1,66 @@ | |||
# Tasks to build chrome extension. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we build the extensions with Ruby tooling? E.g. rake
.
0a62f07
to
f60f126
Compare
Updated:
The Rakefile is not finished yet ✋ GIF - Hide existing consoleThanks. |
Great! Thanks for the update. |
This looks really awesome. I'm running rails through Vagrant through, so Chrome is on a localhost and rails is running in a VM. How would I set this up on my current system? |
@simkessy Thank you. The extension can detect Web Console by a response header, so I think there is no need to set up if you see the default console. All you have to do is to install the extension (and you might need to do |
f60f126
to
563319e
Compare
Updated:
@gsamokovarov Hello, could you review the rake tasks again? (ref: 563319e) Thank you! |
require "web_console" | ||
|
||
module WebConsole | ||
class FakeMiddleware |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this live in lib/web_console/testing/fake_middleware.rb
? This is to follow the example of other Rails component grouping their testing utilities in similar module.
563319e
to
59fe2f3
Compare
Updated:
@gsamokovarov Any other points you have? Thanks. |
"crx": "^3.0.2" | ||
}, | ||
"scripts": { | ||
"crx": "npm install && node \"$(npm bin)/gulp\" crx/run" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have gulp anymore, right?
59fe2f3
to
ae8bbde
Compare
Updated again:
Thanks again. |
require 'web_console/testing/fake_middleware' | ||
|
||
# This class is to pre-compile 'templates/*.erb'. | ||
class ERBHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERBPrecompiler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, also, please put it inside of the WebConsole::Testing
namespace. Its more predictable to have the web_console/testing/erb_helper
class/module in this namespace. You can call it with the fully qualified name wherever its referenced now. Same applies to the FakeMiddleware
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will do it :-)
ae8bbde
to
0f64708
Compare
Updated:
Thanks! |
Forgot to write, I added |
require "action_dispatch" | ||
require "web_console" | ||
|
||
module WebConsole::Testing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer it written like:
module WebConsole
module Testing
class FakeMiddleware
end
end
end
That way, the file that is required first will create the WebConsole::Testing
module and the other files will just reopen it. You also get better Module.nesting
and can reference constants in WebConsole relatively as well. Same for the precompiler.
0f64708
to
221da56
Compare
Updated again.
Yeah, that makes sense.
Now I get it. Thanks! |
|
||
task build: [ extdir, 'lib:templates' ] do | ||
cd rootdir do | ||
cp_r [ 'chrome/html', 'chrome/js', 'chrome/manifest.json', 'img/', 'tmp/lib/' ], dist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line ends up copying files which should be ignored (e.g., vim swap files). I will rewrite this task with git ls-files
or something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
f709292
to
49acec6
Compare
Updated (diff for the Rakefile: 221da56...2d350dc):
Thanks! |
Oh, this also causes |
49acec6
to
f79075b
Compare
Updated again:
And thanks again. |
cp_r [ 'img/', 'tmp/lib/' ], dist | ||
`cd chrome && git ls-files`.split("\n").each do |src| | ||
dest = dist.join(src) | ||
mkdir_p dest.dirname unless Dir.exists?(dest.dirname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think mkdir_p
will check if the dir exist and won't create it at all, so you can save yourself the condition.
For the development: ``` $ git clone https://github.com/rails/web-console.git $ cd web-console $ bundle install $ bundle exec rake ext:chrome:run => Chrome will be launched with the extension. ``` And provide some rake tasks for the extension: - "ext:chrome" is to build the extension - "ext:chrome:run" is to launch a browser with the extension - "ext:chrome:zip" is to generate .zip - "ext:chrome:crx" is to generate .crx
f79075b
to
7098a7e
Compare
Updated again*2 (diff: f79075b...ece32ec):
|
@sh19910711 Do you have anything to add here? There are areas which we can improve, but I think it's a decent start. |
@gsamokovarov No, I don't. I think so too :-) |
@gsamokovarov Thanks for merging 🙇 |
Ref. #121 |
Hey @sh19910711, we seem to have forgotten to include the renamed |
Hey. That folder might be "extensions/script"? |
@simkessy Thank you. The extension can detect Web Console by a response header, so I think there is no need to set up if you see the default console. All you have to do is to install the extension (and you might need to do gem "web-console", "~>2.2.0" or something perhaps). @sh19910711 I'm trying to follow the install instructions but I'm not sure if I'm suppose to be cloning the extension locally or in vagrant? So far I'm tried to do everything in vagrant and I get this error when trying to bundle
|
@simkessy Hi. It's better to clone the extension locally if you use it in Chrome on the real machine.
I got the same error on the master branch. I think we can pass it by specifying the Gemfile of Web Console (like that |
This pull-request contains Chrome Extension and some preparations for the browser extensions.
1. Use a static method to send XHRs
2. Other preparations for the browser extensions
3. Add Chrome Extension
About the extension, we can try the development version by the following commands:
Now I'm looking for an edge case for the extension, so welcome any feedback from anyone at any time.
And hello @gsamokovarov, could you review this pull-request, please?
Thank you.