diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index ba2ff525d5..bb4412e8a1 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -17,7 +17,7 @@ def signup_confirm(user, token) :confirm_string => token.token) mail :to => user.email, - :subject => I18n.t("user_mailer.signup_confirm.subject") + :subject => t(".subject") end end @@ -28,7 +28,7 @@ def email_confirm(user, token) :confirm_string => token.token) mail :to => user.new_email, - :subject => I18n.t("user_mailer.email_confirm.subject") + :subject => t(".subject") end end @@ -38,7 +38,7 @@ def lost_password(user, token) :token => token.token) mail :to => user.email, - :subject => I18n.t("user_mailer.lost_password.subject") + :subject => t(".subject") end end @@ -52,7 +52,7 @@ def gpx_success(trace, possible_points) @possible_points = possible_points mail :to => trace.user.email, - :subject => I18n.t("user_mailer.gpx_success.subject") + :subject => t(".subject") end end @@ -65,7 +65,7 @@ def gpx_failure(trace, error) @error = error mail :to => trace.user.email, - :subject => I18n.t("user_mailer.gpx_failure.subject") + :subject => t(".subject") end end @@ -83,7 +83,7 @@ def message_notification(message) mail :from => from_address(message.sender.display_name, "m", message.id, message.digest), :to => message.recipient.email, - :subject => I18n.t("user_mailer.message_notification.subject_header", :subject => message.title) + :subject => t(".subject", :message_title => message.title) end end @@ -104,7 +104,7 @@ def diary_comment_notification(comment, recipient) mail :from => from_address(comment.user.display_name, "c", comment.id, comment.digest, recipient.id), :to => recipient.email, - :subject => I18n.t("user_mailer.diary_comment_notification.subject", :user => comment.user.display_name) + :subject => t(".subject", :user => comment.user.display_name) end end @@ -117,7 +117,7 @@ def friendship_notification(friendship) attach_user_avatar(@friendship.befriender) mail :to => friendship.befriendee.email, - :subject => I18n.t("user_mailer.friendship_notification.subject", :user => friendship.befriender.display_name) + :subject => t(".subject", :user => friendship.befriender.display_name) end end @@ -132,7 +132,7 @@ def note_comment_notification(comment, recipient) @commenter = if comment.author comment.author.display_name else - I18n.t("user_mailer.note_comment_notification.anonymous") + t(".anonymous") end @author = @commenter @@ -141,9 +141,9 @@ def note_comment_notification(comment, recipient) set_references("note", comment.note) subject = if @owner - I18n.t("user_mailer.note_comment_notification.#{@event}.subject_own", :commenter => @commenter) + t(".#{@event}.subject_own", :commenter => @commenter) else - I18n.t("user_mailer.note_comment_notification.#{@event}.subject_other", :commenter => @commenter) + t(".#{@event}.subject_other", :commenter => @commenter) end mail :to => recipient.email, :subject => subject @@ -163,9 +163,9 @@ def changeset_comment_notification(comment, recipient) @author = @commenter subject = if @owner - I18n.t("user_mailer.changeset_comment_notification.commented.subject_own", :commenter => @commenter) + t(".commented.subject_own", :commenter => @commenter) else - I18n.t("user_mailer.changeset_comment_notification.commented.subject_other", :commenter => @commenter) + t(".commented.subject_other", :commenter => @commenter) end attach_user_avatar(comment.author) diff --git a/app/views/user_mailer/changeset_comment_notification.html.erb b/app/views/user_mailer/changeset_comment_notification.html.erb index 85cd87e5e0..95c5cdc5bc 100644 --- a/app/views/user_mailer/changeset_comment_notification.html.erb +++ b/app/views/user_mailer/changeset_comment_notification.html.erb @@ -3,12 +3,12 @@

