1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2025-05-02 12:27:08 +01:00

chore: update project dependencies

This commit is contained in:
hacksalot
2018-02-12 00:05:29 -05:00
parent 7144126175
commit c4f7350528
71 changed files with 1600 additions and 1737 deletions

View File

@ -1,11 +1,13 @@
/**
Definition of the HandlebarsGenerator class.
@license MIT. See LICENSE.md for details.
@module renderers/handlebars-generator
*/
(function() {
/**
Definition of the HandlebarsGenerator class.
@license MIT. See LICENSE.md for details.
@module renderers/handlebars-generator
*/
/**
Perform template-based resume generation using Handlebars.js.
@class HandlebarsGenerator
*/
var FS, HANDLEBARS, HMSTATUS, HandlebarsGenerator, PATH, READFILES, SLASH, _, parsePath, registerHelpers, registerPartials;
_ = require('underscore');
@ -26,31 +28,28 @@ Definition of the HandlebarsGenerator class.
SLASH = require('slash');
/**
Perform template-based resume generation using Handlebars.js.
@class HandlebarsGenerator
*/
HandlebarsGenerator = module.exports = {
generateSimple: function(data, tpl) {
var template;
var err, template;
try {
// Compile and run the Handlebars template.
template = HANDLEBARS.compile(tpl, {
strict: false,
assumeObjects: false,
noEscape: data.opts.noescape
});
return template(data);
} catch (_error) {
} catch (error1) {
err = error1;
throw {
fluenterror: HMSTATUS[template ? 'invokeTemplate' : 'compileTemplate'],
inner: _error
inner: err
};
}
},
generate: function(json, jst, format, curFmt, opts, theme) {
var ctx, encData;
// Preprocess text
encData = json;
if (format === 'html' || format === 'pdf') {
encData = json.markdownify();
@ -58,8 +57,10 @@ Definition of the HandlebarsGenerator class.
if (format === 'doc') {
encData = json.xmlify();
}
// Set up partials and helpers
registerPartials(format, theme);
registerHelpers(theme, encData, opts);
// Set up the context
ctx = {
r: encData,
RAW: json,
@ -70,6 +71,7 @@ Definition of the HandlebarsGenerator class.
results: curFmt.files,
headFragment: opts.headFragment || ''
};
// Render the template
return this.generateSimple(ctx, jst);
}
};
@ -77,7 +79,10 @@ Definition of the HandlebarsGenerator class.
registerPartials = function(format, theme) {
var partialsFolder;
if (_.contains(['html', 'doc', 'md', 'txt', 'pdf'], format)) {
// Locate the global partials folder
partialsFolder = PATH.join(parsePath(require.resolve('fresh-themes')).dirname, '/partials/', format === 'pdf' ? 'html' : format);
// Register global partials in the /partials/[format] folder
// TODO: Only do this once per HMR invocation.
_.each(READFILES(partialsFolder, function(error) {
return {};
}), function(el) {
@ -90,6 +95,7 @@ Definition of the HandlebarsGenerator class.
return theme.partialsInitialized = true;
});
}
// Register theme-specific partials
return _.each(theme.partials, function(el) {
var compiledTemplate, tplData;
tplData = FS.readFileSync(el.path, 'utf8');

View File

@ -1,11 +1,13 @@
/**
Definition of the JRSGenerator class.
@license MIT. See LICENSE.md for details.
@module renderers/jrs-generator
*/
(function() {
/**
Definition of the JRSGenerator class.
@license MIT. See LICENSE.md for details.
@module renderers/jrs-generator
*/
/**
Perform template-based resume generation for JSON Resume themes.
@class JRSGenerator
*/
var FS, HANDLEBARS, JRSGenerator, MD, MDIN, PATH, READFILES, SLASH, _, parsePath, registerHelpers;
_ = require('underscore');
@ -26,15 +28,10 @@ Definition of the JRSGenerator class.
MD = require('marked');
/**
Perform template-based resume generation for JSON Resume themes.
@class JRSGenerator
*/
JRSGenerator = module.exports = {
generate: function(json, jst, format, cssInfo, opts, theme) {
var org, rezHtml, turnoff;
// Disable JRS theme chatter (console.log, console.error, etc.)
turnoff = ['log', 'error', 'dir'];
org = turnoff.map(function(c) {
var ret;
@ -42,17 +39,20 @@ Definition of the JRSGenerator class.
console[c] = function() {};
return ret;
});
// Freeze and render
rezHtml = theme.render(json.harden());
// Turn logging back on
turnoff.forEach(function(c, idx) {
return console[c] = org[idx];
});
// Unfreeze and apply Markdown
return rezHtml = rezHtml.replace(/@@@@~[\s\S]*?~@@@@/g, function(val) {
return MDIN(val.replace(/~@@@@/g, '').replace(/@@@@~/g, ''));
});
}
};
MDIN = function(txt) {
MDIN = function(txt) { // TODO: Move this
return MD(txt || '').replace(/^\s*<p>|<\/p>\s*$/gi, '');
};

View File

@ -1,11 +1,13 @@
/**
Definition of the UnderscoreGenerator class.
@license MIT. See LICENSE.md for details.
@module underscore-generator.js
*/
(function() {
/**
Definition of the UnderscoreGenerator class.
@license MIT. See LICENSE.md for details.
@module underscore-generator.js
*/
/**
Perform template-based resume generation using Underscore.js.
@class UnderscoreGenerator
*/
var UnderscoreGenerator, _, escapeLaTeX, registerHelpers;
_ = require('underscore');
@ -16,28 +18,26 @@ Definition of the UnderscoreGenerator class.
escapeLaTeX = require('escape-latex');
/**
Perform template-based resume generation using Underscore.js.
@class UnderscoreGenerator
*/
UnderscoreGenerator = module.exports = {
generateSimple: function(data, tpl) {
var HMS, t;
var HMS, err, t;
try {
// Compile and run the Handlebars template.
t = _.template(tpl);
return t(data);
} catch (_error) {
} catch (error) {
err = error;
//console.dir _error
HMS = require('../core/status-codes');
throw {
fluenterror: HMS[t ? 'invokeTemplate' : 'compileTemplate'],
inner: _error
inner: err
};
}
},
generate: function(json, jst, format, cssInfo, opts, theme) {
var ctx, delims, r, traverse;
// Tweak underscore's default template delimeters
delims = (opts.themeObj && opts.themeObj.delimeters) || opts.template;
if (opts.themeObj && opts.themeObj.delimeters) {
delims = _.mapObject(delims, function(val, key) {
@ -68,16 +68,20 @@ Definition of the UnderscoreGenerator class.
default:
r = json;
}
// Set up the context
ctx = {
r: r,
filt: opts.filters,
XML: require('xml-escape'),
RAW: json,
cssInfo: cssInfo,
//engine: @
headFragment: opts.headFragment || '',
opts: opts
};
// Link to our helpers
registerHelpers(theme, opts, cssInfo, ctx, this);
// Generate!
return this.generateSimple(ctx, jst);
}
};