diff --git a/controllers/products.js b/controllers/products.js index 9ce46c2..135fa00 100644 --- a/controllers/products.js +++ b/controllers/products.js @@ -14,8 +14,6 @@ var getProduct = module.exports.getProduct = function(req, res, next) { if (err) return res.json(500, err); if (response.statusCode !== 200) res.send(response.statusCode, body); //TODO: better - logger.info('product from magic: ' + body); - var product = JSON.parse(body).data; var data = { @@ -28,7 +26,7 @@ var getProduct = module.exports.getProduct = function(req, res, next) { twitter: product.businessTwitter }, image: { - url: product.photoUrl + '/convert?fit=clip&w=320&h=320', //TODO: switch to using hb filepicker helper + url: product.photoUrl, width: 320, height: 320 }, @@ -36,10 +34,6 @@ var getProduct = module.exports.getProduct = function(req, res, next) { } }; - if (product.photoUrl == null) delete data.product.image; - - logger.info('compiling template with data: ' + JSON.stringify(data)); - res.send(view(data)); }); }; diff --git a/package.json b/package.json index 2561769..8202afe 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ } ], "scripts": { + "prestart": "find views -name *handlebars | xargs -I {} echo node_modules/.bin/handlebars {} -f {} | sed 's/\\(.*\\)\\/.*\\.handlebars/\\1\\/index.js/g' | sh", "start": "node ./main.js" }, "main": "./server.js", diff --git a/views/index.js b/views/index.js index 18764b5..15b5555 100644 --- a/views/index.js +++ b/views/index.js @@ -1,5 +1,7 @@ global.Handlebars = require('handlebars'); +require('./handlebars-helpers').register(global.Handlebars); + require('./product'); module.exports = Handlebars.templates; diff --git a/views/product/product.handlebars b/views/product/product.handlebars index 4f35845..8284770 100644 --- a/views/product/product.handlebars +++ b/views/product/product.handlebars @@ -1,7 +1,7 @@ - {{#if product.image}} + {{#if product.image.url}} {{#if product.business.twitter}} @@ -9,7 +9,7 @@ {{/if}} - +