From 40f441c89ee97102b16b1784a2b1544a40a66734 Mon Sep 17 00:00:00 2001
From: Gareth Rees
Date: Wed, 12 Mar 2014 10:34:12 +0000
Subject: Correctly call helpers in RequestController#describe_state
Calling simple_date threw an exception as it uses a helper internally.
Only LinkToHelper is included in to the controller, so the underlying
helper was not available.
---
app/controllers/request_controller.rb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index a94461758..6445dd685 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -447,9 +447,9 @@ class RequestController < ApplicationController
flash[:notice] = case info_request.calculate_status
when 'waiting_response'
_("Thank you! Hopefully your wait isn't too long.
By law, you should get a response promptly, and normally before the end of
-{{date_response_required_by}}.
",:date_response_required_by=>simple_date(info_request.date_response_required_by))
+{{date_response_required_by}}.
",:date_response_required_by=>view_context.simple_date(info_request.date_response_required_by))
when 'waiting_response_overdue'
- _("Thank you! Hope you don't have to wait much longer.
By law, you should have got a response promptly, and normally before the end of {{date_response_required_by}}.
",:date_response_required_by=>simple_date(info_request.date_response_required_by))
+ _("Thank you! Hope you don't have to wait much longer.
By law, you should have got a response promptly, and normally before the end of {{date_response_required_by}}.
",:date_response_required_by=>view_context.simple_date(info_request.date_response_required_by))
when 'waiting_response_very_overdue'
_("Thank you! Your request is long overdue, by more than {{very_late_number_of_days}} working days. Most requests should be answered within {{late_number_of_days}} working days. You might like to complain about this, see below.
", :very_late_number_of_days => AlaveteliConfiguration::reply_very_late_after_days, :late_number_of_days => AlaveteliConfiguration::reply_late_after_days)
when 'not_held'
--
cgit v1.2.3
From b6561750b971030767a0e8146be1414471518086 Mon Sep 17 00:00:00 2001
From: Gareth Rees
Date: Wed, 19 Mar 2014 11:40:59 +0000
Subject: Use AttachmentToHTML to generate FoiAttachment#body_as_html
---
app/controllers/request_controller.rb | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
(limited to 'app/controllers/request_controller.rb')
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 6445dd685..d4c303e52 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -763,18 +763,22 @@ class RequestController < ApplicationController
key_path = foi_fragment_cache_path(key)
image_dir = File.dirname(key_path)
FileUtils.mkdir_p(image_dir)
- html, wrapper_id = @attachment.body_as_html(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"
- html.sub!(//i, "" + view_html_stylesheet)
- html.sub!(/]*>/i, '')
- html.sub!(/<\/body[^>]*>/i, '
')
+ view_html_stylesheet = render_to_string(:partial => "request/view_html_stylesheet")
+ view_html_prefix = render_to_string(:partial => "request/view_html_prefix")
- view_html_prefix = render_to_string :partial => "request/view_html_prefix"
- html.sub!("", view_html_prefix)
- html.sub!("", CGI.escape(@attachment_url))
+ # 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
@incoming_message.html_mask_stuff!(html)
+
response.content_type = 'text/html'
render :text => html
end
--
cgit v1.2.3
From 9f283e2e48e859d1ba6a31baa783feb177cccb17 Mon Sep 17 00:00:00 2001
From: Gareth Rees
Date: Wed, 2 Apr 2014 17:43:04 +0100
Subject: Update gubbins to call AttachmentToHTML
---
app/controllers/request_controller.rb | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
(limited to 'app/controllers/request_controller.rb')
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)
--
cgit v1.2.3