EmailBuilder.coffee 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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/f5lBiZ">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.projectInvite =
  76. subject: _.template "<%= project.name %> - shared by <%= owner.email %>"
  77. layout: NotificationEmailLayout
  78. type:"notification"
  79. plainTextTemplate: _.template """
  80. Hi, <%= owner.email %> wants to share '<%= project.name %>' with you.
  81. Follow this link to view the project: <%= inviteUrl %>
  82. Thank you
  83. #{settings.appName} - <%= siteUrl %>
  84. """
  85. compiledTemplate: _.template """
  86. <p>Hi, <%= owner.email %> wants to share <a href="<%= inviteUrl %>">'<%= project.name %>'</a> with you</p>
  87. <center>
  88. <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">
  89. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  90. View Project
  91. </span>
  92. </a>
  93. </center>
  94. <p> Thank you</p>
  95. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  96. """
  97. templates.completeJoinGroupAccount =
  98. subject: _.template "Verify Email to join <%= group_name %> group"
  99. layout: NotificationEmailLayout
  100. type:"notification"
  101. compiledTemplate: _.template """
  102. <p>Hi, please verify your email to join the <%= group_name %> and get your free premium account</p>
  103. <center>
  104. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:24px;">
  105. <div style="padding-right:10px;padding-left:10px">
  106. <a href="<%= completeJoinUrl %>" style="text-decoration:none" target="_blank">
  107. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  108. Verify now
  109. </span>
  110. </a>
  111. </div>
  112. </div>
  113. </center>
  114. <p> Thank you</p>
  115. <p> <a href="<%= siteUrl %>">#{settings.appName}</a></p>
  116. """
  117. module.exports =
  118. templates: templates
  119. buildEmail: (templateName, opts)->
  120. template = templates[templateName]
  121. opts.siteUrl = settings.siteUrl
  122. opts.body = template.compiledTemplate(opts)
  123. if settings.email?.templates?.customFooter?
  124. opts.body += settings.email?.templates?.customFooter
  125. return {
  126. subject : template.subject(opts)
  127. html: template.layout(opts)
  128. text: template?.plainTextTemplate?(opts)
  129. type:template.type
  130. }