aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/request_controller.rb3
-rw-r--r--app/models/incoming_message.rb62
-rw-r--r--app/views/admin_public_body/_form.rhtml7
-rw-r--r--app/views/admin_public_body/edit.rhtml2
-rw-r--r--app/views/request/_bubble.rhtml4
-rw-r--r--app/views/request/_correspondence.rhtml10
-rw-r--r--app/views/request/show.rhtml67
7 files changed, 115 insertions, 40 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index 6cce879e7..8c6b854e7 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.20 2007-11-23 12:01:19 francis Exp $
+# $Id: request_controller.rb,v 1.21 2007-12-22 02:23:35 francis Exp $
class RequestController < ApplicationController
@@ -13,6 +13,7 @@ class RequestController < ApplicationController
@correspondences = @info_request.outgoing_messages + @info_request.incoming_messages
@correspondences.sort! { |a,b| a.sent_at <=> b.sent_at }
@status = @info_request.calculate_status
+ @collapse_quotes = params[:unfold] ? false : true
end
def list
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index f1ae68410..be65a4b60 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.7 2007-12-17 19:35:13 francis Exp $
+# $Id: incoming_message.rb,v 1.8 2007-12-22 02:23:35 francis Exp $
class IncomingMessage < ActiveRecord::Base
belongs_to :info_request
@@ -45,18 +45,68 @@ class IncomingMessage < ActiveRecord::Base
self.mail.date || self.created_at
end
- # Use this when displaying the body text
- def sanitised_body
- body = self.mail.body.dup
+ # Remove email addresses from text (mainly to reduce spam - particularly
+ # we want to stop spam to our own magic archiving request-* addresses,
+ # which would otherwise appear a lot in bounce messages and reply quotes etc.)
+ def self.email_filter(text)
+ text = text.dup
# Remove any email addresses - we don't want bounce messages to leak out
# either the requestor's email address or the request's response email
# address out onto the internet
rx = Regexp.new(MySociety::Validate.email_match_regexp)
- body.gsub!(rx, "...@...")
+ text.gsub!(rx, "...@...")
- return body
+ return text
end
+
+ # Remove quoted sections from emails (eventually the aim would be for this
+ # to do as good a job as GMail does) XXX bet it needs a proper parser
+ # XXX and this BEGIN_QUOTED / END_QUOTED stuff is a mess
+ def self.remove_email_quotage(text)
+ text = text.dup
+
+ text.gsub!(/^(>.+\n)/, "BEGIN_QUOTED\\1END_QUOTED")
+ text.gsub!(/^(On .+ wrote:\n)/, "BEGIN_QUOTED\\1END_QUOTED")
+
+ original_message =
+ '(' + '''------ This is a copy of the message, including all the headers. ------''' +
+ '|' + '''-----Original Message-----''' +
+ ')'
+
+ text.gsub!(/^(#{original_message}\n.*)$/m, "BEGIN_QUOTED\\1END_QUOTED")
+
+ return text
+ end
+
+ # Returns body text with quotes flattened, and emails removed.
+ def get_body_for_display(collapse_quoted_sections = true)
+ parts = self.mail.parts
+ if parts.size > 0
+ #return self.mail.parts[0].class.to_s
+ text = self.mail.body
+ else
+ text = self.mail.quoted_body
+ end
+
+ text = IncomingMessage.email_filter(text)
+ text = IncomingMessage.remove_email_quotage(text)
+ text = CGI.escapeHTML(text)
+ if collapse_quoted_sections
+ #text = text.gsub(/BEGIN_QUOTED/, '<span class="quoted_email">')
+ #text = text.gsub(/END_QUOTED/, '</span>')
+ text = text.gsub(/(BEGIN_QUOTED(.+?)END_QUOTED)+/m, '<a href="?unfold=1">show quoted sections</a>')
+ else
+ if text.include?('BEGIN_QUOTED')
+ text = text.gsub(/BEGIN_QUOTED(.+?)END_QUOTED/m, '\1')
+ text = text + '<a href="?">hide quoted sections</a>'
+ end
+ end
+ text = text.gsub(/\n/, '<br>')
+
+ return text
+ end
+
end
diff --git a/app/views/admin_public_body/_form.rhtml b/app/views/admin_public_body/_form.rhtml
index dda975d14..8b9eca34e 100644
--- a/app/views/admin_public_body/_form.rhtml
+++ b/app/views/admin_public_body/_form.rhtml
@@ -16,3 +16,10 @@
<%= text_area 'public_body', 'last_edit_comment', :rows => 3, :cols => 60 %></p>
<!--[eoform:public_body]-->
+<p><strong>Privacy note:</strong> The email addresses are assumed public data,
+so we can share the love around later. If somebody wants to give us a
+super-secret address (say to bypass spam traps) then we'll have to rethink
+this.
+</p>
+
+
diff --git a/app/views/admin_public_body/edit.rhtml b/app/views/admin_public_body/edit.rhtml
index 775c98a99..b38ff02b3 100644
--- a/app/views/admin_public_body/edit.rhtml
+++ b/app/views/admin_public_body/edit.rhtml
@@ -7,6 +7,8 @@
<%= submit_tag 'Save' %>
<% end %>
+<p>
<%= link_to 'Show', '../show/' + @public_body.id.to_s %> |
<%= link_to 'List all', '../list' %>
+</p>
diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.rhtml
index 0af5d7b21..8480693e3 100644
--- a/app/views/request/_bubble.rhtml
+++ b/app/views/request/_bubble.rhtml
@@ -1,11 +1,11 @@
<blockquote class="xsnazzy">
<b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b><b class="xb5"></b><b class="xb6"></b><b class="xb7"></b>
<div class="xboxcontent">
- <p><%= body.gsub(/\n/, '<br>') %></p>
+ <p><%= body %></p>
</div>
<b class="xb7"></b><b class="xb6"></b><b class="xb5"></b><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b>
<em></em>
- <span></span>
+ <span class="bubblebit"></span>
</blockquote>
diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml
index 7a85bb627..aa6b799fa 100644
--- a/app/views/request/_correspondence.rhtml
+++ b/app/views/request/_correspondence.rhtml
@@ -21,16 +21,18 @@
</p>
<% elsif (correspondence.class.to_s == 'IncomingMessage')
incoming_message = correspondence%>
- <%= render :partial => 'bubble', :locals => { :body => incoming_message.sanitised_body } %>
+ <%= render :partial => 'bubble', :locals => { :body => incoming_message.get_body_for_display(@collapse_quotes) } %>
<p class="xspeaker">
- <%= incoming_message.mail.friendly_from %>
- of <%= public_body_link(@info_request.public_body) %>
+ <% if incoming_message.mail.from %>
+ <%= incoming_message.mail.friendly_from %> of
+ <% end %>
+ <%= public_body_link(@info_request.public_body) %>
wrote a reply on <strong><%= simple_date(incoming_message.sent_at)
%></strong>
</p>
<% else %>
- <% raise "Unknown correspondence type" + correspondence.class.to_s %>
+ <% raise "Unknown correspondence type " + correspondence.class.to_s %>
<% end %>
</div>
diff --git a/app/views/request/show.rhtml b/app/views/request/show.rhtml
index 3b5a5c2bf..83e183c81 100644
--- a/app/views/request/show.rhtml
+++ b/app/views/request/show.rhtml
@@ -1,33 +1,46 @@
<% @title = h(@info_request.title) %>
-<h1><%=@title%></h1>
+<div id="request_main">
+ <h1><%=@title%></h1>
-<p class="subtitle">A Freedom of Information request to
-<%= public_body_link(@info_request.public_body) %>
-by
-<%= user_link(@info_request.user) %>
-</p>
+ <p class="subtitle">A Freedom of Information request to
+ <%= public_body_link(@info_request.public_body) %>
+ by
+ <%= user_link(@info_request.user) %>
+ </p>
-<p class="xspeaker">
-<% if @status == 'awaiting' %>
-Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %>
-<% elsif @status == 'overdue' %>
-Currently <strong>overdue a response</strong> from <%=
-public_body_link(@info_request.public_body) %>. Under section blah of the
-Freedom of Information Act 2000 responses must be made within 20 working days.
-<% elsif @status == 'information' %>
-The request was at least partly <strong>successful</strong>.
-<% elsif @status == 'none' %>
-The request is <strong>not (yet) successful</strong>.
-<% elsif @status == 'unknown' %>
-<strong>Response received</strong>, but <%= user_link(@info_request.user) %> has not yet reported if it was
-successful or a rejection.
-<% else %>
-<% raise "unknown status " + $status %>
-<% end %>
-</p>
+ <p id="request_status">
+ <% if @status == 'awaiting' %>
+ Currently <strong>waiting for a response</strong> from <%= public_body_link(@info_request.public_body) %>
+ <% elsif @status == 'overdue' %>
+ Currently <strong>overdue a response</strong> from <%=
+ public_body_link(@info_request.public_body) %>. Under section blah of the
+ Freedom of Information Act 2000 responses must be made within 20 working days.
+ <% elsif @status == 'information' %>
+ The request was at least partly <strong>successful</strong>.
+ <% elsif @status == 'none' %>
+ The request is <strong>not (yet) successful</strong>.
+ <% elsif @status == 'unknown' %>
+ <strong>Response received</strong>, but <%= user_link(@info_request.user) %> has not yet reported if it was
+ successful or a rejection.
+ <% else %>
+ <% raise "unknown status " + $status %>
+ <% end %>
+ </p>
+
+ <% for correspondence in @correspondences %>
+ <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %>
+ <% end %>
+</div>
+
+<div id="request_sidebar">
+ <h2>Juicy stuff will be here</h2>
+ <p>For now it is just padding to make the messages on the left
+ narrower, so I can see what the formatting is like.
+ <!--<h2>Blog posts about this request</h2>
+ <p>...
+ <h2>Wikipedia articles</h2>
+ <p>...-->
+</div>
-<% for correspondence in @correspondences %>
- <%= render :partial => 'correspondence', :locals => { :correspondence => correspondence } %>
-<% end %>