Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
{ 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
Expand Down
6 changes: 5 additions & 1 deletion lib/dev_toolbar/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ def call(env)

def toolbar_links
DevToolbar.configuration.links.map do |link|
"<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
if link[:name] == "View Source"
"<a href='#' onclick='window.open(\"view-source:\" + window.location.href); return false;' class='dev-toolbar-link'>#{link[:name]}</a>"
else
"<a href='#{link[:path]}' target='_blank' class='dev-toolbar-link'>#{link[:name]}</a>"
end
end.join(' ')
end
end
Expand Down