mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-02 20:37:08 +01:00
Merge branch 'master' into dev
This commit is contained in:
31
dist/generators/html-pdf-cli-generator.js
vendored
31
dist/generators/html-pdf-cli-generator.js
vendored
@ -52,7 +52,7 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
}
|
||||
if (_.has(engines, safe_eng)) {
|
||||
this.errHandler = info.opts.errHandler;
|
||||
engines[safe_eng].call(this, info.mk, info.outputFile, this.onError);
|
||||
engines[safe_eng].call(this, info.mk, info.outputFile, info.opts, this.onError);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
@ -86,11 +86,19 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease wkhtmltopdf rendering
|
||||
*/
|
||||
wkhtmltopdf: function(markup, fOut, on_error) {
|
||||
var tempFile;
|
||||
wkhtmltopdf: function(markup, fOut, opts, on_error) {
|
||||
var tempFile, wkhtmltopdf_args, wkhtmltopdf_options;
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
SPAWN('wkhtmltopdf', [tempFile, fOut], false, on_error, this);
|
||||
wkhtmltopdf_options = _.extend({
|
||||
'margin-bottom': '10mm',
|
||||
'margin-top': '10mm'
|
||||
}, opts.wkhtmltopdf);
|
||||
wkhtmltopdf_options = _.flatten(_.map(wkhtmltopdf_options, function(v, k) {
|
||||
return ['--' + k, v];
|
||||
}));
|
||||
wkhtmltopdf_args = wkhtmltopdf_options.concat([tempFile, fOut]);
|
||||
SPAWN('wkhtmltopdf', wkhtmltopdf_args, false, on_error, this);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -100,7 +108,7 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
phantomjs: function(markup, fOut, on_error) {
|
||||
phantomjs: function(markup, fOut, opts, on_error) {
|
||||
var destPath, scriptPath, sourcePath, tempFile;
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
@ -109,6 +117,19 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
sourcePath = SLASH(PATH.relative(process.cwd(), tempFile));
|
||||
destPath = SLASH(PATH.relative(process.cwd(), fOut));
|
||||
SPAWN('phantomjs', [scriptPath, sourcePath, destPath], false, on_error, this);
|
||||
},
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using WeasyPrint's CLI interface.
|
||||
Spawns a child process with `weasyprint <source> <target>`. Weasy Print
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
*/
|
||||
weasyprint: function(markup, fOut, opts, on_error) {
|
||||
var tempFile;
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
SPAWN('weasyprint', [tempFile, fOut], false, on_error, this);
|
||||
}
|
||||
};
|
||||
|
||||
|
4
dist/helpers/generic-helpers.js
vendored
4
dist/helpers/generic-helpers.js
vendored
@ -589,7 +589,9 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
dateTemp = FluentDate.fmt(dateB);
|
||||
dateTo = dateTemp.format(fmt);
|
||||
}
|
||||
if (dateFrom && dateTo) {
|
||||
if (dateFrom === dateTo) {
|
||||
return dateFrom;
|
||||
} else if (dateFrom && dateTo) {
|
||||
return dateFrom + sep + dateTo;
|
||||
} else if (dateFrom || dateTo) {
|
||||
return dateFrom || dateTo;
|
||||
|
1
dist/verbs/build.js
vendored
1
dist/verbs/build.js
vendored
@ -246,6 +246,7 @@ Implementation of the 'build' verb for HackMyResume.
|
||||
_opts.noTips = opts.noTips;
|
||||
_opts.debug = opts.debug;
|
||||
_opts.sort = opts.sort;
|
||||
_opts.wkhtmltopdf = opts.wkhtmltopdf;
|
||||
that = this;
|
||||
_opts.onTransform = function(info) {
|
||||
that.stat(HMEVENT.afterTransform, info);
|
||||
|
Reference in New Issue
Block a user