<% if @owner %> - <%= raw t ".commented.your_changeset", :commenter => link_to_user(@commenter), :time => @time %> + <%= t ".commented.your_changeset_html", :commenter => link_to_user(@commenter), :time => @time %> <% else %> - <%= raw t ".commented.commented_changeset", :commenter => link_to_user(@commenter), :time => @time, :changeset_author => @changeset_author %> + <%= t ".commented.commented_changeset_html", :commenter => link_to_user(@commenter), :time => @time, :changeset_author => @changeset_author %> <% end %> <% if @changeset_comment %> - <%= raw t ".commented.partial_changeset_with_comment", :changeset_comment => tag.em(@changeset_comment) %> + <%= t ".commented.partial_changeset_with_comment_html", :changeset_comment => tag.em(@changeset_comment) %> <% else %> <%= t ".commented.partial_changeset_without_comment" %> <% end %> @@ -19,11 +19,11 @@ <% end %>

- <%= raw t ".details", :url => link_to(@changeset_url, @changeset_url) %> + <%= t ".details_html", :url => link_to(@changeset_url, @changeset_url) %>

<% content_for :footer do %>

- <%= raw t ".unsubscribe", :url => link_to(@changeset_url, @changeset_url, :style => "color: #222") %> + <%= t ".unsubscribe_html", :url => link_to(@changeset_url, @changeset_url, :style => "color: #222") %>

<% end %> diff --git a/app/views/user_mailer/diary_comment_notification.html.erb b/app/views/user_mailer/diary_comment_notification.html.erb index abf92509fb..b4efae83bd 100644 --- a/app/views/user_mailer/diary_comment_notification.html.erb +++ b/app/views/user_mailer/diary_comment_notification.html.erb @@ -2,7 +2,7 @@ <%= t ".hi", :to_user => @to_user %>

- <%= raw t ".header", :from_user => link_to_user(@from_user), :subject => tag.em(@title) %> + <%= t ".header_html", :from_user => link_to_user(@from_user), :subject => tag.em(@title) %>

<%= message_body do %> @@ -10,9 +10,9 @@ <% end %> <% content_for :footer do %> -

<%= raw t ".footer", - :readurl => link_to(@readurl, @readurl) + tag(:br), - :commenturl => link_to(@commenturl, @commenturl) + tag(:br), - :replyurl => link_to(@replyurl, @replyurl) %> +

<%= t ".footer_html", + :readurl => link_to(@readurl, @readurl) + tag(:br), + :commenturl => link_to(@commenturl, @commenturl) + tag(:br), + :replyurl => link_to(@replyurl, @replyurl) %>

<% end %> diff --git a/app/views/user_mailer/diary_comment_notification.text.erb b/app/views/user_mailer/diary_comment_notification.text.erb index b86c303ae8..cbf9ddaa05 100644 --- a/app/views/user_mailer/diary_comment_notification.text.erb +++ b/app/views/user_mailer/diary_comment_notification.text.erb @@ -3,7 +3,7 @@ <%= t '.header', :from_user => @from_user, :subject => @title %> == -<%= raw @text.to_text %> +<%= @text.to_text %> == <%= t '.footer', :readurl => @readurl, :commenturl => @commenturl, :replyurl => @replyurl %> diff --git a/app/views/user_mailer/email_confirm.html.erb b/app/views/user_mailer/email_confirm.html.erb index 3848b192bd..d972e9f64a 100644 --- a/app/views/user_mailer/email_confirm.html.erb +++ b/app/views/user_mailer/email_confirm.html.erb @@ -1,7 +1,7 @@ -

<%= t "user_mailer.email_confirm_html.greeting" %>

+

<%= t ".greeting" %>

-

<%= t "user_mailer.email_confirm_html.hopefully_you", :server_url => Settings.server_url, :new_address => @address %>

+

<%= t ".hopefully_you", :server_url => Settings.server_url, :new_address => @address %>

-

<%= t "user_mailer.email_confirm_html.click_the_link" %>

+

<%= t ".click_the_link" %>

<%= @url %>

