Skip to content

Commit

Permalink
Disable middleware if Propshaft is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasSkywalker committed Aug 12, 2023
1 parent 01b70de commit 40bbf24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/heavens_door/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class Engine < ::Rails::Engine #:nodoc:
initializer 'HeavensDoor' do |app|
app.middleware.use HeavensDoor::Middleware

app.config.assets.precompile += %w(heavens_door.js heavens_door.css)
if !defined?(Propshaft)
app.config.assets.precompile += %w(heavens_door.js heavens_door.css)
end
end
end
end
4 changes: 3 additions & 1 deletion lib/heavens_door/middleware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def call(env)
end

body = body.dup if body.frozen?
body.sub!(/<\/head[^>]*>/) { %Q[<link rel="stylesheet" href="#{Rails.application.config.assets.prefix}/heavens_door.css" /><script src="#{Rails.application.config.assets.prefix}/heavens_door.js"></script>\n#{$~}] }
if !defined?(Propshaft)
body.sub!(/<\/head[^>]*>/) { %Q[<link rel="stylesheet" href="#{Rails.application.config.assets.prefix}/heavens_door.css" /><script src="#{Rails.application.config.assets.prefix}/heavens_door.js"></script>\n#{$~}] }
end
body.sub!(/<body[^>]*>/) { %Q[#{$~}\n<div id="heavens-door" class="heavens-door-custom"><span id="heavens-door-open" class="heavens-door-button">⏺</span><span id="heavens-door-close" class="heavens-door-button">⏹</span><span id="heavens-door-copy" class="heavens-door-button">📋</span></div>] }

[status, headers, [body]]
Expand Down

0 comments on commit 40bbf24

Please sign in to comment.