From af16e2c3e596a10912b34a40c31266c4001e4133 Mon Sep 17 00:00:00 2001 From: Gekkejager Date: Thu, 3 Mar 2016 14:07:53 +0100 Subject: [PATCH 01/14] Add cc and bcc options --- docs/mailer.html | 198 ++++++++++++++++++++++++----------------------- lib/mailer.js | 2 + 2 files changed, 102 insertions(+), 98 deletions(-) diff --git a/docs/mailer.html b/docs/mailer.html index 5cf7a28..b3677c0 100644 --- a/docs/mailer.html +++ b/docs/mailer.html @@ -10,51 +10,51 @@
- + - +
- +
Mailer = {
   settings: {
     silent: false,
@@ -142,13 +142,13 @@ 

Setup

return this; } };
- + - - + +
  • - +
    @@ -163,53 +163,53 @@

    The factory

    with data, as well as sending emails from those templates.

    - +
    const factory = (options) => {
       check(options, Match.ObjectIncluding({
    - +
  • - - + +
  • - +

    Mailer must take a templates object with template names as keys.

    - +
        templates: Object,
    - +
  • - - + +
  • - +

    Take optional template helpers.

    - +
        helpers: Match.Optional(Object),
    - +
  • - - + +
  • - +

    Take an optional layout template object.

    - +
        layout: Match.Optional(Match.OneOf(Object, Boolean))
       }));
     
    @@ -221,13 +221,13 @@ 

    The factory

    Utils.setupLogger(settings.logger, { suppressInfo: settings.silent });
    - +
  • - - + +
  • - +
    @@ -236,19 +236,19 @@

    The factory

    the template.

    - +
      const addHelpers = (template) => {
         check(template.name, String);
         check(template.helpers, Match.Optional(Object));
         return Template[template.name].helpers(_.extend({}, globalHelpers, template.helpers));
       };
    - +
  • - - + +
  • - +
    @@ -260,7 +260,7 @@

    Compile

    can optionally have paths to any SCSS and CSS stylesheets.

    - +
      const compile = (template) => {
         check(template, Match.ObjectIncluding({
           path: String,
    @@ -294,13 +294,13 @@ 

    Compile

    addHelpers(layout); }
    - +
  • - - + +
  • - +
    @@ -308,34 +308,34 @@

    Compile

    Template.<template.name>
     
    - +
        const tmpl = SSR.compileTemplate(template.name, content, {
           language: settings.language
         });
    - +
  • - - + +
  • - +

    Add helpers to template.

    - +
        addHelpers(template);
         return tmpl;
       };
    - +
  • - - + +
  • - +
    @@ -344,7 +344,7 @@

    Render

    Will compile the template if not done already.

    - +
      const render = (templateName, data) => {
         check(templateName, String);
         check(data, Match.Optional(Object));
    @@ -370,13 +370,13 @@ 

    Render

    let preview = null; let css = null;
    - +
  • - - + +
  • - +
    @@ -387,19 +387,19 @@

    Render

    preview prop in the data context to apply to the layout.

    - +
          if (tmpl.__helpers.has('preview')) {
             preview = tmpl.__helpers.get('preview');
           } else if (data.preview) {
             preview = data.preview;
           }
    - +
  • - - + +
  • - +
    @@ -407,7 +407,7 @@

    Render

    the layout in <style> tags. Ideal for media queries.

    - +
          if (template.extraCSS) {
             try {
               css = Utils.readFile(template.extraCSS);
    @@ -432,13 +432,13 @@ 

    Render

    rendered = Utils.addDoctype(rendered); return rendered; };
    - +
  • - - + +
  • - +
    @@ -447,12 +447,14 @@

    Send

    including the template name and optional data object.

    - +
      const sendEmail = (options) => {
         check(options, {
           to: String,
           subject: String,
           template: String,
    +      cc: Match.Optional(String),
    +      bcc: Match.Optional(String),
           replyTo: Match.Optional(String),
           from: Match.Optional(String),
           data: Match.Optional(Object),
    @@ -468,13 +470,13 @@ 

    Send

    } const opts = _.extend({}, defaults, options);
    - +
  • - - + +
  • - +
    @@ -482,7 +484,7 @@

    Send

    create plain-text version from HTML.

    - +
        try {
           opts.html = render(options.template, options.data);
           if (settings.plainText) {
    @@ -525,13 +527,13 @@ 

    Send

    init }; };
    - +
  • - - + +
  • - +
    @@ -540,7 +542,7 @@

    Send

    inner init() function.

    - +
    Mailer.init = function(opts) {
       const obj = _.extend(this, factory(opts));
     
    @@ -550,9 +552,9 @@ 

    Send

    obj.init(); };
    - +
  • - + diff --git a/lib/mailer.js b/lib/mailer.js index e51052a..79d5882 100644 --- a/lib/mailer.js +++ b/lib/mailer.js @@ -227,6 +227,8 @@ const factory = (options) => { to: String, subject: String, template: String, + cc: Match.Optional(String), + bcc: Match.Optional(String), replyTo: Match.Optional(String), from: Match.Optional(String), data: Match.Optional(Object), From a255c636a6eb3c6f5d3218c7b7cde532964446af Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 11:53:42 -0300 Subject: [PATCH 02/14] Readme update --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 18fa5f8..2db7e7a 100644 --- a/README.md +++ b/README.md @@ -521,6 +521,12 @@ route: { PRs and help is welcomed. +## Things to do + +- [ ] Tests. + +Also see [open issues](https://github.com/lookback/meteor-emails/issues). + *** Made by [Lookback](http://github.com/lookback) From 1fcbffe8ad6c2336f1c8974796babf6e9aca9e58 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:18:54 -0300 Subject: [PATCH 03/14] Update route send action to support cc and bcc --- lib/routing.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/lib/routing.js b/lib/routing.js index 72e416d..48f8728 100644 --- a/lib/routing.js +++ b/lib/routing.js @@ -72,7 +72,7 @@ Routing = (template, settings, render, compile) => { }; const sendAction = (req, res, params, template) => { - const to = params.query.to || settings.testEmail; + const {to = settings.testEmail, cc, bcc} = params.query; Utils.Logger.info(`Sending ${template.name}…`); @@ -86,12 +86,22 @@ Routing = (template, settings, render, compile) => { return; } - const result = Mailer.send({ + const options = { to, data, template: template.name, subject: '[TEST] ' + template.name - }); + }; + + if (cc) { + options.cc = cc; + } + + if (bcc) { + options.bcc = bcc; + } + + const result = Mailer.send(options); let msg = ''; @@ -101,14 +111,17 @@ Routing = (template, settings, render, compile) => { } else { res.writeHead(200); const reallySentEmail = !!process.env.MAIL_URL; - msg = reallySentEmail ? `Sent test email to ${to}` : `Sent email to STDOUT`; + msg = reallySentEmail + ? `Sent test email to ${to}` + ((cc) ? ` and cc: ${cc}` : '') + ((bcc) ? `, and bcc: ${bcc}` : '') + : `Sent email to STDOUT`; } + Utils.Logger.info(msg); res.end(msg); } else { res.writeHead(400); - res.end('No testEmail provided.'); + res.end('No testEmail or ?to parameter provided.'); } }; From 01171591a6f75a70938e4c5024dbf37cad52c791 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:19:21 -0300 Subject: [PATCH 04/14] Example app: Sett MAIL_URL from Meteor.settings, unless it's set already --- example/server/server.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/example/server/server.js b/example/server/server.js index bcd991b..39ccdc6 100644 --- a/example/server/server.js +++ b/example/server/server.js @@ -1,3 +1,7 @@ +if (!process.env.MAIL_URL) { + process.env.MAIL_URL = Meteor.settings.MAIL_URL; +} + Mailer.config({ from: 'John Doe ', replyTo: 'John Doe ', From 9ab114232aa660042455db035fc1168a2938b5a8 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:33:06 -0300 Subject: [PATCH 05/14] Add Lookback linting --- .eslintignore | 2 ++ .eslintrc | 21 +++------------------ .gitignore | 3 +++ package.json | 22 ++++++++++++++++++++++ 4 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 .eslintignore create mode 100644 package.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..2e1aee1 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +example/.meteor +node_modules diff --git a/.eslintrc b/.eslintrc index 377ec71..57a0db7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,21 +1,5 @@ { - "extends": "eslint:recommended", - "rules": { - "brace-style": [2, "1tbs", { "allowSingleLine": true }], - "strict": 0, - "quotes": [2, "single"], - "no-underscore-dangle": 0, - "curly": 0, - "no-unused-vars": 1, - "no-console": 0, - "no-var": 2 - }, - - "env": { - "node": true, - "meteor": true, - "es6": true - }, + "extends": "lookback/meteor", "globals": { "Mailer": true, @@ -26,6 +10,7 @@ "TemplateHelpers": true, "SSR": false, "Picker": false, - "Routing": true + "Routing": true, + "Templates": true } } diff --git a/.gitignore b/.gitignore index ebae69d..a9b3a32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .DS_Store .sass-cache/ .npm/ +example/settings.json +npm-debug.log +node_modules diff --git a/package.json b/package.json new file mode 100644 index 0000000..6cd05d9 --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "lookback-emails", + "version": "0.7.1", + "description": "`lookback:emails` is a Meteor package that makes it easier to build, test and debug rich HTML emails.", + "repository": { + "type": "git", + "url": "git+https://github.com/lookback/meteor-emails.git" + }, + "scripts": { + "lint": "./node_modules/.bin/eslint ." + }, + "license": "MIT", + "bugs": { + "url": "https://github.com/lookback/meteor-emails/issues" + }, + "devDependencies": { + "babel-eslint": "^5.0.0", + "babel-preset-es2015": "^6.3.13", + "eslint": "^2.2.0", + "eslint-config-lookback": "lookback/eslint-config-lookback" + } +} From 3c6d4036d2f9f258a196a2a03b3f4ecb21a7fa42 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:33:46 -0300 Subject: [PATCH 06/14] Version 0.7.2 --- README.md | 13 +++++++++++++ example/.meteor/versions | 2 +- package.js | 2 +- package.json | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2db7e7a..1b1de15 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,8 @@ Please inspect the provided sample code for details. template: 'templateName', // Required. replyTo: 'Name ', // Override global 'ReplyTo: ' option. from: 'Name ', // Override global 'From: ' option. + cc: 'Name ', // Optional. + bcc: 'Name ', // Optional. data: {} // Optional. Render your email with a data object. } ``` @@ -470,6 +472,7 @@ Why not try [`meteor-logger`](https://github.com/lookback/meteor-logger)? :) ## Version history +- `0.7.2` - Support `cc` and `bcc` options to `Mailer.send()`. Filed in [#52](https://github.com/lookback/meteor-emails/issues/52), fixed in [#52](https://github.com/lookback/meteor-emails/pull/54). - `0.7.1` - Check for existence of `Blaze` global before extending with registered Blaze helpers. - `0.7.0` - Replaced Iron Router dependency with `meteorhacks:picker`, which means you can now use this package with FlowRouter as well. @@ -521,6 +524,16 @@ route: { PRs and help is welcomed. +## Develop + +Clone repo, and run: + +``` +npm install +``` + +to install dev dev dependencies. We're using ESLint for linting. + ## Things to do - [ ] Tests. diff --git a/example/.meteor/versions b/example/.meteor/versions index 15f7cf8..96dd369 100644 --- a/example/.meteor/versions +++ b/example/.meteor/versions @@ -34,7 +34,7 @@ jquery@1.11.4 kadira:flow-router@2.9.0 livedata@1.0.15 logging@1.0.8 -lookback:emails@0.7.1 +lookback:emails@0.7.2 meteor@1.1.9 meteor-base@1.0.1 meteorhacks:picker@1.0.3 diff --git a/package.js b/package.js index ea5718e..d6b8e38 100644 --- a/package.js +++ b/package.js @@ -4,7 +4,7 @@ var where = 'server'; Package.describe({ name: 'lookback:emails', summary: 'Send HTML emails with server side Blaze templates. Preview and debug in the browser.', - version: '0.7.1', + version: '0.7.2', git: 'https://github.com/lookback/meteor-emails.git' }); diff --git a/package.json b/package.json index 6cd05d9..d1f66f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lookback-emails", - "version": "0.7.1", + "version": "0.7.2", "description": "`lookback:emails` is a Meteor package that makes it easier to build, test and debug rich HTML emails.", "repository": { "type": "git", From ae215f5715ce8e9fd3a8a4a0793ea87f52c4009d Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:37:15 -0300 Subject: [PATCH 07/14] Use Ecmascript 0.1.5 --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index d6b8e38..1597850 100644 --- a/package.js +++ b/package.js @@ -23,7 +23,7 @@ Package.onUse(function(api) { ], where, { weak: true }); api.use([ - 'ecmascript', + 'ecmascript@0.1.5', 'check', 'underscore', 'email', From 15bb7d541851925f2eeda3835b9baf3fe60ed12d Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:38:19 -0300 Subject: [PATCH 08/14] Publish 0.7.2 --- .versions | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.versions b/.versions index 903b5fa..422122b 100644 --- a/.versions +++ b/.versions @@ -1,38 +1,66 @@ +autoupdate@1.2.4 babel-compiler@5.8.24_1 babel-runtime@0.1.4 base64@1.0.4 +binary-heap@1.0.4 blaze@2.1.3 blaze-tools@1.0.4 boilerplate-generator@1.0.4 caching-compiler@1.0.0 +caching-html-compiler@1.0.2 +callback-hook@1.0.4 check@1.1.0 coffeescript@1.0.11 +ddp@1.2.2 +ddp-client@1.2.1 +ddp-common@1.2.2 +ddp-server@1.2.2 deps@1.0.9 diff-sequence@1.0.1 ecmascript@0.1.6 ecmascript-runtime@0.2.6 ejson@1.0.7 email@1.0.8 +geojson-utils@1.0.4 html-tools@1.0.5 htmljs@1.0.5 +http@1.1.1 id-map@1.0.4 jquery@1.11.4 +local-test:lookback:emails@0.7.2 logging@1.0.8 -lookback:emails@0.7.1 +lookback:emails@0.7.2 meteor@1.1.10 meteorhacks:picker@1.0.3 meteorhacks:ssr@2.1.2 +minifiers@1.1.7 +minimongo@1.0.10 +mongo@1.1.3 mongo-id@1.0.1 +npm-mongo@1.4.39_1 observe-sequence@1.0.7 +ordered-dict@1.0.4 +practicalmeteor:chai@2.1.0_1 +practicalmeteor:loglevel@1.2.0_2 +practicalmeteor:mocha@2.1.0_7 +practicalmeteor:mocha-core@0.1.4 +practicalmeteor:sinon@1.14.1_2 promise@0.5.1 random@1.0.5 +reactive-dict@1.1.3 reactive-var@1.0.6 +reload@1.1.4 +retry@1.0.4 routepolicy@1.0.6 sacha:juice@0.1.4 +session@1.1.1 spacebars@1.0.7 spacebars-compiler@1.0.7 +templating@1.1.5 +templating-tools@1.0.0 tracker@1.0.9 ui@1.0.8 underscore@1.0.4 +url@1.0.5 webapp@1.2.3 webapp-hashing@1.0.5 From 9e7571937b70c080b1077a36f5b2fb759d170eb3 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Thu, 3 Mar 2016 12:38:50 -0300 Subject: [PATCH 09/14] README typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b1de15..c5daf68 100644 --- a/README.md +++ b/README.md @@ -472,7 +472,7 @@ Why not try [`meteor-logger`](https://github.com/lookback/meteor-logger)? :) ## Version history -- `0.7.2` - Support `cc` and `bcc` options to `Mailer.send()`. Filed in [#52](https://github.com/lookback/meteor-emails/issues/52), fixed in [#52](https://github.com/lookback/meteor-emails/pull/54). +- `0.7.2` - Support `cc` and `bcc` options to `Mailer.send()`. Filed in [#52](https://github.com/lookback/meteor-emails/issues/52), fixed in [#54](https://github.com/lookback/meteor-emails/pull/54). - `0.7.1` - Check for existence of `Blaze` global before extending with registered Blaze helpers. - `0.7.0` - Replaced Iron Router dependency with `meteorhacks:picker`, which means you can now use this package with FlowRouter as well. From 7bfdff61f17a7174415cf95477622c5c66b9d244 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Tue, 8 Mar 2016 13:59:20 -0800 Subject: [PATCH 10/14] Separate options objects in sendEmail function. --- lib/mailer.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/mailer.js b/lib/mailer.js index 79d5882..a15ed28 100644 --- a/lib/mailer.js +++ b/lib/mailer.js @@ -1,4 +1,4 @@ -//`lookback:emails` is a small package for Meteor which helps you +// `lookback:emails` is a small package for Meteor which helps you // tremendously in the process of building, testing and debugging // HTML emails in Meteor applications. // @@ -16,7 +16,8 @@ const TAG = 'mailer'; // - `baseUrl` is what root domain to base relative paths from. // - `testEmail`, when testing emails, set this variable. // - `logger`, optionally inject an external logger. Defaults to `console`. -// - `disabled`, optionally disable the actual email sending. Useful for E2E testing. Defaults to `false`. +// - `disabled`, optionally disable the actual email sending. Useful for E2E testing. +// Defaults to `false`. // - `addRoutes`, should we add preview and send routes? Defaults to `true` in development. Mailer = { settings: { @@ -42,7 +43,7 @@ Mailer = { middlewares: [], use(middleware) { - if(!_.isFunction(middleware)) { + if (!_.isFunction(middleware)) { console.error('Middleware must be a function!'); } else { this.middlewares.push(middleware); @@ -175,7 +176,6 @@ const factory = (options) => { const layout = template.layout || options.layout; if (layout && template.layout !== false) { - let preview = null; let css = null; @@ -197,7 +197,8 @@ const factory = (options) => { try { css = Utils.readFile(template.extraCSS); } catch (ex) { - Utils.Logger.error(`Could not add extra CSS when rendering ${templateName}: ${ex.message}`, TAG); + Utils.Logger.error( + `Could not add extra CSS when rendering ${templateName}: ${ex.message}`, TAG); } } @@ -222,8 +223,8 @@ const factory = (options) => { // // The main sending-email function. Takes a set of usual email options, // including the template name and optional data object. - const sendEmail = (options) => { - check(options, { + const sendEmail = (sendOptions) => { + check(sendOptions, { to: String, subject: String, template: String, @@ -243,12 +244,13 @@ const factory = (options) => { defaults.replyTo = settings.replyTo; } - const opts = _.extend({}, defaults, options); + // `template` isn't part of Meteor's `Email.send()` API, so omit this. + const opts = _.omit(_.extend({}, defaults, sendOptions), 'template', 'data'); // Render HTML with optional data context and optionally // create plain-text version from HTML. try { - opts.html = render(options.template, options.data); + opts.html = render(sendOptions.template, sendOptions.data); if (settings.plainText) { opts.text = Utils.toText(opts.html, settings.plainTextOpts); } @@ -296,7 +298,7 @@ const factory = (options) => { Mailer.init = function(opts) { const obj = _.extend(this, factory(opts)); - if(obj.settings.addRoutes) { + if (obj.settings.addRoutes) { obj.use(Routing); } From d441cc621e03aca90e3acb7d161b2554afc85c76 Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Tue, 8 Mar 2016 14:16:23 -0800 Subject: [PATCH 11/14] Allow array of strings in to, bcc, cc, and replyTo options to sendEmail --- lib/mailer.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mailer.js b/lib/mailer.js index a15ed28..ee48d1f 100644 --- a/lib/mailer.js +++ b/lib/mailer.js @@ -225,12 +225,12 @@ const factory = (options) => { // including the template name and optional data object. const sendEmail = (sendOptions) => { check(sendOptions, { - to: String, + to: Match.OneOf(String, [String]), subject: String, template: String, - cc: Match.Optional(String), - bcc: Match.Optional(String), - replyTo: Match.Optional(String), + cc: Match.Optional(Match.OneOf(String, [String])), + bcc: Match.Optional(Match.OneOf(String, [String])), + replyTo: Match.Optional(Match.OneOf(String, [String])), from: Match.Optional(String), data: Match.Optional(Object), headers: Match.Optional(Object) From fac91de438a6d28c48711aec64cef152da5f649c Mon Sep 17 00:00:00 2001 From: Johan Brook Date: Tue, 8 Mar 2016 14:16:57 -0800 Subject: [PATCH 12/14] Update routing middleware to support multiple to, cc, bcc in send action --- lib/routing.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/routing.js b/lib/routing.js index 48f8728..65a05f1 100644 --- a/lib/routing.js +++ b/lib/routing.js @@ -12,6 +12,10 @@ const CONTENT_TYPES = { text: 'text/plain' }; +const arrayOrString = (str) => { + return Array.isArray(str) ? str : str.split(','); +}; + Routing = (template, settings, render, compile) => { check(template.name, String); check(template.route.path, String); @@ -22,7 +26,7 @@ Routing = (template, settings, render, compile) => { const previewAction = (type) => { check(type, Match.OneOf('html', 'text')); - return (req, res, params, template) => { + return (req, res, params, _) => { let data = null; try { @@ -71,7 +75,7 @@ Routing = (template, settings, render, compile) => { }; }; - const sendAction = (req, res, params, template) => { + const sendAction = (req, res, params, _) => { const {to = settings.testEmail, cc, bcc} = params.query; Utils.Logger.info(`Sending ${template.name}…`); @@ -87,18 +91,18 @@ Routing = (template, settings, render, compile) => { } const options = { - to, + to: arrayOrString(to), data, template: template.name, subject: '[TEST] ' + template.name }; if (cc) { - options.cc = cc; + options.cc = arrayOrString(cc); } if (bcc) { - options.bcc = bcc; + options.bcc = arrayOrString(bcc); } const result = Mailer.send(options); From 46d95fedeae575029036664670de8084a970a0c6 Mon Sep 17 00:00:00 2001 From: Ben Greene Date: Mon, 14 Mar 2016 11:19:32 -0400 Subject: [PATCH 13/14] Upgrade to meteorhacks:ssr 2.2.0 --- package.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.js b/package.js index 1597850..51fe7f2 100644 --- a/package.js +++ b/package.js @@ -28,7 +28,7 @@ Package.onUse(function(api) { 'underscore', 'email', 'sacha:juice@0.1.3', - 'meteorhacks:ssr@2.1.2', + 'meteorhacks:ssr@2.2.0', 'meteorhacks:picker@1.0.3' ], where); From 5044bac74b0104abde3ac1464a3aa565083134d3 Mon Sep 17 00:00:00 2001 From: Carlos Baraza Haro Date: Thu, 17 Mar 2016 12:58:24 +0100 Subject: [PATCH 14/14] Fix CSS loading --- lib/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index bc6d9e0..830e1bd 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -119,12 +119,12 @@ Utils = { let content = html; if (template.css) { - const css = Utils.readFile(template.css); + const css = Utils.readFile(template.css, template.packageFolderName); content = juice.inlineContent(content, css, juiceOpts); } if (template.scss) { - const scss = Utils.toCSS(template.scss); + const scss = Utils.toCSS(template.scss, template.packageFolderName); content = juice.inlineContent(content, scss, juiceOpts); } @@ -141,7 +141,7 @@ Utils = { }, readFile: function(relativePathFromApp, packageFolderName) { - const file = packageFolderName ? + const file = packageFolderName ? path.join(PACKAGES_ROOT, packageFolderName, relativePathFromApp) : path.join(ROOT, relativePathFromApp); @@ -149,8 +149,8 @@ Utils = { return fs.readFileSync(file, { encoding: 'utf8' }); - } catch (ex) { + Utils.Logger.error(`Could not find file: ${file}, ${ex.message}`, TAG); throw new Meteor.Error(500, `Could not find file: ${file}`, ex.message); } }, @@ -163,7 +163,7 @@ Utils = { } const file = packageFolderName ? - path.join(PACKAGES_ROOT, packageName, relativePathFromApp) + path.join(PACKAGES_ROOT, packageFolderName, scss) : path.join(ROOT, scss); const sass = Package['chrisbutler:node-sass'].sass;