diff --git a/app/views/user_mailer/email_confirm.text.erb b/app/views/user_mailer/email_confirm.text.erb index e4fff2b6de..66bd553077 100644 --- a/app/views/user_mailer/email_confirm.text.erb +++ b/app/views/user_mailer/email_confirm.text.erb @@ -1,7 +1,7 @@ -<%= t 'user_mailer.email_confirm_plain.greeting' %> +<%= t '.greeting' %> -<%= word_wrap(t 'user_mailer.email_confirm_plain.hopefully_you', :server_url => Settings.server_url, :new_address => @address) %> +<%= word_wrap(t '.hopefully_you', :server_url => Settings.server_url, :new_address => @address) %> -<%= t 'user_mailer.email_confirm_plain.click_the_link' %> +<%= t '.click_the_link' %> <%= @url %> diff --git a/app/views/user_mailer/friendship_notification.html.erb b/app/views/user_mailer/friendship_notification.html.erb index 24587a6e3a..0f2353150b 100644 --- a/app/views/user_mailer/friendship_notification.html.erb +++ b/app/views/user_mailer/friendship_notification.html.erb @@ -1,9 +1,9 @@

<%= t ".had_added_you", :user => @friendship.befriender.display_name %>

<%= message_body do %> -

<%= raw t ".see_their_profile", :userurl => link_to(@viewurl, @viewurl) %>

+

<%= t ".see_their_profile_html", :userurl => link_to(@viewurl, @viewurl) %>

<% unless @friendship.befriendee.is_friends_with?(@friendship.befriender) -%> -

<%= raw t ".befriend_them", :befriendurl => link_to(@friendurl, @friendurl) %>

+

<%= t ".befriend_them_html", :befriendurl => link_to(@friendurl, @friendurl) %>

<% end -%> <% end %> diff --git a/app/views/user_mailer/lost_password.html.erb b/app/views/user_mailer/lost_password.html.erb index 7e61b6c49c..f22480bb34 100644 --- a/app/views/user_mailer/lost_password.html.erb +++ b/app/views/user_mailer/lost_password.html.erb @@ -1,7 +1,7 @@ -

<%= t "user_mailer.lost_password_html.greeting" %>

+

<%= t ".greeting" %>

-

<%= t "user_mailer.lost_password_html.hopefully_you" %>

+

<%= t ".hopefully_you" %>

-

<%= t "user_mailer.lost_password_html.click_the_link" %>

+

<%= t ".click_the_link" %>

<%= @url %>

diff --git a/app/views/user_mailer/lost_password.text.erb b/app/views/user_mailer/lost_password.text.erb index 778fa6540d..560ec13295 100644 --- a/app/views/user_mailer/lost_password.text.erb +++ b/app/views/user_mailer/lost_password.text.erb @@ -1,7 +1,7 @@ -<%= t 'user_mailer.lost_password_plain.greeting' %> +<%= t '.greeting' %> -<%= word_wrap(t 'user_mailer.lost_password_plain.hopefully_you') %> +<%= word_wrap(t '.hopefully_you') %> -<%= t 'user_mailer.lost_password_plain.click_the_link' %> +<%= t '.click_the_link' %> <%= @url %> diff --git a/app/views/user_mailer/message_notification.html.erb b/app/views/user_mailer/message_notification.html.erb index 74d10f599b..fd49c6723c 100644 --- a/app/views/user_mailer/message_notification.html.erb +++ b/app/views/user_mailer/message_notification.html.erb @@ -2,9 +2,9 @@ <%= t ".hi", :to_user => @to_user %>

- <%= raw t ".header", - :from_user => link_to_user(@from_user), - :subject => tag.em(@title) %> + <%= t ".header", + :from_user => link_to_user(@from_user), + :subject => tag.em(@title) %>

