]> git.openstreetmap.org Git - rails.git/commitdiff
intial commit, for 'en' locale only, for changeset_comment_notification only, doesn...
authorHerve Saint-Amand <git@saintamh.org>
Thu, 29 Dec 2016 21:54:46 +0000 (21:54 +0000)
committerHerve Saint-Amand <git@saintamh.org>
Thu, 29 Dec 2016 21:54:46 +0000 (21:54 +0000)
app/models/notifier.rb
app/views/notifier/changeset_comment_notification.html.erb
config/locales/en.yml

index 0539bdeb72fe3963bd7f52287427246713d035f0..b53210c30e96df1c017fe1b9f62ba07584984f3b 100644 (file)
@@ -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 = <<EOS
+iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAA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
+yGOzz3/96MFDzyw8PTk9/2S9ZSe6nQfri8v3b9367N61W5fuXbn07o1rd68t3wRWAPfrYAAT10ab
+L37t8PM/+M3Wn5z815sLpz5yF43Rs87llzfXNi5ubWzcBjpABttLfLtjVIDm/L5d7ccO7Bq5df1W
+Z/Hq5+vO+S6QAPkjoPJrkt0LjzHe3km/txE7Zw5MjPiXo1BmH2yYRVQ/yvLsamert7ljctRdvnGf
+tLPM/yB5dPS/Qv7bx7WxacaGagz6fWlPTjaUYA6kFRi/Xpbl0tbmVr/VrOv9tXV6Kw/+t3r/Z33R
+anbsmSfPc2k0mwFgyqL0W5sbZRRFPLy/9P8G/EL/DvwpHPAlnJG4AAAAJXRFWHRkYXRlOmNyZWF0
+ZQAyMDE2LTA5LTI3VDE2OjM0OjA2KzAxOjAwiYFarwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxNi0w
+OS0yN1QxNjozMzo0MSswMTowMFvtyR4AAAAASUVORK5CYII=
+EOS
+
 end
index b7646a886b7e0c0a0dac0435cd0756b179ad434f..dffb29059397771bee5539871e21b93de7cf81b6 100644 (file)
@@ -1,20 +1,74 @@
-<p><%= t 'notifier.changeset_comment_notification.greeting' %></p>
-
-<p>
-  <% 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 %>
-</p>
-
-==
-<%= @comment.to_html %>
-==
-
-<p><%= raw t 'notifier.changeset_comment_notification.details', :url => link_to(@changeset_url, @changeset_url) %></p>
+<html>
+  <head>
+    <title></title>
+    <meta charset="UTF-8"></meta>
+  </head>
+  <body style="padding: 0; margin: 0">
+    <table border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#eee" style="color: #222; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; text-align: center">
+      <tr>
+        <td>
+          <table align="center" width="600" cellspacing="10" style="color: #222; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; margin-left: auto; margin-right: auto">
+            <tr>
+              <td width="30">
+                <a href="<%= @root_url %>" target="_blank">
+                  <%= image_tag attachments["osm_logo_30x30.png"].url, alt: "OpenStreetMap logo", title: "OpenStreetMap", height: "30", width: "30", border: "0" %>
+                </a>
+              </td>
+              <td>
+                <a href="<%= @root_url %>" target="_blank" style="text-decoration: none; color: #000">
+                  <h1 style="font-size: 18px; font-weight: 600; margin: 0; text-align: left">OpenStreetMap</h1>
+                </a>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <table width="100%" bgcolor="#fff" cellspacing="15" style="color: #222; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 14px; border: solid 1px #ccc">
+                  <tr>
+                    <td>
+                      <p>
+                        <% 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 %>
+                      </p>
+                      <table style="color: #222; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 15px; font-style: italic; margin: 15px; background-color: #eee" cellpadding="10">
+                        <tr>
+                          <td style="vertical-align: top">
+                            <a href="<%= @commenter_url %>" target="_blank"><img src="<%= @commenter_thumbnail_src %>"></a>
+                          </td>
+                          <td style="vertical-align: top">
+                            <%= @comment.to_html %>
+                          </td>
+                        </tr>
+                      </table>
+                      <p>
+                        <p><%= raw t 'notifier.changeset_comment_notification.details_html', :url => link_to(@changeset_url, @changeset_url) %></p>
+                      </p>
+                    </td>
+                  </tr>
+                </table>
+              </td>
+            </tr>
+          </table>
+        </td>
+      </tr>
+      <tr>
+        <td align="center">
+          <p>
+            <a style="color: #222" href="<%= @changeset_url %>">Unsubscribe</a>
+            from updates to this changeset
+          </p>
+          <p style="margin-bottom: 10px">
+            <a href="https://www.openstreetmap.org/" target="_blank" style="color: #222">OpenStreetMap.org</a>
+          </p>
+        </td>
+      </tr>
+    </table>
+  </body>
+</html>
index cfff874bda7d1c404579f685ba52ec48aebcdc64..52994509fad15aa2780bcd2abf3713cd4ec9d098 100644 (file)
@@ -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: '<a href="%{commenter_url}" target="_blank" style="text-decoration: none; color: #222"><strong>%{commenter}</strong></a>
+           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: '<a href="%{commenter_url}" target="_blank" style="text-decoration: none; color: #222"><strong>%{commenter}</strong></a>
+          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 <em>%{changeset_comment}</em>'
         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
+         <nobr>%{url}</nobr>.'
   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"