dev_toolbar 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +16 -0
- data/Rakefile +36 -0
- data/app/assets/stylesheets/dev_toolbar/dev_toolbar.scss +76 -0
- data/app/views/shared/_dev_tools.html.erb +11 -0
- data/lib/dev_toolbar.rb +6 -0
- data/lib/dev_toolbar/debug_helper.rb +10 -0
- data/lib/dev_toolbar/engine.rb +49 -0
- data/lib/dev_toolbar/middleware.rb +41 -0
- data/lib/dev_toolbar/version.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1aef5cd3c0aa26e81bb29134d3700bbafe9addc215bc03a8baaf844ca0de43c6
|
4
|
+
data.tar.gz: 471568a19e42b41835ccb82016d618f699dba0f9aa86be361ddc93b360b4e621
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7db6621b788076edaa4772437fe4e9820716fed9693aac4b93db45683435a8c7c9b8bbcc138396a3ea6803eb45d4790d0259ff815a4f37f913fdf1eb50b9f576
|
7
|
+
data.tar.gz: f138d77ff57066f90a5a1095b2e36d32b9e9d68ab7526a1ccb6396c95e3b3998782d133f549ce4fa7727e79ca227816ac8fce202312863cb4f9682b33fcfe03f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Firstdraft
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# DevToolbar
|
2
|
+
Firstdraft Dev Toolbar for cloud9 integration with better errors and web-console..etc..,
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
group :development do
|
9
|
+
gem 'dev_toolbar', git: 'https://github.com/firstdraft/dev_toolbar.git'
|
10
|
+
end
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
```bash
|
15
|
+
$ bundle
|
16
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
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
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'DevToolbar'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'test'
|
31
|
+
t.pattern = 'test/**/*_test.rb'
|
32
|
+
t.verbose = false
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
task default: :test
|
@@ -0,0 +1,76 @@
|
|
1
|
+
.dev_toolbar {
|
2
|
+
box-sizing: border-box;
|
3
|
+
position:fixed;
|
4
|
+
height: 40px;
|
5
|
+
right:-40px;
|
6
|
+
top:45%;
|
7
|
+
transform:rotate(-90deg);
|
8
|
+
-webkit-transform:rotate(-90deg);
|
9
|
+
-ms-transform:rotate(-90deg);
|
10
|
+
-moz-transform:rotate(-90deg);
|
11
|
+
z-index:999;
|
12
|
+
|
13
|
+
.btn {
|
14
|
+
font-family: Georgia;
|
15
|
+
text-decoration: none;
|
16
|
+
display: inline-block;
|
17
|
+
font-weight: normal;
|
18
|
+
text-align: center;
|
19
|
+
white-space: nowrap;
|
20
|
+
vertical-align: middle;
|
21
|
+
-webkit-user-select: none;
|
22
|
+
-moz-user-select: none;
|
23
|
+
-ms-user-select: none;
|
24
|
+
user-select: none;
|
25
|
+
border: 1px solid transparent;
|
26
|
+
padding: 0.5rem 0.75rem;
|
27
|
+
font-size: 1rem;
|
28
|
+
line-height: 1.25;
|
29
|
+
border-radius: 0.25rem;
|
30
|
+
transition: all 0.15s ease-in-out;
|
31
|
+
}
|
32
|
+
|
33
|
+
.btn:focus, .btn.focus {
|
34
|
+
outline: 0;
|
35
|
+
box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
|
36
|
+
}
|
37
|
+
|
38
|
+
.btn-outline-secondary {
|
39
|
+
color: #868e96;
|
40
|
+
background-color: transparent;
|
41
|
+
background-image: none;
|
42
|
+
border-color: #868e96;
|
43
|
+
}
|
44
|
+
|
45
|
+
.btn-outline-secondary:hover {
|
46
|
+
color: #fff;
|
47
|
+
background-color: #868e96;
|
48
|
+
border-color: #868e96;
|
49
|
+
}
|
50
|
+
|
51
|
+
.btn-outline-secondary:focus, .btn-outline-secondary.focus {
|
52
|
+
box-shadow: 0 0 0 3px rgba(134, 142, 150, 0.5);
|
53
|
+
}
|
54
|
+
|
55
|
+
.btn-outline-secondary:active {
|
56
|
+
color: #fff;
|
57
|
+
background-color: #868e96;
|
58
|
+
border-color: #868e96;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
.footer {
|
63
|
+
position: absolute;
|
64
|
+
right: 0;
|
65
|
+
bottom: 0;
|
66
|
+
left: 0;
|
67
|
+
padding: 1rem;
|
68
|
+
text-align: center;
|
69
|
+
}
|
70
|
+
|
71
|
+
.alert-info {
|
72
|
+
color: #31708f;
|
73
|
+
background-color: #d9edf7;
|
74
|
+
border-color: #bce8f1;
|
75
|
+
}
|
76
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= stylesheet_link_tag "dev_toolbar" %>
|
2
|
+
<div class="dev_toolbar">
|
3
|
+
<% if defined?(WebGit) %>
|
4
|
+
<%= link_to "Git", "/git", class: "dev_tools_button btn btn-outline-secondary" %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if defined?(ActiveAdmin) %>
|
8
|
+
<%= link_to "Admin", "/admin", class: "dev_tools_button btn btn-outline-secondary" %>
|
9
|
+
<% end %>
|
10
|
+
<%= link_to "Routes", "/rails/info", class: "dev_tools_button btn btn-outline-secondary" %>
|
11
|
+
</div>
|
data/lib/dev_toolbar.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module DevToolbar
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace DevToolbar
|
4
|
+
|
5
|
+
initializer "dev_toolbar.configure_rails_initialization" do |app|
|
6
|
+
if enable?
|
7
|
+
insert_middleware
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
initializer "dev_toolbar.assets" do |app|
|
12
|
+
Rails.application.config.assets.precompile += %w{ dev_toolbar }
|
13
|
+
Rails.application.config.assets.paths << root.join("app", "assets", "stylesheets", "dev_toolbar")
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer 'dev_toolbar.action_controller' do |app|
|
17
|
+
ActiveSupport.on_load :action_controller do
|
18
|
+
helper DevToolbar::DebugHelper
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.after_initialize do
|
23
|
+
path = Rails.root.join('whitelist.yml')
|
24
|
+
if File.exist?(path)
|
25
|
+
whitelisted_ips = YAML.load_file(path)
|
26
|
+
whitelisted_ips.each do |ip|
|
27
|
+
BetterErrors::Middleware.allow_ip!(ip)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def insert_middleware
|
33
|
+
if defined? BetterErrors::Middleware
|
34
|
+
app.middleware.insert_after BetterErrors::Middleware, DevToolbar::Middleware
|
35
|
+
else
|
36
|
+
app.middleware.use DevToolbar::Middleware
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def enable?
|
42
|
+
!Rails.env.production? and app.config.consider_all_requests_local
|
43
|
+
end
|
44
|
+
|
45
|
+
def app
|
46
|
+
Rails.application
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module DevToolbar
|
2
|
+
class Middleware
|
3
|
+
def initialize(app)
|
4
|
+
@app = app
|
5
|
+
end
|
6
|
+
|
7
|
+
def call(env)
|
8
|
+
request = Rack::Request.new(env)
|
9
|
+
@ip = request.ip
|
10
|
+
@app.call(env)
|
11
|
+
rescue Exception => ex
|
12
|
+
if pass_through?
|
13
|
+
@app.call(env)
|
14
|
+
else
|
15
|
+
[200, {"Content-Type" => "text/html"}, [error_message]]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def pass_through?
|
20
|
+
path = Rails.root.join('whitelist.yml')
|
21
|
+
if File.exist?(path)
|
22
|
+
whitelisted_ips = YAML.load_file(path)
|
23
|
+
whitelisted_ips.include?(@ip)
|
24
|
+
else
|
25
|
+
true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def error_message
|
30
|
+
<<-HTML
|
31
|
+
<h1>Uh oh! You've got an error in your code.</h1>
|
32
|
+
|
33
|
+
<h2>To get a more helpful error page, please run this command at a terminal prompt:</h2>
|
34
|
+
|
35
|
+
<pre style="font-size: 4em;"><code>bin/whitelist #{@ip}</code></pre>
|
36
|
+
|
37
|
+
<h2>and then restart your server.</h2>
|
38
|
+
HTML
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dev_toolbar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Murugan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: better_errors
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Firstdraft Dev Toolbar
|
42
|
+
email:
|
43
|
+
- murugan@firstdraft.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/assets/stylesheets/dev_toolbar/dev_toolbar.scss
|
52
|
+
- app/views/shared/_dev_tools.html.erb
|
53
|
+
- lib/dev_toolbar.rb
|
54
|
+
- lib/dev_toolbar/debug_helper.rb
|
55
|
+
- lib/dev_toolbar/engine.rb
|
56
|
+
- lib/dev_toolbar/middleware.rb
|
57
|
+
- lib/dev_toolbar/version.rb
|
58
|
+
homepage: https://github.com/firstdraft
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.7.8
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Debug helper
|
82
|
+
test_files: []
|