]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/notifier_helper.rb
Fix styling of email notifications in RTL languages
[rails.git] / app / helpers / notifier_helper.rb
index 3e53e2543c006a57f9dee08113099abd892df457..cc99898aa7b78ebe8e8121aec7e3aceaa86979bf 100644 (file)
@@ -5,10 +5,17 @@ module NotifierHelper
 
   def link_to_user(display_name)
     link_to(
-      display_name,
-      user_url(display_name, :host => SERVER_URL),
+      content_tag(
+        "strong",
+        display_name,
+        # NB we need "text-decoration: none" twice: GMail only honours it on
+        # the <a> but Outlook only on the <strong>
+        :style => "text-decoration: none"
+      ),
+      user_url(display_name, :host => Settings.server_url),
       :target => "_blank",
-      :style => "text-decoration: none; color: #222; font-weight: bold"
+      :rel => "noopener",
+      :style => "text-decoration: none; color: #222"
     )
   end
 
@@ -20,6 +27,17 @@ module NotifierHelper
   end
 
   def style_message(html)
-    html.gsub /<p>/, '<p style="color: black; margin: 0.75em 0">'
+    # Because we can't use stylesheets in HTML emails, we need to inline the
+    # styles. Rather than copy-paste the same string of CSS into every message,
+    # we apply it once here, after the message has been composed.
+    html.gsub(/<p>/, '<p style="color: black; margin: 0.75em 0; font-family: \'Helvetica Neue\', Arial, Sans-Serif">')
+  end
+
+  def style_left
+    I18n.t("html.dir") == "ltr" ? "left" : "right"
+  end
+
+  def style_right
+    I18n.t("html.dir") == "ltr" ? "right" : "left"
   end
 end