From 756b4af9e5461fa7f5e85cff1947fd7c9dbc8638 Mon Sep 17 00:00:00 2001 From: Ben Purinton Date: Fri, 18 Oct 2024 13:28:50 -0700 Subject: [PATCH 1/5] Add view source button --- README.md | 1 + lib/dev_toolbar/middleware.rb | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0dda464..6d97bbe 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ Then, add a configuration file with the names and routes you want links for: # config/initializers/dev_toolbar.rb DevToolbar.configure do |config| config.links = [ + { name: "View Source", path: "/to-do" }, { name: "Routes", path: "/rails/info/routes" }, { name: "Database", path: "/rails/db" }, # rails_db gem must be installed { name: "Data Model", path: "/erd.png" }, # erd.png must be in public/ folder diff --git a/lib/dev_toolbar/middleware.rb b/lib/dev_toolbar/middleware.rb index 9b05b0d..a64f89b 100644 --- a/lib/dev_toolbar/middleware.rb +++ b/lib/dev_toolbar/middleware.rb @@ -8,6 +8,7 @@ def call(env) status, headers, response = @app.call(env) if Rails.env.development? && headers["Content-Type"]&.include?("text/html") + request = Rack::Request.new(env) response_body = response.body toolbar_html = <<-HTML
@@ -15,7 +16,7 @@ def call(env) 🛠️