<%= message_body do %> diff --git a/app/views/user_mailer/message_notification.text.erb b/app/views/user_mailer/message_notification.text.erb index b3a74bb88d..1d75e7e2a2 100644 --- a/app/views/user_mailer/message_notification.text.erb +++ b/app/views/user_mailer/message_notification.text.erb @@ -1,9 +1,9 @@ -<%= raw t '.hi', :to_user => @to_user %> +<%= t '.hi', :to_user => @to_user %> -<%= raw t '.header', :from_user => @from_user, :subject => @title %> +<%= t '.header', :from_user => @from_user, :subject => @title %> == -<%= raw @text.to_text %> +<%= @text.to_text %> == -<%= word_wrap(t '.footer_html', :readurl => @readurl, :replyurl => @replyurl) %> +<%= word_wrap(t '.footer', :readurl => @readurl, :replyurl => @replyurl) %> diff --git a/app/views/user_mailer/note_comment_notification.html.erb b/app/views/user_mailer/note_comment_notification.html.erb index 3a82860286..8d779bc485 100644 --- a/app/views/user_mailer/note_comment_notification.html.erb +++ b/app/views/user_mailer/note_comment_notification.html.erb @@ -1,9 +1,9 @@

<%= t ".greeting" %>

<% if @owner %> -

<%= raw t ".#{@event}.your_note", :commenter => link_to_user(@commenter), :place => @place %>

+

<%= t ".#{@event}.your_note_html", :commenter => link_to_user(@commenter), :place => @place %>

<% else %> -

<%= raw t ".#{@event}.commented_note", :commenter => link_to_user(@commenter), :place => @place %>

+

<%= t ".#{@event}.commented_note_html", :commenter => link_to_user(@commenter), :place => @place %>

<% end %> <% unless @comment.empty? %> @@ -12,4 +12,4 @@ <% end %> <% end %> -

<%= raw t ".details", :url => link_to(@noteurl, @noteurl) %>

+

<%= t ".details_html", :url => link_to(@noteurl, @noteurl) %>

