diff options
-rw-r--r-- | app/controllers/request_controller.rb | 11 | ||||
-rw-r--r-- | app/models/incoming_message.rb | 14 | ||||
-rw-r--r-- | todo.txt | 2 |
3 files changed, 14 insertions, 13 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 2789fed97..15e39bf59 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.124 2008-10-17 20:32:42 francis Exp $ +# $Id: request_controller.rb,v 1.125 2008-10-17 20:43:25 francis Exp $ class RequestController < ApplicationController @@ -405,13 +405,12 @@ class RequestController < ApplicationController html = @attachment.body_as_html view_html_stylesheet = render_to_string :partial => "request/view_html_stylesheet" - html.sub!("<head>", "<head>" + view_html_stylesheet) + html.sub!(/<head>/i, "<head>" + view_html_stylesheet) + html.sub!(/<body[^>]*>/i, '<body><prefix-here><div id="wrapper"><div id="view_html_content">' + view_html_stylesheet) + html.sub!(/<\/body[^>]*>/i, '</div></div></body>' + view_html_stylesheet) view_html_prefix = render_to_string :partial => "request/view_html_prefix" - html.sub!("<!--Section Begins-->", view_html_prefix + "<!--Section Begins-->") - - html.sub!("<!--Section Begins-->", '<!--Section Begins--><div class="view_html_content">') - html.sub!("<!--Section Ends->", '</div><!--Section Begins-->') + html.sub!("<prefix-here>", view_html_prefix) # 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) diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index f76479f65..a6ca692c8 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -19,7 +19,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: incoming_message.rb,v 1.153 2008-10-17 20:32:42 francis Exp $ +# $Id: incoming_message.rb,v 1.154 2008-10-17 20:43:25 francis Exp $ # TODO # Move some of the (e.g. quoting) functions here into rblib, as they feel @@ -172,10 +172,10 @@ class FOIAttachment system("/usr/bin/wvHtml " + tempfile.path + " " + tempfile.path + ".html") html = File.read(tempfile.path + ".html") File.unlink(tempfile.path + ".html") -# elsif content_type == 'application/pdf' -# IO.popen("/usr/bin/pdftohtml " + tempfile.path + " -", "r") do |child| -# html = child.read() + "\n\n" -# end + elsif content_type == 'application/pdf' + IO.popen("/usr/bin/pdftohtml -stdout -enc UTF-8 -noframes " + tempfile.path + "", "r") do |child| + html = child.read() + "\n\n" + end else raise "No HTML conversion available for type " + content_type end @@ -187,8 +187,8 @@ class FOIAttachment def has_body_as_html? if content_type == 'application/vnd.ms-word' return true -# elsif content_type == 'application/pdf' -# return true + elsif content_type == 'application/pdf' + return true end return false end @@ -3,6 +3,8 @@ Test data for Tony Next ==== +Make HTML load read from cache file if present + Performance: Remove loading of public body tags from every info request load Completed in 15.53564 (0 reqs/sec) | Rendering: 1.03024 (6%) | DB: 14.46186 (93%) | 200 OK [http://www.whatdotheyknow.com/body/list/n] |