EmailBuilder.coffee 4.2 KB

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