diff --git a/config/locales/en.yml b/config/locales/en.yml index c7613cfd4f..8531800809 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1414,18 +1414,24 @@ en: subject: "[OpenStreetMap] %{user} commented on a diary entry" hi: "Hi %{to_user}," header: "%{from_user} has commented on the OpenStreetMap diary entry with the subject %{subject}:" + header_html: "%{from_user} has commented on the OpenStreetMap diary entry with the subject %{subject}:" footer: "You can also read the comment at %{readurl} and you can comment at %{commenturl} or send a message to the author at %{replyurl}" + footer_html: "You can also read the comment at %{readurl} and you can comment at %{commenturl} or send a message to the author at %{replyurl}" message_notification: - subject_header: "[OpenStreetMap] %{subject}" + subject: "[OpenStreetMap] %{message_title}" hi: "Hi %{to_user}," header: "%{from_user} has sent you a message through OpenStreetMap with the subject %{subject}:" + header_html: "%{from_user} has sent you a message through OpenStreetMap with the subject %{subject}:" + footer: "You can also read the message at %{readurl} and you can send a message to the author at %{replyurl}" footer_html: "You can also read the message at %{readurl} and you can send a message to the author at %{replyurl}" friendship_notification: hi: "Hi %{to_user}," subject: "[OpenStreetMap] %{user} added you as a friend" had_added_you: "%{user} has added you as a friend on OpenStreetMap." see_their_profile: "You can see their profile at %{userurl}." + see_their_profile_html: "You can see their profile at %{userurl}." befriend_them: "You can also add them as a friend at %{befriendurl}." + befriend_them_html: "You can also add them as a friend at %{befriendurl}." gpx_description: description_with_tags_html: "It looks like your GPX file %{trace_name} with the description %{trace_description} and the following tags: %{tags}" description_with_no_tags_html: "It looks like your GPX file %{trace_name} with the description %{trace_description} and no tags" @@ -1449,21 +1455,11 @@ en: welcome: "After you confirm your account, we'll provide you with some additional information to get you started." email_confirm: subject: "[OpenStreetMap] Confirm your email address" - email_confirm_plain: - greeting: "Hi," - hopefully_you: "Someone (hopefully you) would like to change their email address over at %{server_url} to %{new_address}." - click_the_link: "If this is you, please click the link below to confirm the change." - email_confirm_html: greeting: "Hi," hopefully_you: "Someone (hopefully you) would like to change their email address over at %{server_url} to %{new_address}." click_the_link: "If this is you, please click the link below to confirm the change." lost_password: subject: "[OpenStreetMap] Password reset request" - lost_password_plain: - greeting: "Hi," - hopefully_you: "Someone (possibly you) has asked for the password to be reset on this email address's openstreetmap.org account." - click_the_link: "If this is you, please click the link below to reset your password." - lost_password_html: greeting: "Hi," hopefully_you: "Someone (possibly you) has asked for the password to be reset on this email address's openstreetmap.org account." click_the_link: "If this is you, please click the link below to reset your password." @@ -1474,18 +1470,25 @@ en: subject_own: "[OpenStreetMap] %{commenter} has commented on one of your notes" subject_other: "[OpenStreetMap] %{commenter} has commented on a note you are interested in" your_note: "%{commenter} has left a comment on one of your map notes near %{place}." + your_note_html: "%{commenter} has left a comment on one of your map notes near %{place}." commented_note: "%{commenter} has left a comment on a map note you have commented on. The note is near %{place}." + commented_note_html: "%{commenter} has left a comment on a map note you have commented on. The note is near %{place}." closed: subject_own: "[OpenStreetMap] %{commenter} has resolved one of your notes" subject_other: "[OpenStreetMap] %{commenter} has resolved a note you are interested in" your_note: "%{commenter} has resolved one of your map notes near %{place}." + your_note_html: "%{commenter} has resolved one of your map notes near %{place}." commented_note: "%{commenter} has resolved a map note you have commented on. The note is near %{place}." + commented_note_html: "%{commenter} has resolved a map note you have commented on. The note is near %{place}." reopened: subject_own: "[OpenStreetMap] %{commenter} has reactivated one of your notes" subject_other: "[OpenStreetMap] %{commenter} has reactivated a note you are interested in" your_note: "%{commenter} has reactivated one of your map notes near %{place}." + your_note_html: "%{commenter} has reactivated one of your map notes near %{place}." commented_note: "%{commenter} has reactivated a map note you have commented on. The note is near %{place}." + commented_note_html: "%{commenter} has reactivated a map note you have commented on. The note is near %{place}." details: "More details about the note can be found at %{url}." + details_html: "More details about the note can be found at %{url}." changeset_comment_notification: hi: "Hi %{to_user}," greeting: "Hi," @@ -1493,11 +1496,16 @@ en: subject_own: "[OpenStreetMap] %{commenter} has commented on one of your changesets" subject_other: "[OpenStreetMap] %{commenter} has commented on a changeset you are interested in" your_changeset: "%{commenter} left a comment at %{time} on one of your changesets" + your_changeset_html: "%{commenter} left a comment at %{time} on one of your changesets" commented_changeset: "%{commenter} left a comment at %{time} on a changeset you are watching created by %{changeset_author}" + commented_changeset_html: "%{commenter} left a comment at %{time} on a changeset you are watching created by %{changeset_author}" partial_changeset_with_comment: "with comment '%{changeset_comment}'" + partial_changeset_with_comment_html: "with comment '%{changeset_comment}'" partial_changeset_without_comment: "without comment" details: "More details about the changeset can be found at %{url}." + details_html: "More details about the changeset can be found at %{url}." unsubscribe: 'To unsubscribe from updates to this changeset, visit %{url} and click "Unsubscribe".' + unsubscribe_html: 'To unsubscribe from updates to this changeset, visit %{url} and click "Unsubscribe".' messages: inbox: title: "Inbox" diff --git a/test/mailers/user_mailer_test.rb b/test/mailers/user_mailer_test.rb index 2a4b5a417a..537bb9d0dd 100644 --- a/test/mailers/user_mailer_test.rb +++ b/test/mailers/user_mailer_test.rb @@ -17,4 +17,13 @@ def test_gpx_description_tags assert_match(/one two three/, email.html_part.body.to_s) end + + def test_html_encoding + user = create(:user, :display_name => "Jack & Jill
") + message = create(:message, :sender => user) + email = UserMailer.message_notification(message) + + assert_match("Jack & Jill
", email.text_part.body.to_s) + assert_match("Jack & Jill <br>", email.html_part.body.to_s) + end end