mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-10 07:47:07 +01:00
chore: update project dependencies
This commit is contained in:
38
dist/generators/base-generator.js
vendored
38
dist/generators/base-generator.js
vendored
@ -1,39 +1,33 @@
|
||||
|
||||
/**
|
||||
Definition of the BaseGenerator class.
|
||||
@module generators/base-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
The BaseGenerator class is the root of the generator hierarchy. Functionality
|
||||
common to ALL generators lives here.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
/**
|
||||
Definition of the BaseGenerator class.
|
||||
@module generators/base-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var BaseGenerator;
|
||||
|
||||
/**
|
||||
The BaseGenerator class is the root of the generator hierarchy. Functionality
|
||||
common to ALL generators lives here.
|
||||
*/
|
||||
module.exports = BaseGenerator = (function() {
|
||||
class BaseGenerator {
|
||||
/** Base-class initialize. */
|
||||
constructor(format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
/** Base-class initialize. */
|
||||
function BaseGenerator(format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/** Status codes. */
|
||||
|
||||
BaseGenerator.prototype.codes = require('../core/status-codes');
|
||||
|
||||
|
||||
/** Generator options. */
|
||||
|
||||
BaseGenerator.prototype.opts = {};
|
||||
|
||||
return BaseGenerator;
|
||||
|
||||
})();
|
||||
}).call(this);
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
36
dist/generators/html-generator.js
vendored
36
dist/generators/html-generator.js
vendored
@ -1,14 +1,10 @@
|
||||
|
||||
/**
|
||||
Definition of the HTMLGenerator class.
|
||||
@module generators/html-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var FS, HTML, HtmlGenerator, PATH, TemplateGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the HTMLGenerator class.
|
||||
@module generators/html-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var FS, HTML, HtmlGenerator, PATH, TemplateGenerator;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
@ -20,20 +16,16 @@ Definition of the HTMLGenerator class.
|
||||
|
||||
require('string.prototype.endswith');
|
||||
|
||||
module.exports = HtmlGenerator = (function(superClass) {
|
||||
extend(HtmlGenerator, superClass);
|
||||
|
||||
function HtmlGenerator() {
|
||||
HtmlGenerator.__super__.constructor.call(this, 'html');
|
||||
module.exports = HtmlGenerator = class HtmlGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('html');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Copy satellite CSS files to the destination and optionally pretty-print
|
||||
the HTML resume prior to saving.
|
||||
*/
|
||||
|
||||
HtmlGenerator.prototype.onBeforeSave = function(info) {
|
||||
*/
|
||||
onBeforeSave(info) {
|
||||
if (info.outputFile.endsWith('.css')) {
|
||||
return info.mk;
|
||||
}
|
||||
@ -42,11 +34,9 @@ Definition of the HTMLGenerator class.
|
||||
} else {
|
||||
return info.mk;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
64
dist/generators/html-pdf-cli-generator.js
vendored
64
dist/generators/html-pdf-cli-generator.js
vendored
@ -1,14 +1,10 @@
|
||||
|
||||
/**
|
||||
Definition of the HtmlPdfCLIGenerator class.
|
||||
@module generators/html-pdf-generator.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var FS, HMSTATUS, HtmlPdfCLIGenerator, PATH, SLASH, SPAWN, TemplateGenerator, _, engines,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the HtmlPdfCLIGenerator class.
|
||||
@module generators/html-pdf-generator.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var FS, HMSTATUS, HtmlPdfCLIGenerator, PATH, SLASH, SPAWN, TemplateGenerator, _, engines;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
@ -24,26 +20,21 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
|
||||
SPAWN = require('../utils/safe-spawn');
|
||||
|
||||
|
||||
/**
|
||||
An HTML-driven PDF resume generator for HackMyResume. Talks to Phantom,
|
||||
wkhtmltopdf, and other PDF engines over a CLI (command-line interface).
|
||||
If an engine isn't installed for a particular platform, error out gracefully.
|
||||
*/
|
||||
|
||||
module.exports = HtmlPdfCLIGenerator = (function(superClass) {
|
||||
extend(HtmlPdfCLIGenerator, superClass);
|
||||
|
||||
function HtmlPdfCLIGenerator() {
|
||||
HtmlPdfCLIGenerator.__super__.constructor.call(this, 'pdf', 'html');
|
||||
*/
|
||||
module.exports = HtmlPdfCLIGenerator = class HtmlPdfCLIGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('pdf', 'html');
|
||||
}
|
||||
|
||||
|
||||
/** Generate the binary PDF. */
|
||||
|
||||
HtmlPdfCLIGenerator.prototype.onBeforeSave = function(info) {
|
||||
onBeforeSave(info) {
|
||||
var safe_eng;
|
||||
if (info.ext !== 'html' && info.ext !== 'pdf') {
|
||||
//console.dir _.omit( info, 'mk' ), depth: null, colors: true
|
||||
return info.mk;
|
||||
}
|
||||
safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
||||
@ -53,43 +44,40 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
if (_.has(engines, safe_eng)) {
|
||||
this.errHandler = info.opts.errHandler;
|
||||
engines[safe_eng].call(this, info.mk, info.outputFile, info.opts, this.onError);
|
||||
return null;
|
||||
return null; // halt further processing
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/* Low-level error callback for spawn(). May be called after HMR process
|
||||
termination, so object references may not be valid here. That's okay; if
|
||||
the references are invalid, the error was already logged. We could use
|
||||
spawn-watch here but that causes issues on legacy Node.js.
|
||||
*/
|
||||
|
||||
HtmlPdfCLIGenerator.prototype.onError = function(ex, param) {
|
||||
spawn-watch here but that causes issues on legacy Node.js. */
|
||||
onError(ex, param) {
|
||||
var ref;
|
||||
if ((ref = param.errHandler) != null) {
|
||||
if (typeof ref.err === "function") {
|
||||
ref.err(HMSTATUS.pdfGeneration, ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlPdfCLIGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
// TODO: Move each engine to a separate module
|
||||
engines = {
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using wkhtmltopdf's CLI interface.
|
||||
Spawns a child process with `wkhtmltopdf <source> <target>`. wkhtmltopdf
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease wkhtmltopdf rendering
|
||||
*/
|
||||
*/
|
||||
wkhtmltopdf: function(markup, fOut, opts, on_error) {
|
||||
var tempFile, wkargs, wkopts;
|
||||
// Save the markup to a temporary file
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
// Prepare wkhtmltopdf arguments.
|
||||
wkopts = _.extend({
|
||||
'margin-top': '10mm',
|
||||
'margin-bottom': '10mm'
|
||||
@ -100,16 +88,16 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
wkargs = wkopts.concat([tempFile, fOut]);
|
||||
SPAWN('wkhtmltopdf', wkargs, false, on_error, this);
|
||||
},
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using Phantom's CLI interface.
|
||||
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
*/
|
||||
phantomjs: function(markup, fOut, opts, on_error) {
|
||||
var destPath, scriptPath, sourcePath, tempFile;
|
||||
// Save the markup to a temporary file
|
||||
tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
scriptPath = PATH.relative(process.cwd(), PATH.resolve(__dirname, '../utils/rasterize.js'));
|
||||
@ -118,15 +106,15 @@ Definition of the HtmlPdfCLIGenerator class.
|
||||
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;
|
||||
// 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, this);
|
||||
|
56
dist/generators/html-png-generator.js
vendored
56
dist/generators/html-png-generator.js
vendored
@ -1,14 +1,17 @@
|
||||
|
||||
/**
|
||||
Definition of the HtmlPngGenerator class.
|
||||
@module generators/html-png-generator
|
||||
@license MIT. See LICENSE.MD for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var FS, HTML, HtmlPngGenerator, PATH, SLASH, SPAWN, TemplateGenerator, phantom,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the HtmlPngGenerator class.
|
||||
@module generators/html-png-generator
|
||||
@license MIT. See LICENSE.MD for details.
|
||||
*/
|
||||
/**
|
||||
Generate a PDF from HTML using Phantom's CLI interface.
|
||||
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
var FS, HTML, HtmlPngGenerator, PATH, SLASH, SPAWN, TemplateGenerator, phantom;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
@ -22,21 +25,18 @@ Definition of the HtmlPngGenerator class.
|
||||
|
||||
PATH = require('path');
|
||||
|
||||
|
||||
/**
|
||||
An HTML-based PNG resume generator for HackMyResume.
|
||||
*/
|
||||
|
||||
module.exports = HtmlPngGenerator = (function(superClass) {
|
||||
extend(HtmlPngGenerator, superClass);
|
||||
|
||||
function HtmlPngGenerator() {
|
||||
HtmlPngGenerator.__super__.constructor.call(this, 'png', 'html');
|
||||
*/
|
||||
module.exports = HtmlPngGenerator = class HtmlPngGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('png', 'html');
|
||||
}
|
||||
|
||||
HtmlPngGenerator.prototype.invoke = function(rez, themeMarkup, cssInfo, opts) {};
|
||||
invoke(rez, themeMarkup, cssInfo, opts) {}
|
||||
|
||||
HtmlPngGenerator.prototype.generate = function(rez, f, opts) {
|
||||
// TODO: Not currently called or callable.
|
||||
generate(rez, f, opts) {
|
||||
var htmlFile, htmlResults;
|
||||
htmlResults = opts.targets.filter(function(t) {
|
||||
return t.fmt.outFormat === 'html';
|
||||
@ -45,23 +45,13 @@ Definition of the HtmlPngGenerator class.
|
||||
return fl.info.ext === 'html';
|
||||
});
|
||||
phantom(htmlFile[0].data, f);
|
||||
};
|
||||
}
|
||||
|
||||
return HtmlPngGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
|
||||
|
||||
/**
|
||||
Generate a PDF from HTML using Phantom's CLI interface.
|
||||
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||
must be installed and path-accessible.
|
||||
TODO: If HTML generation has run, reuse that output
|
||||
TODO: Local web server to ease Phantom rendering
|
||||
*/
|
||||
};
|
||||
|
||||
phantom = function(markup, fOut) {
|
||||
var destPath, info, scriptPath, sourcePath, tempFile;
|
||||
// Save the markup to a temporary file
|
||||
tempFile = fOut.replace(/\.png$/i, '.png.html');
|
||||
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||
scriptPath = SLASH(PATH.relative(process.cwd(), PATH.resolve(__dirname, '../utils/rasterize.js')));
|
||||
|
39
dist/generators/json-generator.js
vendored
39
dist/generators/json-generator.js
vendored
@ -1,14 +1,10 @@
|
||||
|
||||
/**
|
||||
Definition of the JsonGenerator class.
|
||||
@module generators/json-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var BaseGenerator, FJCV, FS, JsonGenerator, _,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the JsonGenerator class.
|
||||
@module generators/json-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var BaseGenerator, FJCV, FS, JsonGenerator, _;
|
||||
|
||||
BaseGenerator = require('./base-generator');
|
||||
|
||||
@ -18,29 +14,24 @@ Definition of the JsonGenerator class.
|
||||
|
||||
FJCV = require('fresh-jrs-converter');
|
||||
|
||||
|
||||
/** The JsonGenerator generates a FRESH or JRS resume as an output. */
|
||||
|
||||
module.exports = JsonGenerator = (function(superClass) {
|
||||
extend(JsonGenerator, superClass);
|
||||
|
||||
function JsonGenerator() {
|
||||
JsonGenerator.__super__.constructor.call(this, 'json');
|
||||
module.exports = JsonGenerator = class JsonGenerator extends BaseGenerator {
|
||||
constructor() {
|
||||
super('json');
|
||||
}
|
||||
|
||||
JsonGenerator.prototype.invoke = function(rez) {
|
||||
invoke(rez) {
|
||||
var altRez;
|
||||
altRez = FJCV['to' + (rez.format() === 'FRESH' ? 'JRS' : 'FRESH')](rez);
|
||||
return altRez = FJCV.toSTRING(altRez);
|
||||
};
|
||||
}
|
||||
|
||||
JsonGenerator.prototype.generate = function(rez, f) {
|
||||
//altRez.stringify()
|
||||
generate(rez, f) {
|
||||
FS.writeFileSync(f, this.invoke(rez), 'utf8');
|
||||
};
|
||||
}
|
||||
|
||||
return JsonGenerator;
|
||||
|
||||
})(BaseGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
44
dist/generators/json-yaml-generator.js
vendored
44
dist/generators/json-yaml-generator.js
vendored
@ -1,14 +1,10 @@
|
||||
|
||||
/**
|
||||
Definition of the JsonYamlGenerator class.
|
||||
@module generators/json-yaml-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var BaseGenerator, FS, JsonYamlGenerator, YAML,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the JsonYamlGenerator class.
|
||||
@module generators/json-yaml-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var BaseGenerator, FS, JsonYamlGenerator, YAML;
|
||||
|
||||
BaseGenerator = require('./base-generator');
|
||||
|
||||
@ -16,34 +12,28 @@ Definition of the JsonYamlGenerator class.
|
||||
|
||||
YAML = require('yamljs');
|
||||
|
||||
|
||||
/**
|
||||
JsonYamlGenerator takes a JSON resume object and translates it directly to
|
||||
JSON without a template, producing an equivalent YAML-formatted resume. See
|
||||
also YamlGenerator (yaml-generator.js).
|
||||
*/
|
||||
|
||||
module.exports = JsonYamlGenerator = (function(superClass) {
|
||||
extend(JsonYamlGenerator, superClass);
|
||||
|
||||
function JsonYamlGenerator() {
|
||||
JsonYamlGenerator.__super__.constructor.call(this, 'yml');
|
||||
*/
|
||||
module.exports = JsonYamlGenerator = class JsonYamlGenerator extends BaseGenerator {
|
||||
constructor() {
|
||||
super('yml');
|
||||
}
|
||||
|
||||
JsonYamlGenerator.prototype.invoke = function(rez, themeMarkup, cssInfo, opts) {
|
||||
return YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
|
||||
};
|
||||
invoke(rez, themeMarkup, cssInfo, opts) {
|
||||
return YAML.stringify(JSON.parse(rez.stringify()), 2e308, 2);
|
||||
}
|
||||
|
||||
JsonYamlGenerator.prototype.generate = function(rez, f, opts) {
|
||||
generate(rez, f, opts) {
|
||||
var data;
|
||||
data = YAML.stringify(JSON.parse(rez.stringify()), Infinity, 2);
|
||||
data = YAML.stringify(JSON.parse(rez.stringify()), 2e308, 2);
|
||||
FS.writeFileSync(f, data, 'utf8');
|
||||
return data;
|
||||
};
|
||||
}
|
||||
|
||||
return JsonYamlGenerator;
|
||||
|
||||
})(BaseGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
32
dist/generators/latex-generator.js
vendored
32
dist/generators/latex-generator.js
vendored
@ -1,32 +1,22 @@
|
||||
|
||||
/**
|
||||
Definition of the LaTeXGenerator class.
|
||||
@module generators/latex-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var LaTeXGenerator, TemplateGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the LaTeXGenerator class.
|
||||
@module generators/latex-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var LaTeXGenerator, TemplateGenerator;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
|
||||
/**
|
||||
LaTeXGenerator generates a LaTeX resume via TemplateGenerator.
|
||||
*/
|
||||
|
||||
module.exports = LaTeXGenerator = (function(superClass) {
|
||||
extend(LaTeXGenerator, superClass);
|
||||
|
||||
function LaTeXGenerator() {
|
||||
LaTeXGenerator.__super__.constructor.call(this, 'latex', 'tex');
|
||||
*/
|
||||
module.exports = LaTeXGenerator = class LaTeXGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('latex', 'tex');
|
||||
}
|
||||
|
||||
return LaTeXGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
32
dist/generators/markdown-generator.js
vendored
32
dist/generators/markdown-generator.js
vendored
@ -1,32 +1,22 @@
|
||||
|
||||
/**
|
||||
Definition of the MarkdownGenerator class.
|
||||
@module generators/markdown-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var MarkdownGenerator, TemplateGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the MarkdownGenerator class.
|
||||
@module generators/markdown-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var MarkdownGenerator, TemplateGenerator;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
|
||||
/**
|
||||
MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator.
|
||||
*/
|
||||
|
||||
module.exports = MarkdownGenerator = (function(superClass) {
|
||||
extend(MarkdownGenerator, superClass);
|
||||
|
||||
function MarkdownGenerator() {
|
||||
MarkdownGenerator.__super__.constructor.call(this, 'md', 'txt');
|
||||
*/
|
||||
module.exports = MarkdownGenerator = class MarkdownGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('md', 'txt');
|
||||
}
|
||||
|
||||
return MarkdownGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
116
dist/generators/template-generator.js
vendored
116
dist/generators/template-generator.js
vendored
@ -1,14 +1,13 @@
|
||||
|
||||
/**
|
||||
Definition of the TemplateGenerator class. TODO: Refactor
|
||||
@module generators/template-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var BaseGenerator, EXTEND, FRESHTheme, FS, JRSTheme, MD, MKDIRP, PATH, TemplateGenerator, XML, _, _defaultOpts, _reg, createSymLinks, freeze, parsePath, unfreeze,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the TemplateGenerator class. TODO: Refactor
|
||||
@module generators/template-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
/** Default template generator options. */
|
||||
/** Freeze newlines for protection against errant JST parsers. */
|
||||
/** Unfreeze newlines when the coast is clear. */
|
||||
var BaseGenerator, EXTEND, FRESHTheme, FS, JRSTheme, MD, MKDIRP, PATH, TemplateGenerator, XML, _, _defaultOpts, _reg, createSymLinks, freeze, parsePath, unfreeze;
|
||||
|
||||
FS = require('fs-extra');
|
||||
|
||||
@ -32,46 +31,38 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
|
||||
JRSTheme = require('../core/jrs-theme');
|
||||
|
||||
|
||||
/**
|
||||
TemplateGenerator performs resume generation via local Handlebar or Underscore
|
||||
style template expansion and is appropriate for text-based formats like HTML,
|
||||
plain text, and XML versions of Microsoft Word, Excel, and OpenOffice.
|
||||
@class TemplateGenerator
|
||||
*/
|
||||
|
||||
module.exports = TemplateGenerator = (function(superClass) {
|
||||
extend(TemplateGenerator, superClass);
|
||||
|
||||
|
||||
*/
|
||||
module.exports = TemplateGenerator = class TemplateGenerator extends BaseGenerator {
|
||||
/** Constructor. Set the output format and template format for this
|
||||
generator. Will usually be called by a derived generator such as
|
||||
HTMLGenerator or MarkdownGenerator.
|
||||
*/
|
||||
|
||||
function TemplateGenerator(outputFormat, templateFormat, cssFile) {
|
||||
TemplateGenerator.__super__.constructor.call(this, outputFormat);
|
||||
HTMLGenerator or MarkdownGenerator. */
|
||||
constructor(outputFormat, templateFormat, cssFile) {
|
||||
super(outputFormat);
|
||||
this.tplFormat = templateFormat || outputFormat;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/** Generate a resume using string-based inputs and outputs without touching
|
||||
the filesystem.
|
||||
@method invoke
|
||||
@param rez A FreshResume object.
|
||||
@param opts Generator options.
|
||||
@returns {Array} An array of objects representing the generated output
|
||||
files.
|
||||
*/
|
||||
|
||||
TemplateGenerator.prototype.invoke = function(rez, opts) {
|
||||
files. */
|
||||
invoke(rez, opts) {
|
||||
var curFmt, results;
|
||||
opts = opts ? (this.opts = EXTEND(true, {}, _defaultOpts, opts)) : this.opts;
|
||||
// Sort such that CSS files are processed before others
|
||||
curFmt = opts.themeObj.getFormat(this.format);
|
||||
curFmt.files = _.sortBy(curFmt.files, function(fi) {
|
||||
return fi.ext !== 'css';
|
||||
});
|
||||
// Run the transformation!
|
||||
results = curFmt.files.map(function(tplInfo, idx) {
|
||||
var trx;
|
||||
if (tplInfo.action === 'transform') {
|
||||
@ -95,25 +86,30 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
return {
|
||||
files: results
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/** Generate a resume using file-based inputs and outputs. Requires access
|
||||
to the local filesystem.
|
||||
@method generate
|
||||
@param rez A FreshResume object.
|
||||
@param f Full path to the output resume file to generate.
|
||||
@param opts Generator options.
|
||||
*/
|
||||
|
||||
TemplateGenerator.prototype.generate = function(rez, f, opts) {
|
||||
@param opts Generator options. */
|
||||
generate(rez, f, opts) {
|
||||
var curFmt, genInfo, outFolder;
|
||||
// Prepare
|
||||
this.opts = EXTEND(true, {}, _defaultOpts, opts);
|
||||
// Call the string-based generation method
|
||||
genInfo = this.invoke(rez, null);
|
||||
outFolder = parsePath(f).dirname;
|
||||
curFmt = opts.themeObj.getFormat(this.format);
|
||||
// Process individual files within this format. For example, the HTML
|
||||
// output format for a theme may have multiple HTML files, CSS files,
|
||||
// etc. Process them here.
|
||||
genInfo.files.forEach(function(file) {
|
||||
var thisFilePath;
|
||||
// console.dir _.omit(file.info,'cssData','data','css' )
|
||||
|
||||
// Pre-processing
|
||||
file.info.orgPath = file.info.orgPath || '';
|
||||
thisFilePath = file.info.primary ? f : PATH.join(outFolder, file.info.orgPath);
|
||||
if (file.info.action !== 'copy' && this.onBeforeSave) {
|
||||
@ -129,7 +125,9 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
}
|
||||
}
|
||||
if (typeof opts.beforeWrite === "function") {
|
||||
opts.beforeWrite(thisFilePath);
|
||||
opts.beforeWrite({
|
||||
data: thisFilePath
|
||||
});
|
||||
}
|
||||
MKDIRP.sync(PATH.dirname(thisFilePath));
|
||||
if (file.info.action !== 'copy') {
|
||||
@ -141,8 +139,11 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
FS.copySync(file.info.path, thisFilePath);
|
||||
}
|
||||
if (typeof opts.afterWrite === "function") {
|
||||
opts.afterWrite(thisFilePath);
|
||||
opts.afterWrite({
|
||||
data: thisFilePath
|
||||
});
|
||||
}
|
||||
// Post-processing
|
||||
if (this.onAfterSave) {
|
||||
return this.onAfterSave({
|
||||
outputFile: fileName,
|
||||
@ -151,10 +152,10 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
});
|
||||
}
|
||||
}, this);
|
||||
// Some themes require a symlink structure. If so, create it.
|
||||
createSymLinks(curFmt, outFolder);
|
||||
return genInfo;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/** Perform a single resume resume transformation using string-based inputs
|
||||
and outputs without touching the local file system.
|
||||
@ -162,10 +163,8 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
@param jst The stringified template data
|
||||
@param format The format name, such as "html" or "latex"
|
||||
@param cssInfo Needs to be refactored.
|
||||
@param opts Options and passthrough data.
|
||||
*/
|
||||
|
||||
TemplateGenerator.prototype.transform = function(json, jst, format, opts, theme, curFmt) {
|
||||
@param opts Options and passthrough data. */
|
||||
transform(json, jst, format, opts, theme, curFmt) {
|
||||
var eng, result;
|
||||
if (this.opts.freezeBreaks) {
|
||||
jst = freeze(jst);
|
||||
@ -176,29 +175,30 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
result = unfreeze(result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
return TemplateGenerator;
|
||||
|
||||
})(BaseGenerator);
|
||||
};
|
||||
|
||||
createSymLinks = function(curFmt, outFolder) {
|
||||
// Some themes require a symlink structure. If so, create it.
|
||||
if (curFmt.symLinks) {
|
||||
Object.keys(curFmt.symLinks).forEach(function(loc) {
|
||||
var absLoc, absTarg, succeeded, type;
|
||||
var absLoc, absTarg, err, succeeded, type;
|
||||
absLoc = PATH.join(outFolder, loc);
|
||||
absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
|
||||
// Set type to 'file', 'dir', or 'junction' (Windows only)
|
||||
type = parsePath(absLoc).extname ? 'file' : 'junction';
|
||||
try {
|
||||
return FS.symlinkSync(absTarg, absLoc, type);
|
||||
} catch (_error) {
|
||||
} catch (error) {
|
||||
err = error;
|
||||
succeeded = false;
|
||||
if (_error.code === 'EEXIST') {
|
||||
if (err.code === 'EEXIST') {
|
||||
FS.unlinkSync(absLoc);
|
||||
try {
|
||||
FS.symlinkSync(absTarg, absLoc, type);
|
||||
succeeded = true;
|
||||
} catch (_error) {}
|
||||
} catch (error) {}
|
||||
}
|
||||
if (!succeeded) {
|
||||
throw ex;
|
||||
@ -208,31 +208,22 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/** Freeze newlines for protection against errant JST parsers. */
|
||||
|
||||
freeze = function(markup) {
|
||||
markup.replace(_reg.regN, _defaultOpts.nSym);
|
||||
return markup.replace(_reg.regR, _defaultOpts.rSym);
|
||||
};
|
||||
|
||||
|
||||
/** Unfreeze newlines when the coast is clear. */
|
||||
|
||||
unfreeze = function(markup) {
|
||||
markup.replace(_reg.regSymR, '\r');
|
||||
return markup.replace(_reg.regSymN, '\n');
|
||||
};
|
||||
|
||||
|
||||
/** Default template generator options. */
|
||||
|
||||
_defaultOpts = {
|
||||
engine: 'underscore',
|
||||
keepBreaks: true,
|
||||
freezeBreaks: false,
|
||||
nSym: '&newl;',
|
||||
rSym: '&retn;',
|
||||
nSym: '&newl;', // newline entity
|
||||
rSym: '&retn;', // return entity
|
||||
template: {
|
||||
interpolate: /\{\{(.+?)\}\}/g,
|
||||
escape: /\{\{\=(.+?)\}\}/g,
|
||||
@ -269,13 +260,12 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
prettify: {
|
||||
indent_size: 2,
|
||||
unformatted: ['em', 'strong', 'a'],
|
||||
max_char: 80
|
||||
max_char: 80 // ← See lib/html.js in above-linked repo
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//wrap_line_length: 120, <-- Don't use this
|
||||
/** Regexes for linebreak preservation. */
|
||||
|
||||
_reg = {
|
||||
regN: new RegExp('\n', 'g'),
|
||||
regR: new RegExp('\r', 'g'),
|
||||
|
32
dist/generators/text-generator.js
vendored
32
dist/generators/text-generator.js
vendored
@ -1,32 +1,22 @@
|
||||
|
||||
/**
|
||||
Definition of the TextGenerator class.
|
||||
@module generators/text-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var TemplateGenerator, TextGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the TextGenerator class.
|
||||
@module generators/text-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var TemplateGenerator, TextGenerator;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
|
||||
/**
|
||||
The TextGenerator generates a plain-text resume via the TemplateGenerator.
|
||||
*/
|
||||
|
||||
module.exports = TextGenerator = (function(superClass) {
|
||||
extend(TextGenerator, superClass);
|
||||
|
||||
function TextGenerator() {
|
||||
TextGenerator.__super__.constructor.call(this, 'txt');
|
||||
*/
|
||||
module.exports = TextGenerator = class TextGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('txt');
|
||||
}
|
||||
|
||||
return TextGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
28
dist/generators/word-generator.js
vendored
28
dist/generators/word-generator.js
vendored
@ -1,27 +1,19 @@
|
||||
|
||||
/*
|
||||
Definition of the WordGenerator class.
|
||||
@module generators/word-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var TemplateGenerator, WordGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/*
|
||||
Definition of the WordGenerator class.
|
||||
@module generators/word-generator
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var TemplateGenerator, WordGenerator;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
module.exports = WordGenerator = (function(superClass) {
|
||||
extend(WordGenerator, superClass);
|
||||
|
||||
function WordGenerator() {
|
||||
WordGenerator.__super__.constructor.call(this, 'doc', 'xml');
|
||||
module.exports = WordGenerator = class WordGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('doc', 'xml');
|
||||
}
|
||||
|
||||
return WordGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
30
dist/generators/xml-generator.js
vendored
30
dist/generators/xml-generator.js
vendored
@ -1,30 +1,20 @@
|
||||
|
||||
/**
|
||||
Definition of the XMLGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module generatprs/xml-generator
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var BaseGenerator, XMLGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the XMLGenerator class.
|
||||
@license MIT. See LICENSE.md for details.
|
||||
@module generatprs/xml-generator
|
||||
*/
|
||||
var BaseGenerator, XMLGenerator;
|
||||
|
||||
BaseGenerator = require('./base-generator');
|
||||
|
||||
|
||||
/** The XmlGenerator generates an XML resume via the TemplateGenerator. */
|
||||
|
||||
module.exports = XMLGenerator = (function(superClass) {
|
||||
extend(XMLGenerator, superClass);
|
||||
|
||||
function XMLGenerator() {
|
||||
XMLGenerator.__super__.constructor.call(this, 'xml');
|
||||
module.exports = XMLGenerator = class XMLGenerator extends BaseGenerator {
|
||||
constructor() {
|
||||
super('xml');
|
||||
}
|
||||
|
||||
return XMLGenerator;
|
||||
|
||||
})(BaseGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
32
dist/generators/yaml-generator.js
vendored
32
dist/generators/yaml-generator.js
vendored
@ -1,32 +1,22 @@
|
||||
|
||||
/**
|
||||
Definition of the YAMLGenerator class.
|
||||
@module yaml-generator.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var TemplateGenerator, YAMLGenerator,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
hasProp = {}.hasOwnProperty;
|
||||
/**
|
||||
Definition of the YAMLGenerator class.
|
||||
@module yaml-generator.js
|
||||
@license MIT. See LICENSE.md for details.
|
||||
*/
|
||||
var TemplateGenerator, YAMLGenerator;
|
||||
|
||||
TemplateGenerator = require('./template-generator');
|
||||
|
||||
|
||||
/**
|
||||
YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
|
||||
*/
|
||||
|
||||
module.exports = YAMLGenerator = (function(superClass) {
|
||||
extend(YAMLGenerator, superClass);
|
||||
|
||||
function YAMLGenerator() {
|
||||
YAMLGenerator.__super__.constructor.call(this, 'yml', 'yml');
|
||||
*/
|
||||
module.exports = YAMLGenerator = class YAMLGenerator extends TemplateGenerator {
|
||||
constructor() {
|
||||
super('yml', 'yml');
|
||||
}
|
||||
|
||||
return YAMLGenerator;
|
||||
|
||||
})(TemplateGenerator);
|
||||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
Reference in New Issue
Block a user