Skip to content

Commit

Permalink
Merge pull request #516 from bc-williamkwon/revertPaperBranchChange
Browse files Browse the repository at this point in the history
 Revert paper branch change
  • Loading branch information
mattolson authored Sep 12, 2019
2 parents 0906470 + 3e195e8 commit 87e08bd
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 103 deletions.
1 change: 0 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"modules": true
},
"env": {
"es6": true,
"node": true
},
"globals": {
Expand Down
86 changes: 15 additions & 71 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
},
"homepage": "https://github.com/bigcommerce/stencil-cli",
"dependencies": {
"@bigcommerce/stencil-paper": "3.0.0-rc.20",
"@bigcommerce/stencil-paper": "^2.0.18",
"@bigcommerce/stencil-styles": "1.1.0",
"accept-language-parser": "^1.0.2",
"archiver": "^0.14.4",
Expand Down
39 changes: 15 additions & 24 deletions server/plugins/renderer/renderer.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,33 +458,24 @@ internals.getHeaders = function (request, options, config) {
* @type {Object}
*/
internals.themeAssembler = {
getTemplates: (path, processor) => {
return new Promise((resolve, reject) => {
TemplateAssembler.assemble(internals.getThemeTemplatesPath(), path, (err, templates) => {
if (err) {
return reject(err);
getTemplates: (path, processor, callback) => {
TemplateAssembler.assemble(internals.getThemeTemplatesPath(), path, (err, templates) => {
if (templates[path]) {
// Check if the string includes frontmatter configuration and remove it
var match = templates[path].match(/---\r?\n[\S\s]*\r?\n---\r?\n([\S\s]*)$/);

if (_.isObject(match) && match[1]) {
templates[path] = match[1];
}
if (templates[path]) {
// Check if the string includes frontmatter configuration and remove it
const match = templates[path].match(/---\r?\n[\S\s]*\r?\n---\r?\n([\S\s]*)$/);
}

if (_.isObject(match) && match[1]) {
templates[path] = match[1];
}
}
return resolve(processor(templates));
});
})
callback(null, processor(templates));
});
},
getTranslations: () => {
return new Promise((resolve, reject) => {
LangAssembler.assemble((err, translations) => {
if (err) {
return reject(err);
}
return resolve(_.mapValues(translations, locales => JSON.parse(locales)));
});
})
getTranslations: (callback) => {
LangAssembler.assemble((err, translations) => {
callback(null, _.mapValues(translations, locales => JSON.parse(locales)));
});
},
};

Expand Down
17 changes: 11 additions & 6 deletions server/plugins/renderer/responses/pencil-response.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ const internals = {};

module.exports = function (data, assembler) {
this.respond = function (request, reply) {
const paper = new Paper(data.context.settings, data.context.theme_settings, assembler, "handlebars-v3");
var response,
output,
paper,
templatePath;

var paper = new Paper(data.context.settings, data.context.theme_settings, assembler);

// Set the environment to dev
data.context.in_development = true;
Expand All @@ -17,21 +22,21 @@ module.exports = function (data, assembler) {
paper.addDecorator(decorator);
})

const templatePath = internals.getTemplatePath(request, data);
templatePath = internals.getTemplatePath(request, data);

paper.loadTheme(templatePath, data.acceptLanguage).then(() => {
paper.loadTheme(templatePath, data.acceptLanguage, function () {
if (request.query.debug === 'context') {
return reply(data.context);
}

const output = paper.renderTheme(templatePath, data);
const response = reply(output);
output = paper.renderTheme(templatePath, data);
response = reply(output);
response.code(data.statusCode);

if (data.headers['set-cookie']) {
response.header('set-cookie', data.headers['set-cookie']);
}
}).catch(err => console.error(err.message.red));
});
};
};

Expand Down

0 comments on commit 87e08bd

Please sign in to comment.