EmailBuilder.coffee 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. _ = require('underscore')
  2. PersonalEmailLayout = require("./Layouts/PersonalEmailLayout")
  3. NotificationEmailLayout = require("./Layouts/NotificationEmailLayout")
  4. settings = require("settings-sharelatex")
  5. templates = {}
  6. templates.registered =
  7. subject: _.template "Activate your #{settings.appName} Account"
  8. layout: PersonalEmailLayout
  9. type: "notification"
  10. plainTextTemplate: _.template """
  11. Congratulations, you've just had an account created for you on #{settings.appName} with the email address "<%= to %>".
  12. Click here to set your password and log in: <%= setNewPasswordUrl %>
  13. If you have any questions or problems, please contact #{settings.adminEmail}
  14. """
  15. compiledTemplate: _.template """
  16. <p>Congratulations, you've just had an account created for you on #{settings.appName} with the email address "<%= to %>".</p>
  17. <p><a href="<%= setNewPasswordUrl %>">Click here to set your password and log in.</a></p>
  18. <p>If you have any questions or problems, please contact <a href="mailto:#{settings.adminEmail}">#{settings.adminEmail}</a>.</p>
  19. """
  20. templates.canceledSubscription =
  21. subject: _.template "ShareLaTeX thoughts"
  22. layout: PersonalEmailLayout
  23. type:"lifecycle"
  24. plainTextTemplate: _.template """
  25. Hi <%= first_name %>,
  26. I'm sorry to see you cancelled your ShareLaTeX premium account. Would you mind giving me some advice on what the site is lacking at the moment via this survey?:
  27. https://sharelatex.typeform.com/to/f5lBiZ
  28. Thank you in advance.
  29. Henry
  30. ShareLaTeX Co-founder
  31. """
  32. compiledTemplate: _.template '''
  33. <p>Hi <%= first_name %>,</p>
  34. <p>I'm sorry to see you cancelled your ShareLaTeX premium account. Would you mind giving me some advice on what the site is lacking at the moment via <a href="https://sharelatex.typeform.com/to/f5lBiZ">this survey</a>?</p>
  35. <p>Thank you in advance.</p>
  36. <p>
  37. Henry <br>
  38. ShareLaTeX Co-founder
  39. </p>
  40. '''
  41. templates.passwordResetRequested =
  42. subject: _.template "Password Reset - #{settings.appName}"
  43. layout: NotificationEmailLayout
  44. type:"notification"
  45. plainTextTemplate: _.template """
  46. Password Reset
  47. We got a request to reset your #{settings.appName} password.
  48. Click this link to reset your password: <%= setNewPasswordUrl %>
  49. If you ignore this message, your password won't be changed.
  50. If you didn't request a password reset, let us know.
  51. Thank you
  52. #{settings.appName} - <%= siteUrl %>
  53. """
  54. compiledTemplate: _.template """
  55. <h2>Password Reset</h2>
  56. <p>
  57. We got a request to reset your #{settings.appName} password.
  58. <p>
  59. <center>
  60. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:24px;">
  61. <div style="padding-right:10px;padding-left:10px">
  62. <a href="<%= setNewPasswordUrl %>" style="text-decoration:none" target="_blank">
  63. <span style= "font-size:16px;font-family:Arial;font-weight:bold;color:#fff;white-space:nowrap;display:block; text-align:center">
  64. Reset password
  65. </span>
  66. </a>
  67. </div>
  68. </div>
  69. </center>
  70. If you ignore this message, your password won't be changed.
  71. <p>
  72. If you didn't request a password reset, let us know.
  73. </p>
  74. <p>Thank you</p>
  75. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  76. """
  77. templates.projectInvite =
  78. subject: _.template "<%= project.name %> - shared by <%= owner.email %>"
  79. layout: NotificationEmailLayout
  80. type:"notification"
  81. plainTextTemplate: _.template """
  82. Hi, <%= owner.email %> wants to share '<%= project.name %>' with you.
  83. Follow this link to view the project: <%= inviteUrl %>
  84. Thank you
  85. #{settings.appName} - <%= siteUrl %>
  86. """
  87. compiledTemplate: _.template """
  88. <p>Hi, <%= owner.email %> wants to share <a href="<%= inviteUrl %>">'<%= project.name %>'</a> with you</p>
  89. <center>
  90. <a style="text-decoration: none; width: 200px; background-color: #a93629; border: 1px solid #e24b3b; border-radius: 3px; padding: 15px; margin: 24px; display: block;" href="<%= inviteUrl %>" style="text-decoration:none" target="_blank">
  91. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  92. View Project
  93. </span>
  94. </a>
  95. </center>
  96. <p> Thank you</p>
  97. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  98. """
  99. templates.completeJoinGroupAccount =
  100. subject: _.template "Verify Email to join <%= group_name %> group"
  101. layout: NotificationEmailLayout
  102. type:"notification"
  103. plainTextTemplate: _.template """
  104. Hi, please verify your email to join the <%= group_name %> and get your free premium account
  105. Click this link to verify now: <%= completeJoinUrl %>
  106. Thank You
  107. #{settings.appName} - <%= siteUrl %>
  108. """
  109. compiledTemplate: _.template """
  110. <p>Hi, please verify your email to join the <%= group_name %> and get your free premium account</p>
  111. <center>
  112. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:24px;">
  113. <div style="padding-right:10px;padding-left:10px">
  114. <a href="<%= completeJoinUrl %>" style="text-decoration:none" target="_blank">
  115. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  116. Verify now
  117. </span>
  118. </a>
  119. </div>
  120. </div>
  121. </center>
  122. <p> Thank you</p>
  123. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  124. """
  125. module.exports =
  126. templates: templates
  127. buildEmail: (templateName, opts)->
  128. template = templates[templateName]
  129. opts.siteUrl = settings.siteUrl
  130. opts.body = template.compiledTemplate(opts)
  131. if settings.email?.templates?.customFooter?
  132. opts.body += settings.email?.templates?.customFooter
  133. return {
  134. subject : template.subject(opts)
  135. html: template.layout(opts)
  136. text: template?.plainTextTemplate?(opts)
  137. type:template.type
  138. }