aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfrancis <francis>2008-01-22 14:04:16 +0000
committerfrancis <francis>2008-01-22 14:04:16 +0000
commitea164e30e274dc712820e9ece6e9a50d5b52ef45 (patch)
treebb9d65772b921dc921210827eedad7b26e9c8375
parent1dc0cfc0dc6a431b35f796b70bdf6cbb1bce7b1e (diff)
Some tidy ups.
Reduce overzealous disclaimer quoting.
-rw-r--r--app/models/incoming_message.rb35
-rw-r--r--todo.txt8
2 files changed, 25 insertions, 18 deletions
diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb
index 0ff62fa53..974da2a42 100644
--- a/app/models/incoming_message.rb
+++ b/app/models/incoming_message.rb
@@ -20,7 +20,12 @@
# 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.32 2008-01-22 13:46:53 francis Exp $
+# $Id: incoming_message.rb,v 1.33 2008-01-22 14:04:16 francis Exp $
+
+
+# TODO
+# Move some of the (e.g. quoting) functions here into rblib, as they feel
+# general not specific to IncomingMessage.
module TMail
class Mail
@@ -45,6 +50,16 @@ class IncomingMessage < ActiveRecord::Base
has_many :outgoing_message_followups, :class_name => OutgoingMessage
+ # Return the structured TMail::Mail object
+ # Documentation at http://i.loveruby.net/en/projects/tmail/doc/
+ def mail
+ if @mail.nil? && !self.raw_data.nil?
+ @mail = TMail::Mail.parse(self.raw_data)
+ @mail.base64_decode
+ end
+ @mail
+ end
+
# Number the attachments in depth first tree order, for use in URLs.
def after_initialize
if !self.mail.nil?
@@ -62,7 +77,7 @@ class IncomingMessage < ActiveRecord::Base
part.url_part_number = @count_parts_count
end
end
- # And look up by URL part number
+ # And look up by URL part number to get an attachment
def self.get_attachment_by_url_part_number(attachments, found_url_part_number)
@count_parts_count = 0
attachments.each do |a|
@@ -73,16 +88,6 @@ class IncomingMessage < ActiveRecord::Base
return nil
end
- # Return the structured TMail::Mail object
- # Documentation at http://i.loveruby.net/en/projects/tmail/doc/
- def mail
- if @mail.nil? && !self.raw_data.nil?
- @mail = TMail::Mail.parse(self.raw_data)
- @mail.base64_decode
- end
- @mail
- end
-
# Return date mail was sent
def sent_at
# Use date it arrived (created_at) if mail itself doesn't have Date: header
@@ -132,7 +137,9 @@ class IncomingMessage < ActiveRecord::Base
text.gsub!(/^(On .+ (wrote|said):\n)/, replacement)
# Multiple line sections
- text.gsub!(/(\s*[-_]{20,}\n.*?disclaimer.*?[-_]{20,}\n)/im, "\n\n" + replacement)
+ ['-', '_'].each do |score|
+ text.gsub!(/(\s*#{score}{20,}\n.*?disclaimer:\n.*?#{score}{20,}\n)/im, "\n\n" + replacement)
+ end
# To end of message sections
original_message =
@@ -240,7 +247,7 @@ class IncomingMessage < ActiveRecord::Base
text = CGI.escapeHTML(text)
text = MySociety::Format.make_clickable(text, :contract => 1)
if collapse_quoted_sections
- text = text.gsub(/(FOLDED_QUOTED_SECTION\s*)+/m, '<span class="unfold_link"><a href="?unfold=1">show quoted sections</a></span>' + "\n")
+ text = text.gsub(/(\s*FOLDED_QUOTED_SECTION\s*)+/m, "\n\n" + '<span class="unfold_link"><a href="?unfold=1">show quoted sections</a></span>' + "\n")
else
if folded_quoted_text.include?('FOLDED_QUOTED_SECTION')
text = text + "\n\n" + '<span class="unfold_link"><a href="?">hide quoted sections</a></span>'
diff --git a/todo.txt b/todo.txt
index 073e3ea2a..28b5084cd 100644
--- a/todo.txt
+++ b/todo.txt
@@ -79,14 +79,12 @@ Show due date on, e.g.
http://foi.mysociety.org/request/4
Sort by due date, show categorisation everywhere
-Properly escape all name_and_email functions
+Sort the requests by when something last happened to them (this needs thought as to what
+sort orders we need)
Check out all automatically things here:
http://foi.mysociety.org/request/14
-Sort the requests by when something last happened to them (this needs thought as to what
-sort orders we need)
-
Tidying
=======
@@ -205,6 +203,8 @@ Forgotten password link
Way of contacting other users
+Properly escape all name_and_email functions
+
Give hotline to call body for extra help
Advice and assistance in making FoI requests to the House of Lords is available
from the Freedom of Information Officer, Parliamentary Archives, House of