dev_toolbar 0.1.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dev_toolbar/configuration.rb +9 -0
- data/lib/dev_toolbar/middleware.rb +73 -26
- data/lib/dev_toolbar/railtie.rb +7 -0
- data/lib/dev_toolbar/version.rb +3 -1
- data/lib/dev_toolbar.rb +17 -4
- metadata +41 -31
- data/MIT-LICENSE +0 -20
- data/README.md +0 -16
- data/Rakefile +0 -36
- data/app/assets/stylesheets/dev_toolbar/dev_toolbar.scss +0 -76
- data/app/views/shared/_dev_tools.html.erb +0 -11
- data/lib/dev_toolbar/debug_helper.rb +0 -10
- data/lib/dev_toolbar/engine.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b5f82f64e412b3c84ead79dd80b612f52af3e45bb590fba94f24aafd148b1ef
|
4
|
+
data.tar.gz: f6ad406e103b96573194853a79cb89f5b3dc4ed78e48bfd692112c8203168d7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f4289abfef772cad1b0ef858dfa760a77e3071e8fad8aa42e8ce348477fabb0575cd52d710388808e7ccfc3d24d504d43d21baee46fc540265aaa50e2de8c4d
|
7
|
+
data.tar.gz: 70cbbfce13c9fa7c67edd150e4b429ef0d9a03477a47979553e2eabe48518181549888d234feb7d38c0ac2047fcf81b7000328a42fc3e96a0cf1f915791f0729
|
@@ -5,37 +5,84 @@ module DevToolbar
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def call(env)
|
8
|
-
|
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
|
8
|
+
status, headers, response = @app.call(env)
|
18
9
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
if Rails.env.development? && headers["Content-Type"]&.include?("text/html")
|
11
|
+
response_body = response.body
|
12
|
+
toolbar_html = <<-HTML
|
13
|
+
<div id="dev-toolbar">
|
14
|
+
<div id="dev-toolbar-button">
|
15
|
+
<a id="dev-toolbar-toggle">🛠️</a>
|
16
|
+
</div>
|
17
|
+
<div id="dev-toolbar-links" class="hidden">
|
18
|
+
#{toolbar_links}
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<style>
|
22
|
+
#dev-toolbar {
|
23
|
+
position: fixed;
|
24
|
+
right: 0;
|
25
|
+
top: 50vh;
|
26
|
+
transform: translateY(-50%);
|
27
|
+
background-color: #f0f0f0;
|
28
|
+
border: 1px solid #ccc;
|
29
|
+
z-index: 1000;
|
30
|
+
display: flex;
|
31
|
+
flex-direction: column;
|
32
|
+
align-items: center;
|
33
|
+
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
|
34
|
+
color: #808080;
|
35
|
+
}
|
36
|
+
|
37
|
+
#dev-toolbar-toggle {
|
38
|
+
font-size: 2em;
|
39
|
+
border: none;
|
40
|
+
cursor: pointer;
|
41
|
+
line-height: 1.5;
|
42
|
+
padding: 0 10px;
|
43
|
+
text-decoration: none;
|
44
|
+
}
|
45
|
+
|
46
|
+
#dev-toolbar-links {
|
47
|
+
display: flex;
|
48
|
+
flex-direction: column;
|
49
|
+
}
|
28
50
|
|
29
|
-
|
30
|
-
|
31
|
-
|
51
|
+
.dev-toolbar-link {
|
52
|
+
padding: 5px 10px;
|
53
|
+
border-bottom: 1px #f0f0f0 solid;
|
54
|
+
color: #808080;
|
55
|
+
text-decoration: none;
|
56
|
+
background-color: white;
|
57
|
+
}
|
58
|
+
|
59
|
+
#dev-toolbar-links.hidden {
|
60
|
+
display: none;
|
61
|
+
}
|
62
|
+
</style>
|
63
|
+
<script>
|
64
|
+
document.getElementById('dev-toolbar-toggle').addEventListener('click', function() {
|
65
|
+
var links = document.getElementById('dev-toolbar-links');
|
66
|
+
links.classList.toggle('hidden');
|
67
|
+
});
|
68
|
+
</script>
|
69
|
+
HTML
|
32
70
|
|
33
|
-
|
71
|
+
response_body.sub!('</body>', "#{toolbar_html}</body>")
|
72
|
+
headers["Content-Length"] = response_body.bytesize.to_s
|
73
|
+
|
74
|
+
response = [response_body]
|
75
|
+
end
|
76
|
+
|
77
|
+
[status, headers, response]
|
78
|
+
end
|
34
79
|
|
35
|
-
|
80
|
+
private
|
36
81
|
|
37
|
-
|
38
|
-
|
82
|
+
def toolbar_links
|
83
|
+
DevToolbar.configuration.links.map do |link|
|
84
|
+
"<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
|
85
|
+
end.join(' ')
|
39
86
|
end
|
40
87
|
end
|
41
88
|
end
|
data/lib/dev_toolbar/version.rb
CHANGED
data/lib/dev_toolbar.rb
CHANGED
@@ -1,6 +1,19 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "dev_toolbar/version"
|
4
|
+
require_relative "dev_toolbar/railtie"
|
5
|
+
require_relative "dev_toolbar/middleware"
|
6
|
+
require_relative "dev_toolbar/configuration"
|
7
|
+
|
4
8
|
module DevToolbar
|
5
|
-
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
11
|
+
class << self
|
12
|
+
attr_accessor :configuration
|
13
|
+
|
14
|
+
def configure
|
15
|
+
self.configuration ||= Configuration.new
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
end
|
6
19
|
end
|
metadata
CHANGED
@@ -1,65 +1,76 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_toolbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
9
|
-
bindir:
|
7
|
+
- Ben Purinton
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '7.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '7.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '13.0'
|
48
|
+
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
description:
|
54
|
+
version: '13.0'
|
55
|
+
description: A sticky toolbar for Rails applications in development mode
|
42
56
|
email:
|
43
|
-
-
|
57
|
+
- ben@firstdraft.com
|
44
58
|
executables: []
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
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
62
|
- lib/dev_toolbar.rb
|
54
|
-
- lib/dev_toolbar/
|
55
|
-
- lib/dev_toolbar/engine.rb
|
63
|
+
- lib/dev_toolbar/configuration.rb
|
56
64
|
- lib/dev_toolbar/middleware.rb
|
65
|
+
- lib/dev_toolbar/railtie.rb
|
57
66
|
- lib/dev_toolbar/version.rb
|
58
67
|
homepage: https://github.com/firstdraft
|
59
68
|
licenses:
|
60
69
|
- MIT
|
61
|
-
metadata:
|
62
|
-
|
70
|
+
metadata:
|
71
|
+
homepage_uri: https://github.com/firstdraft
|
72
|
+
source_code_uri: https://github.com/firstdraft/dev_toolbar
|
73
|
+
post_install_message:
|
63
74
|
rdoc_options: []
|
64
75
|
require_paths:
|
65
76
|
- lib
|
@@ -67,16 +78,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
78
|
requirements:
|
68
79
|
- - ">="
|
69
80
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
81
|
+
version: 2.6.0
|
71
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
83
|
requirements:
|
73
84
|
- - ">="
|
74
85
|
- !ruby/object:Gem::Version
|
75
86
|
version: '0'
|
76
87
|
requirements: []
|
77
|
-
|
78
|
-
|
79
|
-
signing_key:
|
88
|
+
rubygems_version: 3.4.6
|
89
|
+
signing_key:
|
80
90
|
specification_version: 4
|
81
|
-
summary:
|
91
|
+
summary: A development toolbar for Rails applications.
|
82
92
|
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
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
DELETED
@@ -1,16 +0,0 @@
|
|
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
DELETED
@@ -1,36 +0,0 @@
|
|
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
|
@@ -1,76 +0,0 @@
|
|
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
|
-
|
@@ -1,11 +0,0 @@
|
|
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/engine.rb
DELETED
@@ -1,49 +0,0 @@
|
|
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
|