1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-07 18:20:05 +01:00
HackMyResume/src/generators/html-png-generator.js

67 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-12-28 19:29:13 +00:00
/**
Definition of the HtmlPngGenerator class.
2015-12-30 23:52:41 +00:00
@license MIT. See LICENSE.MD for details.
2015-12-28 19:29:13 +00:00
@module html-png-generator.js
*/
2015-12-28 19:29:13 +00:00
(function() {
2015-12-28 19:29:13 +00:00
var TemplateGenerator = require('./template-generator')
, FS = require('fs-extra')
, HTML = require( 'html' );
2015-12-28 19:29:13 +00:00
/**
2015-12-30 23:52:41 +00:00
An HTML-based PNG resume generator for HackMyResume.
2015-12-28 19:29:13 +00:00
*/
var HtmlPngGenerator = module.exports = TemplateGenerator.extend({
2015-12-28 19:29:13 +00:00
init: function() {
this._super( 'png', 'html' );
},
2015-12-30 23:52:41 +00:00
invoke: function( rez, themeMarkup, cssInfo, opts ) {
// TODO: Not currently called or callable.
2015-12-30 23:52:41 +00:00
},
2015-12-30 23:52:41 +00:00
generate: function( rez, f, opts ) {
var htmlResults = opts.targets.filter(function(t){
return t.fmt.outFormat === 'html';
});
var htmlFile = htmlResults[0].final.files.filter(function(fl){
return fl.info.ext === 'html';
});
png( htmlFile[0].data, f );
2015-12-28 19:29:13 +00:00
}
2015-12-28 19:29:13 +00:00
});
2015-12-28 19:29:13 +00:00
/**
2015-12-30 23:52:41 +00:00
Generate a PNG from HTML.
2015-12-28 19:29:13 +00:00
*/
function png( markup, fOut ) {
// TODO: Which Webshot syntax?
2015-12-30 23:52:41 +00:00
// require('webshot')( markup , { encoding: 'binary', siteType: 'html' } )
// .pipe( FS.createWriteStream( fOut ) );
require('webshot')( markup , fOut, { siteType: 'html' }, function(err) { } );
2015-12-28 19:29:13 +00:00
}
2015-12-28 19:29:13 +00:00
}());