Records package: intact status-report styles, no in-app controls; on-condition TSO

- Inlining CSS used String#sub with a replacement string, so "\&" in
  escaped selectors became "</head>"; use block replacements
- Packaged status report and procedures omit the Back link, the print
  button and the favicon link (they don't work outside the app)
- Status report: "On condition (Part 91)" as Tracked as, with remaining
  hours shown for reference; on condition clears the hard-limit flag

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 17:21:58 -05:00
1 parent 2fe2f464c1
commit 5471b9317f
6 files changed
+31 -7

No files matched your search

+4 -3
View File
@@ -95,16 +95,17 @@ class RecordsPackage
# The status report as one self-contained HTML file (styles inlined).
def status_report_html
inline_styles(ApplicationController.render("maintenance_reports/show", layout: "report", assigns: { report: MaintenanceReport.new(@aircraft) }))
inline_styles(ApplicationController.render("maintenance_reports/show", layout: "report", assigns: { report: MaintenanceReport.new(@aircraft), standalone: true }))
end
def standalone_html(body, title)
inline_styles(ApplicationController.render(html: body.html_safe, layout: "report", assigns: {}).sub(%r{<title>.*?</title>}m, "<title>#{ERB::Util.h(title)}</title>"))
inline_styles(ApplicationController.render(html: body.html_safe, layout: "report", assigns: { standalone: true }).sub(%r{<title>.*?</title>}m) { "<title>#{ERB::Util.h(title)}</title>" })
end
def inline_styles(html)
css = %w[tailwind.css application.css].filter_map { Rails.application.assets.load_path.find(_1)&.content }.join("\n")
html.gsub(%r{<link rel="stylesheet"[^>]*>\s*}, "").sub("</head>", "<style>#{css}</style></head>")
# Block forms: a replacement string would treat "\\&" etc. in the CSS as back-references.
html.gsub(%r{<link rel="stylesheet"[^>]*>\s*}) { "" }.sub("</head>") { "<style>#{css}</style></head>" }
.gsub(%r{<script\b[^>]*>.*?</script>}m, "").gsub(%r{<link rel="modulepreload"[^>]*>\s*}, "")
end
end