dev_toolbar 2.0.0 → 3.0.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/app/assets/javascripts/dev_toolbar/index.js +34 -0
- data/app/assets/javascripts/dev_toolbar/toolbar.js +24 -0
- data/app/assets/stylesheets/dev_toolbar.css +41 -0
- data/{lib/dev_toolbar/app → app}/controllers/dev_toolbar/erd_controller.rb +1 -1
- data/lib/dev_toolbar/engine.rb +19 -3
- data/lib/dev_toolbar/middleware.rb +4 -66
- data/lib/dev_toolbar/version.rb +1 -1
- metadata +13 -10
- /data/{lib/dev_toolbar/app → app}/views/dev_toolbar/erd/show.html.erb +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '0878473f66d6e8b0886db7f6563d26c4d39584961c5695a11bf223f0857d54d3'
|
|
4
|
+
data.tar.gz: 5c40deeef8f49f7bca4484f16c757d253d4ebd33cbd2ec0466cb6c0c62697353
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9dae6df0741bd49164de32d1894027f49aac645e0c41b8cccdca2cffb5df36f96228a466950a7efe8cb3ba7043ff73e7512b5d44c67f48d46c9dd8eec6917995
|
|
7
|
+
data.tar.gz: d48f4130a4db41b7b9c5ca240f90daf199452a904eb706cc32ed4db94c5f620dfd28a6160fce77b1a8e78e979fe5f02573b047c55f68c88a0cae9f8a0d2a4d1a
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Toolbar from "dev_toolbar/toolbar"
|
|
2
|
+
|
|
3
|
+
function waitForElementToExist(selector) {
|
|
4
|
+
return new Promise(resolve => {
|
|
5
|
+
if (document.querySelector(selector)) {
|
|
6
|
+
return resolve(document.querySelector(selector));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const observer = new MutationObserver(() => {
|
|
10
|
+
if (document.querySelector(selector)) {
|
|
11
|
+
resolve(document.querySelector(selector));
|
|
12
|
+
observer.disconnect();
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
observer.observe(document.body, {
|
|
17
|
+
subtree: true,
|
|
18
|
+
childList: true,
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const loadEvent = self.hasOwnProperty("Turbo") ? "turbo:load" : "DOMContentLoaded";
|
|
23
|
+
|
|
24
|
+
document.addEventListener(loadEvent, function() {
|
|
25
|
+
if (!document.getElementById("dev-toolbar")) {
|
|
26
|
+
Toolbar.render();
|
|
27
|
+
}
|
|
28
|
+
waitForElementToExist("#dev-toolbar-toggle").then( () => {
|
|
29
|
+
document.getElementById("dev-toolbar-toggle").addEventListener("click", function() {
|
|
30
|
+
var links = document.getElementById("dev-toolbar-links");
|
|
31
|
+
links.classList.toggle("hidden");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export default class Toolbar {
|
|
2
|
+
static render() {
|
|
3
|
+
const configuration = document.querySelector("meta[name=dev_toolbar_config]")
|
|
4
|
+
const defined_links = JSON.parse(configuration.content)
|
|
5
|
+
let toolbar_links = ``
|
|
6
|
+
for (let index = 0; index < defined_links.length; index++) {
|
|
7
|
+
const link = defined_links[index];
|
|
8
|
+
toolbar_links += `<a href="${link.path}" target="_blank" class="dev-toolbar-link">${link.name}</a>`
|
|
9
|
+
}
|
|
10
|
+
const toolbar_html = `
|
|
11
|
+
<div id="dev-toolbar">
|
|
12
|
+
<div id="dev-toolbar-button">
|
|
13
|
+
<button id="dev-toolbar-toggle">🛠️</button>
|
|
14
|
+
</div>
|
|
15
|
+
<div id="dev-toolbar-links" class="hidden">
|
|
16
|
+
${toolbar_links}
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
`
|
|
20
|
+
document.body.insertAdjacentHTML('beforeend', toolbar_html)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
export { Toolbar }
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#dev-toolbar {
|
|
2
|
+
position: fixed;
|
|
3
|
+
right: 0;
|
|
4
|
+
top: 50vh;
|
|
5
|
+
transform: translateY(-50%);
|
|
6
|
+
background-color: #f0f0f0;
|
|
7
|
+
border: 1px solid #ccc;
|
|
8
|
+
z-index: 1000;
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
align-items: center;
|
|
12
|
+
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
|
|
13
|
+
color: #808080;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
#dev-toolbar-toggle {
|
|
17
|
+
all: unset;
|
|
18
|
+
font-size: 2em;
|
|
19
|
+
border: none;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
line-height: 1.5;
|
|
22
|
+
padding: 0 10px;
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#dev-toolbar-links {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.dev-toolbar-link {
|
|
32
|
+
padding: 5px 10px;
|
|
33
|
+
border-bottom: 1px #f0f0f0 solid;
|
|
34
|
+
color: #808080;
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
background-color: white;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#dev-toolbar-links.hidden {
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
data/lib/dev_toolbar/engine.rb
CHANGED
|
@@ -2,9 +2,25 @@ module DevToolbar
|
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
3
|
isolate_namespace DevToolbar
|
|
4
4
|
|
|
5
|
-
config.
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
config.assets.paths << root.join("app/assets/stylesheets")
|
|
6
|
+
|
|
7
|
+
initializer "dev_toolbar.assets_precompile", group: :all do |app|
|
|
8
|
+
# Only configure asset precompilation if Sprockets is available
|
|
9
|
+
if defined?(Sprockets) && app.config.respond_to?(:assets)
|
|
10
|
+
app.config.assets.precompile += [
|
|
11
|
+
"dev_toolbar/toolbar.js",
|
|
12
|
+
"dev_toolbar/index.js",
|
|
13
|
+
]
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
initializer "dev_toolbar.add_static_assets_middleware" do |app|
|
|
18
|
+
app.middleware.use ::Rack::Static,
|
|
19
|
+
# the url prefix to intercept
|
|
20
|
+
urls: ["/dev_toolbar"],
|
|
21
|
+
root: "#{root}/app/"
|
|
22
|
+
end
|
|
23
|
+
|
|
8
24
|
initializer "dev_toolbar.add_routes", after: :add_routing_paths do |app|
|
|
9
25
|
app.routes.append do
|
|
10
26
|
get "/erd", to: "dev_toolbar/erd#show"
|
|
@@ -10,65 +10,10 @@ module DevToolbar
|
|
|
10
10
|
if Rails.env.development? && headers["Content-Type"]&.include?("text/html")
|
|
11
11
|
response_body = response.body
|
|
12
12
|
toolbar_html = <<-HTML
|
|
13
|
-
<
|
|
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
|
-
}
|
|
50
|
-
|
|
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>
|
|
13
|
+
<meta name="dev_toolbar_config" content='#{toolbar_links_content}'>
|
|
69
14
|
HTML
|
|
70
15
|
|
|
71
|
-
response_body.sub!('</
|
|
16
|
+
response_body.sub!('</head>', "#{toolbar_html}</head>")
|
|
72
17
|
headers["Content-Length"] = response_body.bytesize.to_s
|
|
73
18
|
|
|
74
19
|
response = [response_body]
|
|
@@ -79,15 +24,8 @@ module DevToolbar
|
|
|
79
24
|
|
|
80
25
|
private
|
|
81
26
|
|
|
82
|
-
def
|
|
83
|
-
DevToolbar.configuration.links
|
|
84
|
-
# if the erd.png file does not exist in /public, don't show the link
|
|
85
|
-
if link[:name] == "ERD" && !File.exist?(Rails.root.join("erd.png"))
|
|
86
|
-
next
|
|
87
|
-
else
|
|
88
|
-
"<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
|
|
89
|
-
end
|
|
90
|
-
end.compact.join(" ")
|
|
27
|
+
def toolbar_links_content
|
|
28
|
+
JSON.generate(DevToolbar.configuration.links)
|
|
91
29
|
end
|
|
92
30
|
end
|
|
93
31
|
end
|
data/lib/dev_toolbar/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dev_toolbar
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 3.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Purinton
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-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
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
26
|
version: '7.0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
@@ -59,9 +59,12 @@ executables: []
|
|
|
59
59
|
extensions: []
|
|
60
60
|
extra_rdoc_files: []
|
|
61
61
|
files:
|
|
62
|
+
- app/assets/javascripts/dev_toolbar/index.js
|
|
63
|
+
- app/assets/javascripts/dev_toolbar/toolbar.js
|
|
64
|
+
- app/assets/stylesheets/dev_toolbar.css
|
|
65
|
+
- app/controllers/dev_toolbar/erd_controller.rb
|
|
66
|
+
- app/views/dev_toolbar/erd/show.html.erb
|
|
62
67
|
- lib/dev_toolbar.rb
|
|
63
|
-
- lib/dev_toolbar/app/controllers/dev_toolbar/erd_controller.rb
|
|
64
|
-
- lib/dev_toolbar/app/views/dev_toolbar/erd/show.html.erb
|
|
65
68
|
- lib/dev_toolbar/configuration.rb
|
|
66
69
|
- lib/dev_toolbar/engine.rb
|
|
67
70
|
- lib/dev_toolbar/middleware.rb
|
|
@@ -73,7 +76,7 @@ licenses:
|
|
|
73
76
|
metadata:
|
|
74
77
|
homepage_uri: https://github.com/firstdraft
|
|
75
78
|
source_code_uri: https://github.com/firstdraft/dev_toolbar
|
|
76
|
-
post_install_message:
|
|
79
|
+
post_install_message:
|
|
77
80
|
rdoc_options: []
|
|
78
81
|
require_paths:
|
|
79
82
|
- lib
|
|
@@ -88,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
88
91
|
- !ruby/object:Gem::Version
|
|
89
92
|
version: '0'
|
|
90
93
|
requirements: []
|
|
91
|
-
rubygems_version: 3.
|
|
92
|
-
signing_key:
|
|
94
|
+
rubygems_version: 3.5.16
|
|
95
|
+
signing_key:
|
|
93
96
|
specification_version: 4
|
|
94
97
|
summary: A development toolbar for Rails applications.
|
|
95
98
|
test_files: []
|
|
File without changes
|