dev_toolbar 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a18b06fb4ebca9df093fe77b0fc00d329965a63016d5b96b7f1e014345d6e51
4
- data.tar.gz: 7d61f7d42ce4bfba5c5739fd869d4fcbe9799fcf18f013d1d203a10450169ab5
3
+ metadata.gz: '0878473f66d6e8b0886db7f6563d26c4d39584961c5695a11bf223f0857d54d3'
4
+ data.tar.gz: 5c40deeef8f49f7bca4484f16c757d253d4ebd33cbd2ec0466cb6c0c62697353
5
5
  SHA512:
6
- metadata.gz: 17c4d7b47ed6688e0c16af6bf5987bae26519d7705170adc265e8891449ef8b716f0dd81a9029ce7d32b138b59d5f08a9b489f001b88a96aabfe8841677713e6
7
- data.tar.gz: b4f95df36dbbceb5423713ac190a52fa332de5343ada45a4cc7e7cc2350cd23e4edd7b357c134a187a03529534715c90460ea723ffa9e5c646f79b8669042232
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
+ }
@@ -4,7 +4,7 @@ module DevToolbar
4
4
 
5
5
  def show
6
6
  @erd_path = Rails.root.join("erd.png")
7
- render :show
7
+ render "dev_toolbar/erd/show", formats: [:html]
8
8
  end
9
9
  end
10
10
  end
@@ -2,9 +2,25 @@ module DevToolbar
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace DevToolbar
4
4
 
5
- config.autoload_paths << File.expand_path("../app/controllers", __FILE__)
6
- config.paths["app/views"] << File.expand_path("../app/views", __FILE__)
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
- <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
- }
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!('</body>', "#{toolbar_html}</body>")
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 toolbar_links
83
- DevToolbar.configuration.links.map do |link|
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DevToolbar
4
- VERSION = "2.1.0"
4
+ VERSION = "3.0.0"
5
5
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dev_toolbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Purinton
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 2025-07-04 00:00:00.000000000 Z
11
+ date: 2026-06-11 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rails
@@ -58,9 +59,12 @@ executables: []
58
59
  extensions: []
59
60
  extra_rdoc_files: []
60
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
61
67
  - lib/dev_toolbar.rb
62
- - lib/dev_toolbar/app/controllers/dev_toolbar/erd_controller.rb
63
- - lib/dev_toolbar/app/views/dev_toolbar/erd/show.html.erb
64
68
  - lib/dev_toolbar/configuration.rb
65
69
  - lib/dev_toolbar/engine.rb
66
70
  - lib/dev_toolbar/middleware.rb
@@ -72,6 +76,7 @@ licenses:
72
76
  metadata:
73
77
  homepage_uri: https://github.com/firstdraft
74
78
  source_code_uri: https://github.com/firstdraft/dev_toolbar
79
+ post_install_message:
75
80
  rdoc_options: []
76
81
  require_paths:
77
82
  - lib
@@ -86,7 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
91
  - !ruby/object:Gem::Version
87
92
  version: '0'
88
93
  requirements: []
89
- rubygems_version: 3.6.5
94
+ rubygems_version: 3.5.16
95
+ signing_key:
90
96
  specification_version: 4
91
97
  summary: A development toolbar for Rails applications.
92
98
  test_files: []