-
Notifications
You must be signed in to change notification settings - Fork 0
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
Full rewrite #1
Merged
Merged
Full rewrite #1
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fdd1f8b
update authorship
bpurinton fba287d
another gemspec update
bpurinton b89584a
basic setup
bpurinton 1fdb09e
use relative file paths in railtie
bpurinton d69b7c0
add configuration
bpurinton 7e6db0d
fix railtie
bpurinton ed09fae
update readme
bpurinton e6329f6
another readme update
bpurinton bf894a8
move CSS to css file
bpurinton d969cc1
change padding?
bpurinton 60ab084
fix path?
bpurinton 0d7d968
remove app directory, no stylesheet
bpurinton 73df543
fix css
bpurinton d309817
open in new tab
bpurinton fa37201
require relative
bpurinton 748179d
remove some uneccessary files
bpurinton c3233ac
implement as middleware
bpurinton ef134f7
update readme
bpurinton 82cdcc3
cleanup styles
bpurinton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
dev_toolbar (0.1.0) | ||
rails (~> 7.0) | ||
|
||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
actioncable (7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
nio4r (~> 2.0) | ||
websocket-driver (>= 0.6.1) | ||
zeitwerk (~> 2.6) | ||
actionmailbox (7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
activejob (= 7.1.3.3) | ||
activerecord (= 7.1.3.3) | ||
activestorage (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
mail (>= 2.7.1) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
actionmailer (7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
actionview (= 7.1.3.3) | ||
activejob (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
mail (~> 2.5, >= 2.5.4) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
rails-dom-testing (~> 2.2) | ||
actionpack (7.1.3.3) | ||
actionview (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
nokogiri (>= 1.8.5) | ||
racc | ||
rack (>= 2.2.4) | ||
rack-session (>= 1.0.1) | ||
rack-test (>= 0.6.3) | ||
rails-dom-testing (~> 2.2) | ||
rails-html-sanitizer (~> 1.6) | ||
actiontext (7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
activerecord (= 7.1.3.3) | ||
activestorage (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
globalid (>= 0.6.0) | ||
nokogiri (>= 1.8.5) | ||
actionview (7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
builder (~> 3.1) | ||
erubi (~> 1.11) | ||
rails-dom-testing (~> 2.2) | ||
rails-html-sanitizer (~> 1.6) | ||
activejob (7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
globalid (>= 0.3.6) | ||
activemodel (7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
activerecord (7.1.3.3) | ||
activemodel (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
timeout (>= 0.4.0) | ||
activestorage (7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
activejob (= 7.1.3.3) | ||
activerecord (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
marcel (~> 1.0) | ||
activesupport (7.1.3.3) | ||
base64 | ||
bigdecimal | ||
concurrent-ruby (~> 1.0, >= 1.0.2) | ||
connection_pool (>= 2.2.5) | ||
drb | ||
i18n (>= 1.6, < 2) | ||
minitest (>= 5.1) | ||
mutex_m | ||
tzinfo (~> 2.0) | ||
base64 (0.2.0) | ||
bigdecimal (3.1.8) | ||
builder (3.2.4) | ||
concurrent-ruby (1.3.1) | ||
connection_pool (2.4.1) | ||
crass (1.0.6) | ||
date (3.3.4) | ||
drb (2.2.1) | ||
erubi (1.12.0) | ||
globalid (1.2.1) | ||
activesupport (>= 6.1) | ||
i18n (1.14.5) | ||
concurrent-ruby (~> 1.0) | ||
io-console (0.7.2) | ||
irb (1.13.1) | ||
rdoc (>= 4.0.0) | ||
reline (>= 0.4.2) | ||
loofah (2.22.0) | ||
crass (~> 1.0.2) | ||
nokogiri (>= 1.12.0) | ||
mail (2.8.1) | ||
mini_mime (>= 0.1.1) | ||
net-imap | ||
net-pop | ||
net-smtp | ||
marcel (1.0.4) | ||
mini_mime (1.1.5) | ||
minitest (5.23.1) | ||
mutex_m (0.2.0) | ||
net-imap (0.4.11) | ||
date | ||
net-protocol | ||
net-pop (0.1.2) | ||
net-protocol | ||
net-protocol (0.2.2) | ||
timeout | ||
net-smtp (0.5.0) | ||
net-protocol | ||
nio4r (2.7.3) | ||
nokogiri (1.16.5-x86_64-darwin) | ||
racc (~> 1.4) | ||
psych (5.1.2) | ||
stringio | ||
racc (1.8.0) | ||
rack (3.0.11) | ||
rack-session (2.0.0) | ||
rack (>= 3.0.0) | ||
rack-test (2.1.0) | ||
rack (>= 1.3) | ||
rackup (2.1.0) | ||
rack (>= 3) | ||
webrick (~> 1.8) | ||
rails (7.1.3.3) | ||
actioncable (= 7.1.3.3) | ||
actionmailbox (= 7.1.3.3) | ||
actionmailer (= 7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
actiontext (= 7.1.3.3) | ||
actionview (= 7.1.3.3) | ||
activejob (= 7.1.3.3) | ||
activemodel (= 7.1.3.3) | ||
activerecord (= 7.1.3.3) | ||
activestorage (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
bundler (>= 1.15.0) | ||
railties (= 7.1.3.3) | ||
rails-dom-testing (2.2.0) | ||
activesupport (>= 5.0.0) | ||
minitest | ||
nokogiri (>= 1.6) | ||
rails-html-sanitizer (1.6.0) | ||
loofah (~> 2.21) | ||
nokogiri (~> 1.14) | ||
railties (7.1.3.3) | ||
actionpack (= 7.1.3.3) | ||
activesupport (= 7.1.3.3) | ||
irb | ||
rackup (>= 1.0.0) | ||
rake (>= 12.2) | ||
thor (~> 1.0, >= 1.2.2) | ||
zeitwerk (~> 2.6) | ||
rake (13.2.1) | ||
rdoc (6.7.0) | ||
psych (>= 4.0.0) | ||
reline (0.5.8) | ||
io-console (~> 0.5) | ||
stringio (3.1.0) | ||
thor (1.3.1) | ||
timeout (0.4.1) | ||
tzinfo (2.0.6) | ||
concurrent-ruby (~> 1.0) | ||
webrick (1.8.1) | ||
websocket-driver (0.7.6) | ||
websocket-extensions (>= 0.1.0) | ||
websocket-extensions (0.1.5) | ||
zeitwerk (2.6.15) | ||
|
||
PLATFORMS | ||
x86_64-darwin-22 | ||
|
||
DEPENDENCIES | ||
bundler (~> 2.0) | ||
dev_toolbar! | ||
rake (~> 13.0) | ||
|
||
BUNDLED WITH | ||
2.4.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "dev_toolbar/version" | ||
require_relative "dev_toolbar/railtie" | ||
require_relative "dev_toolbar/middleware" | ||
require_relative "dev_toolbar/configuration" | ||
|
||
module DevToolbar | ||
class Error < StandardError; end | ||
# Your code goes here... | ||
|
||
class << self | ||
attr_accessor :configuration | ||
|
||
def configure | ||
self.configuration ||= Configuration.new | ||
yield(configuration) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module DevToolbar | ||
class Configuration | ||
attr_accessor :links | ||
|
||
def initialize | ||
@links = [] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module DevToolbar | ||
class Middleware | ||
def initialize(app) | ||
@app = app | ||
end | ||
|
||
def call(env) | ||
status, headers, response = @app.call(env) | ||
|
||
if Rails.env.development? && headers["Content-Type"]&.include?("text/html") | ||
response_body = response.body | ||
toolbar_html = <<-HTML | ||
<div id="dev-toolbar" style="position: fixed; right: 0; top: 0; background: #333; color: #fff; padding: 0.5rem; z-index: 1000;"> | ||
#{toolbar_links} | ||
</div> | ||
<style> | ||
#dev-toolbar a { | ||
color: #fff; | ||
margin-right: 0.5rem; | ||
} | ||
</style> | ||
HTML | ||
|
||
response_body.sub!('</body>', "#{toolbar_html}</body>") | ||
headers["Content-Length"] = response_body.bytesize.to_s | ||
|
||
response = [response_body] | ||
end | ||
|
||
[status, headers, response] | ||
end | ||
|
||
private | ||
|
||
def toolbar_links | ||
DevToolbar.configuration.links.map do |link| | ||
"<a href='#{link[:path]}' target='_blank'>#{link[:name]}</a>" | ||
end.join(' ') | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Modifying the response body directly can lead to issues with streaming responses or responses that are already gzipped. Consider handling different response types more robustly, possibly by using a more sophisticated approach to modify the response only if it's a complete HTML document and not encoded in a way that would break by simple string substitution.