diff options
author | francis <francis> | 2008-05-12 22:55:48 +0000 |
---|---|---|
committer | francis <francis> | 2008-05-12 22:55:48 +0000 |
commit | 6eb30cd74aff9d242923c6b496d50642e93cab08 (patch) | |
tree | a4fa20756e37bf434fdc411f289712a6dec8307d | |
parent | 3f9b884159482faa58688aacdafd1b2e5a10658d (diff) |
Remove spurious spaces from top of email.
-rw-r--r-- | app/views/track_mailer/event_digest.rhtml | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/app/views/track_mailer/event_digest.rhtml b/app/views/track_mailer/event_digest.rhtml index dd50d74f8..7bbd63881 100644 --- a/app/views/track_mailer/event_digest.rhtml +++ b/app/views/track_mailer/event_digest.rhtml @@ -1,53 +1,52 @@ -<% if @highlight_words.nil? +<% if @highlight_words.nil? @highlight_words = [] -end %> - -<% - # Construct the main text of the mail - main_text = '' - for track_thing, alert_results in @email_about_things - main_text += track_thing.params[:title_in_email] + "\n" - main_text += ("=" * track_thing.params[:title_in_email].size) + "\n\n" - for result in alert_results.reverse - if result[:model].class.to_s == "InfoRequestEvent" - event = result[:model] - - if not event.outgoing_message.nil? - extract = highlight_and_excerpt(event.outgoing_message.body_without_salutation, @highlight_words, 150, false) - elsif not event.incoming_message.nil? - extract = highlight_and_excerpt(event.incoming_message.get_body_for_quoting, @highlight_words, 150, false) - else - extract = highlight_and_excerpt(info_request.initial_request_text, @highlight_words, 150, false) - end - extract.gsub!(/\s+/, ' ') - - if event.event_type == 'response' - url = main_url(incoming_message_url(event.incoming_message)) - main_text += event.info_request.public_body.name + " sent a response to " + event.info_request.user.name - elsif event.event_type == 'followup_sent' - url = main_url(outgoing_message_url(event.outgoing_message)) - main_text += event.info_request.user.name + " sent a follow up message to " + event.info_request.public_body.name - elsif event.event_type == 'sent' - # this is unlikely to happen in real life, but happens in the test code - url = main_url(request_url(event.info_request))+"#outgoing-"+event.outgoing_message.id.to_s - main_text += event.info_request.user.name + " sent a request to " + event.info_request.public_body.name - else - raise "unknown type in event_digest " + event.event_type - end - main_text += " (" + simple_date(event.created_at) + ")\n" - main_text += MySociety::Format.wrap_email_body('"' + extract + '"').gsub(/\n+$/, "") + "\n" - main_text += url + "\n" - - main_text += "\n" + end + + # Construct the main text of the mail + main_text = '' + for track_thing, alert_results in @email_about_things + main_text += track_thing.params[:title_in_email] + "\n" + main_text += ("=" * track_thing.params[:title_in_email].size) + "\n\n" + for result in alert_results.reverse + if result[:model].class.to_s == "InfoRequestEvent" + event = result[:model] + + if not event.outgoing_message.nil? + extract = highlight_and_excerpt(event.outgoing_message.body_without_salutation, @highlight_words, 150, false) + elsif not event.incoming_message.nil? + extract = highlight_and_excerpt(event.incoming_message.get_body_for_quoting, @highlight_words, 150, false) else - raise "need to add other types to TrackMailer.event_digest" + extract = highlight_and_excerpt(info_request.initial_request_text, @highlight_words, 150, false) end + extract.gsub!(/\s+/, ' ') + + if event.event_type == 'response' + url = main_url(incoming_message_url(event.incoming_message)) + main_text += event.info_request.public_body.name + " sent a response to " + event.info_request.user.name + elsif event.event_type == 'followup_sent' + url = main_url(outgoing_message_url(event.outgoing_message)) + main_text += event.info_request.user.name + " sent a follow up message to " + event.info_request.public_body.name + elsif event.event_type == 'sent' + # this is unlikely to happen in real life, but happens in the test code + url = main_url(request_url(event.info_request))+"#outgoing-"+event.outgoing_message.id.to_s + main_text += event.info_request.user.name + " sent a request to " + event.info_request.public_body.name + else + raise "unknown type in event_digest " + event.event_type + end + main_text += " (" + simple_date(event.created_at) + ")\n" + main_text += MySociety::Format.wrap_email_body('"' + extract + '"').gsub(/\n+$/, "") + "\n" + main_text += url + "\n" + + main_text += "\n" + else + raise "need to add other types to TrackMailer.event_digest" end - main_text += "\n" end + main_text += "\n" + end - #STDERR.puts main_text - #STDERR.puts @unsubscribe_url + #STDERR.puts main_text + #STDERR.puts @unsubscribe_url %><%=main_text%>Alter your subscription ======================= |