From e6d19586dffa03e6fac4961c0a1b64b6a237d88d Mon Sep 17 00:00:00 2001 From: Herve Saint-Amand Date: Thu, 29 Dec 2016 21:54:46 +0000 Subject: [PATCH] intial commit, for 'en' locale only, for changeset_comment_notification only, doesn't load images properly yet --- app/models/notifier.rb | 67 +++++++++++++ .../changeset_comment_notification.html.erb | 94 +++++++++++++++---- config/locales/en.yml | 15 ++- 3 files changed, 151 insertions(+), 25 deletions(-) diff --git a/app/models/notifier.rb b/app/models/notifier.rb index 0539bdeb7..b53210c30 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -1,3 +1,5 @@ +require "base64" + class Notifier < ActionMailer::Base default :from => EMAIL_FROM, :return_path => EMAIL_RETURN_PATH, @@ -154,10 +156,13 @@ class Notifier < ActionMailer::Base def changeset_comment_notification(comment, recipient) with_recipient_locale recipient do + @root_url = root_url(:host => SERVER_URL) @changeset_url = changeset_url(comment.changeset, :host => SERVER_URL) @comment = comment.body @owner = recipient == comment.changeset.user @commenter = comment.author.display_name + @commenter_url = user_url(comment.author.display_name, :host => SERVER_URL) + @commenter_thumbnail_src = comment.author.image.url(:small, :host => SERVER_URL) @changeset_comment = comment.changeset.tags["comment"].presence @time = comment.created_at @changeset_author = comment.changeset.user.display_name @@ -168,6 +173,12 @@ class Notifier < ActionMailer::Base I18n.t("notifier.changeset_comment_notification.commented.subject_other", :commenter => @commenter) end + attachments.inline['osm_logo_30x30.png'] = { + mime_type: 'image/png', + encoding: 'base64', + content: @@osm_logo_png_bytes, + } + mail :to => recipient.email, :subject => subject end end @@ -191,4 +202,60 @@ class Notifier < ActionMailer::Base EMAIL_FROM end end + + # FIXME - 2016-12-28 - saintamh - someone please show me a better way to + # include this blob in here. If I save it under app/assets, how do I get a + # path to it in a portable way? + @@osm_logo_png_bytes = <<%= t 'notifier.changeset_comment_notification.greeting' %>

- -

- <% if @owner %> - <%= t "notifier.changeset_comment_notification.commented.your_changeset", :commenter => @commenter, :time => @time %> - <% else %> - <%= t "notifier.changeset_comment_notification.commented.commented_changeset", :commenter => @commenter, :time => @time, :changeset_author => @changeset_author %> - <% end %> - <% if @changeset_comment %> - <%= t "notifier.changeset_comment_notification.commented.partial_changeset_with_comment", :changeset_comment => @changeset_comment %> - <% else %> - <%= t "notifier.changeset_comment_notification.commented.partial_changeset_without_comment" %> - <% end %> -

- -== -<%= @comment.to_html %> -== - -

<%= raw t 'notifier.changeset_comment_notification.details', :url => link_to(@changeset_url, @changeset_url) %>

+ + + + + + + + + + + + + +
+ + + + + + + + +
+ + <%= image_tag attachments["osm_logo_30x30.png"].url, alt: "OpenStreetMap logo", title: "OpenStreetMap", height: "30", width: "30", border: "0" %> + + + +

OpenStreetMap

+
+
+ + + + +
+

+ <% if @owner %> + <%= t "notifier.changeset_comment_notification.commented.your_changeset_html", :commenter => @commenter, :commenter_url => @commenter_url, :time => @time %> + <% else %> + <%= t "notifier.changeset_comment_notification.commented.commented_changeset_html", :commenter => @commenter, :commenter_url => @commenter_url, :time => @time, :changeset_author => @changeset_author %> + <% end %> + <% if @changeset_comment %> + <%= t "notifier.changeset_comment_notification.commented.partial_changeset_with_comment_html", :changeset_comment => @changeset_comment %> + <% else %> + <%= t "notifier.changeset_comment_notification.commented.partial_changeset_without_comment" %> + <% end %> +

+ + + + + +
+ + + <%= @comment.to_html %> +
+

+

<%= raw t 'notifier.changeset_comment_notification.details_html', :url => link_to(@changeset_url, @changeset_url) %>

+

+
+
+
+

+ Unsubscribe + from updates to this changeset +

+

+ OpenStreetMap.org +

+
+ + diff --git a/config/locales/en.yml b/config/locales/en.yml index cfff874bd..52994509f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1315,10 +1315,20 @@ 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} has left a comment on one of your changesets created at %{time}" + your_changeset_html: '%{commenter} + has left a comment on one of your changesets + created at %{time}' commented_changeset: "%{commenter} has left a comment on a map changeset you are watching created by %{changeset_author} at %{time}" + commented_changeset_html: '%{commenter} + has left a comment on a map changeset you are watching created by + %{changeset_author} + at %{time}' 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}.' message: inbox: title: "Inbox" @@ -2288,11 +2298,6 @@ en: against_oneway_without_exit: Go against one-way on %{name} end_oneway_without_exit: End of one-way on %{name} roundabout_with_exit: At roundabout take exit %{exit} onto %{name} - turn_left_with_exit: At roundabout turn left onto %{name} - slight_left_with_exit: At roundabout slight left onto %{name} - turn_right_with_exit: At roundabout turn right onto %{name} - slight_right_with_exit: At roundabout slight right onto %{name} - continue_with_exit: At roundabout continue straight onto %{name} unnamed: "unnamed road" courtesy: "Directions courtesy of %{link}" time: "Time" -- 2.43.2