]> git.openstreetmap.org Git - rails.git/blob - app/helpers/user_mailer_helper.rb
Merge pull request #5932 from tomhughes/frozen-strings
[rails.git] / app / helpers / user_mailer_helper.rb
1 # frozen_string_literal: true
2
3 module UserMailerHelper
4   def fp(text)
5     format_paragraph(text, 72, 0)
6   end
7
8   def link_to_user(display_name)
9     link_to(
10       tag.strong(
11         display_name,
12         # NB we need "text-decoration: none" twice: GMail only honours it on
13         # the <a> but Outlook only on the <strong>
14         :style => "text-decoration: none"
15       ),
16       user_url(display_name, :host => Settings.server_url),
17       :target => "_blank",
18       :rel => "noopener",
19       :style => "text-decoration: none; color: #222"
20     )
21   end
22
23   def message_body(&)
24     render(
25       :partial => "message_body",
26       :locals => { :body => capture(&) }
27     )
28   end
29
30   def style_message(html)
31     # Because we can't use stylesheets in HTML emails, we need to inline the
32     # styles. Rather than copy-paste the same string of CSS into every message,
33     # we apply it once here, after the message has been composed.
34     html.gsub("<p>", '<p style="color: black; margin: 0.75em 0; font-family: \'Helvetica Neue\', Arial, Sans-Serif">').html_safe
35   end
36
37   def style_left
38     I18n.t("html.dir") == "ltr" ? "left" : "right"
39   end
40
41   def style_right
42     I18n.t("html.dir") == "ltr" ? "right" : "left"
43   end
44 end