EmailBuilder.coffee 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. _ = require('underscore')
  2. PersonalEmailLayout = require("./Layouts/PersonalEmailLayout")
  3. NotificationEmailLayout = require("./Layouts/NotificationEmailLayout")
  4. settings = require("settings-sharelatex")
  5. templates = {}
  6. templates.welcome =
  7. subject: _.template "Welcome to ShareLaTeX"
  8. layout: PersonalEmailLayout
  9. type:"lifecycle"
  10. compiledTemplate: _.template '''
  11. <p>Hi <%= first_name %>,</p>
  12. <p>Thanks for signing up to ShareLaTeX! If you ever get lost, you can log in again <a href="<%= siteUrl %>/login">here</a>.</p>
  13. <p>If you're new to LaTeX, take a look at our <a href="<%= siteUrl %>/learn">Help Guides</a> and <a href="<%= siteUrl %>/templates">Templates</a>.</p>
  14. <p>
  15. Regards, <br>
  16. Henry <br>
  17. ShareLaTeX Co-founder
  18. </p>
  19. <p>PS. We love talking to our users about ShareLaTeX. Reply to this email to get in touch us with us directly, whatever the reason. Questions, comments, problems, suggestions, all welcome!<p>
  20. '''
  21. templates.canceledSubscription =
  22. subject: _.template "ShareLaTeX thoughts"
  23. layout: PersonalEmailLayout
  24. type:"lifecycle"
  25. compiledTemplate: _.template '''
  26. <p>Hi <%= first_name %>,</p>
  27. <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? Feedback from our users is the only way we can improve ShareLaTeX.</p>
  28. <p>Thank you in advance.</p>
  29. <p>
  30. Henry <br>
  31. ShareLaTeX Co-founder
  32. </p>
  33. '''
  34. templates.passwordResetRequested =
  35. subject: _.template "Password Reset - ShareLatex.com"
  36. layout: NotificationEmailLayout
  37. type:"notification"
  38. compiledTemplate: _.template '''
  39. <h1 class="h1">Password Reset</h1>
  40. <p>
  41. We got a request to reset your ShareLaTeX password.
  42. <p>
  43. <center>
  44. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:12.5px;">
  45. <div style="padding-right:10px;padding-left:10px">
  46. <a href="<%= setNewPasswordUrl %>" style="text-decoration:none" target="_blank">
  47. <span style= "font-size:16px;font-family:Arial;font-weight:bold;color:#fff;white-space:nowrap;display:block; text-align:center">
  48. Reset password
  49. </span>
  50. </a>
  51. </div>
  52. </div>
  53. </center>
  54. If you ignore this message, your password won't be changed.
  55. <p>
  56. If you didn't request a password reset, let us know.
  57. </p>
  58. <p>Thank you</p>
  59. <p> <a href="<%= siteUrl %>"> ShareLatex.com </a></p>
  60. '''
  61. templates.projectSharedWithYou =
  62. subject: _.template "<%= owner.email %> wants to share <%= project.name %> with you"
  63. layout: NotificationEmailLayout
  64. type:"notification"
  65. compiledTemplate: _.template '''
  66. <p>Hi, <%= owner.email %> wants to share <a href="<%= project.url %>">'<%= project.name %>'</a> with you</p>
  67. <p>&nbsp;</p>
  68. <center>
  69. <div style="width:200px;background-color:#a93629;border:1px solid #e24b3b;border-radius:3px;padding:15px; margin:12.5px;">
  70. <div style="padding-right:10px;padding-left:10px">
  71. <a href="<%= project.url %>" style="text-decoration:none" target="_blank">
  72. <span style= "font-size:16px;font-family:Helvetica,Arial;font-weight:400;color:#fff;white-space:nowrap;display:block; text-align:center">
  73. View Project
  74. </span>
  75. </a>
  76. </div>
  77. </div>
  78. </center>
  79. <p> Thank you</p>
  80. <p> <a href="<%= siteUrl %>"> ShareLatex.com </a></p>
  81. '''
  82. module.exports =
  83. buildEmail: (templateName, opts)->
  84. template = templates[templateName]
  85. opts.siteUrl = settings.siteUrl
  86. opts.body = template.compiledTemplate(opts)
  87. return {
  88. subject : template.subject(opts)
  89. html: template.layout(opts)
  90. type:template.type
  91. }