diff options
-rw-r--r-- | app/models/info_request_event.rb | 8 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 16 | ||||
-rw-r--r-- | app/models/request_mailer.rb | 4 | ||||
-rw-r--r-- | app/views/layouts/contact_mailer.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/request_mailer.rhtml | 2 | ||||
-rw-r--r-- | app/views/layouts/user_mailer.rhtml | 2 | ||||
-rw-r--r-- | app/views/request/_correspondence.rhtml | 4 | ||||
-rw-r--r-- | app/views/track_mailer/event_digest.rhtml | 2 | ||||
-rw-r--r-- | spec/controllers/request_controller_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/request_mailer_spec.rb | 3 |
10 files changed, 15 insertions, 29 deletions
diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 8558ab676..024ed75f1 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -21,7 +21,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request_event.rb,v 1.93 2009-09-20 12:17:14 francis Exp $ +# $Id: info_request_event.rb,v 1.94 2009-10-04 21:42:07 francis Exp $ class InfoRequestEvent < ActiveRecord::Base belongs_to :info_request @@ -227,9 +227,9 @@ class InfoRequestEvent < ActiveRecord::Base if old_value != new_value: ret = ret + "<em>" + CGI.escapeHTML(key) + ":</em> " ret = ret + - CGI.escapeHTML(MySociety::Format.wrap_email_body(old_value).strip).gsub(/\n/, '<br>') + + CGI.escapeHTML(MySociety::Format.wrap_email_body_by_lines(old_value).strip).gsub(/\n/, '<br>') + " => " + - CGI.escapeHTML(MySociety::Format.wrap_email_body(new_value).strip).gsub(/\n/, '<br>') + CGI.escapeHTML(MySociety::Format.wrap_email_body_by_lines(new_value).strip).gsub(/\n/, '<br>') ret = ret + "<br>" end end @@ -238,8 +238,6 @@ class InfoRequestEvent < ActiveRecord::Base ret = ret + CGI.escapeHTML(value.to_s.strip) ret = ret + "<br>" end - # ret = ret + CGI.escapeHTML(a.to_s) + ":" + CGI.escapeHTML(b.to_s) + "<br>" - # ret = ret + self.params.to_yaml return ret end diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 77e4a596c..7de70fc17 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -22,7 +22,7 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: outgoing_message.rb,v 1.93 2009-10-03 10:05:55 francis Exp $ +# $Id: outgoing_message.rb,v 1.94 2009-10-04 21:42:07 francis Exp $ class OutgoingMessage < ActiveRecord::Base strip_attributes! @@ -214,25 +214,13 @@ class OutgoingMessage < ActiveRecord::Base def get_body_for_html_display text = self.body.strip self.remove_privacy_sensitive_things!(text) - text = MySociety::Format.wrap_email_body(text) # reparagraph and wrap it so is good preview of emails + text = MySociety::Format.wrap_email_body_by_lines(text) # reparagraph and wrap it so is good preview of emails text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text, :contract => 1) text.gsub!(/\[(email address|mobile number)\]/, '[<a href="/help/about#mobiles">\1</a>]') text = text.gsub(/\n/, '<br>') return text end - # Testing whether we can just wrap lines rather than between blank line separated paragraphs - def new_get_body_for_html_display - text = self.body.strip - self.remove_privacy_sensitive_things!(text) - text = MySociety::Format.wrap_email_body(text, 67, " ", "\n") # reparagraph and wrap it so is good preview of emails - text = CGI.escapeHTML(text) - text = MySociety::Format.make_clickable(text, :contract => 1) - text.gsub!(/\[(email address|mobile number)\]/, '[<a href="/help/about#mobiles">\1</a>]') - text = text.gsub(/\n/, '<br>') - return text - end - def fully_destroy ActiveRecord::Base.transaction do diff --git a/app/models/request_mailer.rb b/app/models/request_mailer.rb index ad227c8d9..d2e25f268 100644 --- a/app/models/request_mailer.rb +++ b/app/models/request_mailer.rb @@ -4,12 +4,13 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: request_mailer.rb,v 1.87 2009-10-03 09:47:16 francis Exp $ +# $Id: request_mailer.rb,v 1.88 2009-10-04 21:42:07 francis Exp $ class RequestMailer < ApplicationMailer # Email to public body requesting info def initial_request(info_request, outgoing_message) + @wrap_lines_as_paragraphs = true @from = info_request.incoming_name_and_email @recipients = info_request.recipient_name_and_email @subject = info_request.email_subject_request @@ -19,6 +20,7 @@ class RequestMailer < ApplicationMailer # Later message to public body regarding existing request def followup(info_request, outgoing_message, incoming_message_followup) + @wrap_lines_as_paragraphs = true @from = info_request.incoming_name_and_email @recipients = RequestMailer.name_and_email_for_followup(info_request, incoming_message_followup) @subject = RequestMailer.subject_for_followup(info_request, outgoing_message) diff --git a/app/views/layouts/contact_mailer.rhtml b/app/views/layouts/contact_mailer.rhtml index ce5c18c5b..5b8b44402 100644 --- a/app/views/layouts/contact_mailer.rhtml +++ b/app/views/layouts/contact_mailer.rhtml @@ -1 +1 @@ -<%= MySociety::Format.wrap_email_body(yield) %> +<%= MySociety::Format.wrap_email_body_by_paragraphs(yield) %> diff --git a/app/views/layouts/request_mailer.rhtml b/app/views/layouts/request_mailer.rhtml index ce5c18c5b..c45d5467e 100644 --- a/app/views/layouts/request_mailer.rhtml +++ b/app/views/layouts/request_mailer.rhtml @@ -1 +1 @@ -<%= MySociety::Format.wrap_email_body(yield) %> +<% if @wrap_lines_as_paragraphs %><%= MySociety::Format.wrap_email_body_by_lines(yield) %><% else %><%= MySociety::Format.wrap_email_body_by_paragraphs(yield) %><% end %> diff --git a/app/views/layouts/user_mailer.rhtml b/app/views/layouts/user_mailer.rhtml index ce5c18c5b..5b8b44402 100644 --- a/app/views/layouts/user_mailer.rhtml +++ b/app/views/layouts/user_mailer.rhtml @@ -1 +1 @@ -<%= MySociety::Format.wrap_email_body(yield) %> +<%= MySociety::Format.wrap_email_body_by_paragraphs(yield) %> diff --git a/app/views/request/_correspondence.rhtml b/app/views/request/_correspondence.rhtml index 81c6748ce..b63b5fae3 100644 --- a/app/views/request/_correspondence.rhtml +++ b/app/views/request/_correspondence.rhtml @@ -40,10 +40,6 @@ elsif info_request_event.event_type == 'sent' || info_request_event.event_type = </h2> <%= render :partial => 'bubble', :locals => { :body => outgoing_message.get_body_for_html_display(), :attachments => nil } %> - <% if params[:test_new_format] %> - <hr> - <%= render :partial => 'bubble', :locals => { :body => outgoing_message.new_get_body_for_html_display(), :attachments => nil } %> - <% end %> <p class="event_actions"> <% if outgoing_message.status == 'ready' %> diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml index 8084f778d..e6914c853 100644 --- a/app/views/track_mailer/event_digest.rhtml +++ b/app/views/track_mailer/event_digest.rhtml @@ -45,7 +45,7 @@ extract = highlight_and_excerpt(info_request.initial_request_text, @highlight_words, 150, false) end extract = extract.gsub(/\s+/, ' ') - main_text += MySociety::Format.wrap_email_body('"' + extract + '"').gsub(/\n+$/, "") + "\n" + main_text += MySociety::Format.wrap_email_body_by_lines('"' + extract + '"').gsub(/\n+$/, "") + "\n" # Link to the request/response main_text += url + "\n" diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index e8c4e8ba0..65ee8684b 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -314,6 +314,7 @@ describe RequestController, "when creating a new request" do deliveries.size.should == 1 mail = deliveries[0] mail.body.should =~ /This is a silly letter. It is too short to be interesting./ + STDERR.puts "=====" + mail.body + "======" response.should redirect_to(:action => 'show', :url_title => ir.url_title) end diff --git a/spec/models/request_mailer_spec.rb b/spec/models/request_mailer_spec.rb index 35eaf6625..d097e0ec5 100644 --- a/spec/models/request_mailer_spec.rb +++ b/spec/models/request_mailer_spec.rb @@ -15,6 +15,7 @@ describe RequestMailer, " when receiving incoming mail" do deliveries.size.should == 1 mail = deliveries[0] mail.to.should == [ 'bob@localhost' ] # to the user who sent fancy_dog_request + STDERR.puts "=====" + mail.body + "======" deliveries.clear end @@ -144,7 +145,7 @@ describe RequestMailer, " when receiving incoming mail" do #{long_url} And a paragraph afterwards." - wrapped = MySociety::Format.wrap_email_body(body) + wrapped = MySociety::Format.wrap_email_body_by_paragraphs(body) wrapped.should include(long_url) end end |