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