aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/request_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/request_controller.rb')
-rw-r--r--app/controllers/request_controller.rb21
1 files changed, 8 insertions, 13 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index d4c303e52..d66c28275 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -763,19 +763,14 @@ class RequestController < ApplicationController
key_path = foi_fragment_cache_path(key)
image_dir = File.dirname(key_path)
FileUtils.mkdir_p(image_dir)
- html = @attachment.body_as_html(image_dir, :attachment_url => CGI.escape(@attachment_url))
-
- view_html_stylesheet = render_to_string(:partial => "request/view_html_stylesheet")
- view_html_prefix = render_to_string(:partial => "request/view_html_prefix")
-
- # Parse the generated HTML so we can inject more stuff
- parsed = Nokogiri::HTML.parse(html)
- # Insert the stylesheet in the head
- parsed.css('head').children.after(view_html_stylesheet)
- # Insert the content prefix
- parsed.css('body').children.before(view_html_prefix)
- # Get the raw html to render
- html = parsed.to_html
+
+ html = @attachment.body_as_html(image_dir,
+ :attachment_url => Rack::Utils.escape(@attachment_url),
+ :content_for => {
+ :head_suffix => render_to_string(:partial => "request/view_html_stylesheet"),
+ :body_prefix => render_to_string(:partial => "request/view_html_prefix")
+ }
+ )
@incoming_message.html_mask_stuff!(html)