aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb4
-rw-r--r--app/models/incoming_message.rb10
-rw-r--r--public/stylesheets/main.css32
3 files changed, 28 insertions, 18 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index d2500dc21..6488ad726 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -578,11 +578,11 @@ class RequestController < ApplicationController
# the same cache code in cache_attachments above will display them.
image_dir = File.dirname(ActionController::Base.cache_store.cache_path + "/views" + url_for(params.merge(:only_path => true)))
FileUtils.mkdir_p(image_dir)
- html, wrapper_class = @attachment.body_as_html(image_dir)
+ html, wrapper_id = @attachment.body_as_html(image_dir)
view_html_stylesheet = render_to_string :partial => "request/view_html_stylesheet"
html.sub!(/<head>/i, "<head>" + view_html_stylesheet)
- html.sub!(/<body[^>]*>/i, '<body><prefix-here><div id="wrapper" class="' + wrapper_class + '"><div id="view_html_content">')
+ html.sub!(/<body[^>]*>/i, '<body><prefix-here><div id="' + wrapper_id + '"><div id="view_html_content">')
html.sub!(/<\/body[^>]*>/i, '</div></div></body>')
view_html_prefix = render_to_string :partial => "request/view_html_prefix"
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 242fc3ebf..4bab7b6ec 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -341,7 +341,7 @@ class FOIAttachment
# For "View as HTML" of attachment
def body_as_html(dir)
html = nil
- wrapper_class = "default_output"
+ wrapper_id = "wrapper"
# simple cases, can never fail
if self.content_type == 'text/plain'
@@ -349,7 +349,7 @@ class FOIAttachment
text = CGI.escapeHTML(text)
text = MySociety::Format.make_clickable(text)
html = text.gsub(/\n/, '<br>')
- return "<html><head></head><body>" + html + "</body></html>", wrapper_class
+ return "<html><head></head><body>" + html + "</body></html>", wrapper_id
end
# the extractions will also produce image files, which go in the
@@ -368,7 +368,7 @@ class FOIAttachment
elsif self.content_type == 'application/vnd.ms-excel'
IO.popen("/usr/bin/xlhtml -a " + tempfile.path + "", "r") do |child|
html = child.read()
- wrapper_class = "xhtml_output"
+ wrapper_id = "wrapper_xlhtml"
end
elsif self.content_type == 'application/pdf'
IO.popen("/usr/bin/pdftohtml -nodrm -zoom 1.0 -stdout -enc UTF-8 -noframes " + tempfile.path + "", "r") do |child|
@@ -398,10 +398,10 @@ class FOIAttachment
body_without_tags = body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "")
contains_images = html.match(/<img/mi) ? true : false
if !$?.success? || html.size == 0 || (body_without_tags.size == 0 && !contains_images)
- return "<html><head></head><body><p>Sorry, the conversion to HTML failed. Please use the download link at the top right.</p></body></html>"
+ return "<html><head></head><body><p>Sorry, the conversion to HTML failed. Please use the download link at the top right.</p></body></html>", wrapper_id
end
- return html, wrapper_class
+ return html, wrapper_id
end
end
diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css
index 71f9fa81d..ef6ed7adf 100644
--- a/public/stylesheets/main.css
+++ b/public/stylesheets/main.css
@@ -215,7 +215,7 @@ body
}
-/*------------------------------------------------ wrapper round view HTML version of attachments */
+/*------------------------------------------------ wrapper round content */
#wrapper
{
@@ -223,35 +223,45 @@ body
clear: both;
top: 0px;
padding-top: 100px;
+ width: 53em;
margin: 0px auto 1.2em auto;
/* = 800px at default size? so 1em = 16px*/
text-align: left;
overflow: visible;
}
-.default_output {
- width: 53em;
-}
-.xhtml_output {
+
+/*------------------------------------------------ view as HTML */
+/* XXX this copies lines from #wrapper above, as didn't want to break wrapper
+ * right now */
+#wrapper_xlhtml {
+ position: relative;
+ clear: both;
+ top: 0px;
+ padding-top: 100px;
width: 90%;
+ margin: 0px auto 1.2em auto;
+ /* = 800px at default size? so 1em = 16px*/
+ text-align: left;
+ overflow: visible;
}
-#wrapper table {
+#view_html_content table {
border-collapse: collapse;
margin-bottom: 1em;
}
-#wrapper td, th {
+#view_html_content td, th {
border: solid 1px #000000;
}
-#wrapper td {
+#view_html_content td {
vertical-align: top
}
-#wrapper td {
+#view_html_content td {
max-width: 30em;
overflow: auto;
}
-#wrapper tr:nth-child(odd) {
+#view_html_content tr:nth-child(odd) {
background-color: #bbbbbb;
}
-#wrapper tr:nth-child(even) {
+#view_html_content tr:nth-child(even) {
background-color: #dddddd;
}