From fd61d6e1c05f60e472910a70dfe3ac103f99db97 Mon Sep 17 00:00:00 2001 From: francis Date: Tue, 28 Oct 2008 17:58:47 +0000 Subject: Cache HTML versions of attachments --- app/controllers/request_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'app/controllers/request_controller.rb') diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index bb0d7f9bd..6b9ad780b 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -4,7 +4,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_controller.rb,v 1.130 2008-10-27 18:18:30 francis Exp $ +# $Id: request_controller.rb,v 1.131 2008-10-28 17:58:48 francis Exp $ class RequestController < ApplicationController @@ -402,14 +402,11 @@ class RequestController < ApplicationController render :text => @attachment.body end + caches_page :get_attachment_as_html def get_attachment_as_html get_attachment_internal html = @attachment.body_as_html - # Mask any more emails that have now been exposed (e.g. in PDFs - ones in - # .doc will have been got in get_attachment_internal below) - html = @incoming_message.binary_mask_stuff(html) - view_html_stylesheet = render_to_string :partial => "request/view_html_stylesheet" html.sub!(//i, "" + view_html_stylesheet) html.sub!(/]*>/i, '
' + view_html_stylesheet) @@ -437,6 +434,10 @@ class RequestController < ApplicationController # Prevent spam to magic request address. # XXX Bit dodgy modifying a binary like this but hey. Maybe only do for some mime types? @attachment.body = @incoming_message.binary_mask_stuff(@attachment.body) + + @attachment_url = get_attachment_url(:id => @incoming_message.info_request_id, + :incoming_message_id => @incoming_message.id, :part => @part_number, + :file_name => @filename ) end # FOI officers can upload a response -- cgit v1.2.3