Inject persistent top navbar (with printer switcher) into proxied Brother pages

This commit is contained in:
randy committed 2026-09-12 00:34:14 +02:00
1 parent daa39320a6
commit 1cc03d8451
3 files changed
+34 -22

No files matched your search

+6 -1
View File
@@ -102,13 +102,18 @@ helpers do
res = Net::HTTP.start(uri.host, uri.port) { |http| http.request(proxied) }
body = res.body || ''
if res['Content-Type']&.include?('text/html')
body = body.sub(/(<body[^>]*>)/i) { "#{Regexp.last_match(1)}\n#{erb(:_navbar, layout: false)}" }
end
headers = {}
res.each_header do |key, value|
next if %w[transfer-encoding connection content-length].include?(key.downcase)
headers[key] = value
end
[res.code.to_i, headers, [res.body || '']]
[res.code.to_i, headers, [body]]
end
end