From 44555da00f8eb33cfa7e3a6f6a1878521cc2cc29 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Fri, 8 Jan 2016 09:36:32 -0500 Subject: [PATCH] Fix PNG output format for JSON Resume themes. --- src/core/jrs-theme.js | 4 ++-- src/gen/html-png-generator.js | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/core/jrs-theme.js b/src/core/jrs-theme.js index ea67890..fd75bc1 100644 --- a/src/core/jrs-theme.js +++ b/src/core/jrs-theme.js @@ -57,7 +57,7 @@ Definition of the JRSTheme class. action: 'transform', render: this.render, major: true, - ext: pathInfo.extname.slice(1), + ext: 'html', css: null } ]}, @@ -66,7 +66,7 @@ Definition of the JRSTheme class. action: 'transform', render: this.render, major: true, - ext: pathInfo.extname.slice(1), + ext: 'pdf', css: null } ]} diff --git a/src/gen/html-png-generator.js b/src/gen/html-png-generator.js index 2ec793e..692a382 100644 --- a/src/gen/html-png-generator.js +++ b/src/gen/html-png-generator.js @@ -4,25 +4,37 @@ Definition of the HtmlPngGenerator class. @module html-png-generator.js */ + + (function() { + + var TemplateGenerator = require('./template-generator') , FS = require('fs-extra') , HTML = require( 'html' ); + + /** An HTML-based PNG resume generator for HackMyResume. */ var HtmlPngGenerator = module.exports = TemplateGenerator.extend({ + + init: function() { this._super( 'png', 'html' ); }, + + invoke: function( rez, themeMarkup, cssInfo, opts ) { - //return YAML.stringify( JSON.parse( rez.stringify() ), Infinity, 2 ); + // TODO: Not currently called or callable. }, + + generate: function( rez, f, opts ) { var htmlResults = opts.targets.filter(function(t){ return t.fmt.outFormat === 'html'; @@ -30,18 +42,25 @@ Definition of the HtmlPngGenerator class. var htmlFile = htmlResults[0].final.files.filter(function(fl){ return fl.info.ext === 'html'; }); - png(htmlFile[0].data, f); + png( htmlFile[0].data, f ); } + + }); + + /** Generate a PNG from HTML. */ function png( markup, fOut ) { + // TODO: Which Webshot syntax? // require('webshot')( markup , { encoding: 'binary', siteType: 'html' } ) // .pipe( FS.createWriteStream( fOut ) ); require('webshot')( markup , fOut, { siteType: 'html' }, function(err) { } ); } + + }());