EmailBuilder.coffee 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. compiledTemplate: _.template """
  11. <p>Congratulations, you've just had an account created for you on #{settings.appName} with the email address "<%= to %>".</p>
  12. <p><a href="<%= setNewPasswordUrl %>">Click here to set your password and log in.</a></p>
  13. <p>If you have any questions or problems, please contact <a href="mailto:#{settings.adminEmail}">#{settings.adminEmail}</a>.</p>
  14. """
  15. templates.canceledSubscription =
  16. subject: _.template "ShareLaTeX thoughts"
  17. layout: PersonalEmailLayout
  18. type:"lifecycle"
  19. compiledTemplate: _.template '''
  20. <p>Hi <%= first_name %>,</p>
  21. <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/F7OzIY">this survey</a>?</p>
  22. <p>Thank you in advance.</p>
  23. <p>
  24. Henry <br>
  25. ShareLaTeX Co-founder
  26. </p>
  27. '''
  28. templates.passwordResetRequested =
  29. subject: _.template "Password Reset - #{settings.appName}"
  30. layout: NotificationEmailLayout
  31. type:"notification"
  32. compiledTemplate: _.template """
  33. <h2>Password Reset</h2>
  34. <p>
  35. We got a request to reset your #{settings.appName} password.
  36. <p>
  37. <center>
  38. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:24px;">
  39. <div style="padding-right:10px;padding-left:10px">
  40. <a href="<%= setNewPasswordUrl %>" style="text-decoration:none" target="_blank">
  41. <span style= "font-size:16px;font-family:Arial;font-weight:bold;color:#fff;white-space:nowrap;display:block; text-align:center">
  42. Reset password
  43. </span>
  44. </a>
  45. </div>
  46. </div>
  47. </center>
  48. If you ignore this message, your password won't be changed.
  49. <p>
  50. If you didn't request a password reset, let us know.
  51. </p>
  52. <p>Thank you</p>
  53. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  54. """
  55. templates.projectSharedWithYou =
  56. subject: _.template "<%= owner.email %> wants to share <%= project.name %> with you"
  57. layout: NotificationEmailLayout
  58. type:"notification"
  59. compiledTemplate: _.template """
  60. <p>Hi, <%= owner.email %> wants to share <a href="<%= project.url %>">'<%= project.name %>'</a> with you</p>
  61. <center>
  62. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:24px;">
  63. <div style="padding-right:10px;padding-left:10px">
  64. <a href="<%= project.url %>" style="text-decoration:none" target="_blank">
  65. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  66. View Project
  67. </span>
  68. </a>
  69. </div>
  70. </div>
  71. </center>
  72. <p> Thank you</p>
  73. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  74. """
  75. templates.completeJoinGroupAccount =
  76. subject: _.template "Verify Email to join <%= group_name %> group"
  77. layout: NotificationEmailLayout
  78. type:"notification"
  79. compiledTemplate: _.template """
  80. <p>Hi, please verify your email to join the <%= group_name %> and get your free premium account</p>
  81. <center>
  82. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:24px;">
  83. <div style="padding-right:10px;padding-left:10px">
  84. <a href="<%= completeJoinUrl %>" style="text-decoration:none" target="_blank">
  85. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  86. Verify now
  87. </span>
  88. </a>
  89. </div>
  90. </div>
  91. </center>
  92. <p> Thank you</p>
  93. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  94. """
  95. module.exports =
  96. templates: templates
  97. buildEmail: (templateName, opts)->
  98. template = templates[templateName]
  99. opts.siteUrl = settings.siteUrl
  100. opts.body = template.compiledTemplate(opts)
  101. if settings.email?.templates?.customFooter?
  102. opts.body += settings.email?.templates?.customFooter
  103. return {
  104. subject : template.subject(opts)
  105. html: template.layout(opts)
  106. type:template.type
  107. }