mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-03 04:47:07 +01:00
Merge branch 'master' into dev
This commit is contained in:
@ -37,7 +37,7 @@ module.exports = class HtmlPdfCLIGenerator extends TemplateGenerator
|
||||
safe_eng = 'phantomjs' if safe_eng == 'phantom'
|
||||
if _.has engines, safe_eng
|
||||
@errHandler = info.opts.errHandler
|
||||
engines[ safe_eng ].call @, info.mk, info.outputFile, @onError
|
||||
engines[ safe_eng ].call @, info.mk, info.outputFile, info.opts, @onError
|
||||
return null # halt further processing
|
||||
|
||||
|
||||
@ -64,11 +64,20 @@ engines =
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease wkhtmltopdf rendering
|
||||
###
|
||||
wkhtmltopdf: (markup, fOut, on_error) ->
|
||||
wkhtmltopdf: (markup, fOut, opts, on_error) ->
|
||||
# Save the markup to a temporary file
|
||||
tempFile = fOut.replace /\.pdf$/i, '.pdf.html'
|
||||
FS.writeFileSync tempFile, markup, 'utf8'
|
||||
SPAWN 'wkhtmltopdf', [ tempFile, fOut ], false, on_error, @
|
||||
|
||||
# Prepare wkhtmltopdf arguments.
|
||||
wkhtmltopdf_options = _.extend(
|
||||
{'margin-bottom': '10mm', 'margin-top': '10mm'}, opts.wkhtmltopdf)
|
||||
wkhtmltopdf_options = _.flatten(_.map(wkhtmltopdf_options, (v, k)->
|
||||
return ['--' + k, v]
|
||||
))
|
||||
wkhtmltopdf_args = wkhtmltopdf_options.concat [ tempFile, fOut ]
|
||||
|
||||
SPAWN 'wkhtmltopdf', wkhtmltopdf_args , false, on_error, @
|
||||
return
|
||||
|
||||
|
||||
@ -80,7 +89,7 @@ engines =
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
###
|
||||
phantomjs: ( markup, fOut, on_error ) ->
|
||||
phantomjs: ( markup, fOut, opts, on_error ) ->
|
||||
# Save the markup to a temporary file
|
||||
tempFile = fOut.replace /\.pdf$/i, '.pdf.html'
|
||||
FS.writeFileSync tempFile, markup, 'utf8'
|
||||
@ -90,3 +99,17 @@ engines =
|
||||
destPath = SLASH PATH.relative( process.cwd(), fOut)
|
||||
SPAWN 'phantomjs', [ scriptPath, sourcePath, destPath ], false, on_error, @
|
||||
return
|
||||
|
||||
###*
|
||||
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: ( markup, fOut, opts, on_error ) ->
|
||||
# Save the markup to a temporary file
|
||||
tempFile = fOut.replace /\.pdf$/i, '.pdf.html'
|
||||
FS.writeFileSync tempFile, markup, 'utf8'
|
||||
|
||||
SPAWN 'weasyprint', [tempFile, fOut], false, on_error, @
|
||||
return
|
||||
|
@ -551,7 +551,10 @@ _fromTo = ( dateA, dateB, fmt, sep, fallback ) ->
|
||||
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
|
||||
|
@ -179,6 +179,7 @@ _prep = ( src, dst, opts ) ->
|
||||
_opts.noTips = opts.noTips
|
||||
_opts.debug = opts.debug
|
||||
_opts.sort = opts.sort
|
||||
_opts.wkhtmltopdf = opts.wkhtmltopdf
|
||||
that = @
|
||||
|
||||
# Set up callbacks for internal generators
|
||||
|
Reference in New Issue
Block a user