1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 08:20:11 +00:00
This commit is contained in:
devlinjd 2015-10-06 12:21:22 -04:00
parent 4fa15f59a0
commit 8a19009e29
4 changed files with 22 additions and 54 deletions

View File

@ -1,10 +1,11 @@
/** /**
Core resume generation module for FluentCMD. Internal resume generation logic for FluentCMD.
@license Copyright (c) 2015 by James M. Devlin. All rights reserved. @license Copyright (c) 2015 | James M. Devlin
*/ */
module.exports = function () { module.exports = function () {
// We don't mind pseudo-globals here
var MD = require( 'marked' ) var MD = require( 'marked' )
, XML = require( 'xml-escape' ) , XML = require( 'xml-escape' )
, HTML = require( 'html' ) , HTML = require( 'html' )
@ -14,20 +15,19 @@ module.exports = function () {
, extend = require( './utils/extend' ) , extend = require( './utils/extend' )
, _ = require('underscore') , _ = require('underscore')
, unused = require('./utils/string') , unused = require('./utils/string')
, FLUENT = require('fluentlib'); , FLUENT = require('fluentlib')
, rez
var rez, _log; , _log;
/** /**
Core resume generation method for HMR. Given a source JSON resume file, a Core workhorse method for FluentCMD. Given a source JSON resume, a destination
destination resume spec, and a theme file, generate 0..N resumes in the resume path, and a theme file, generate 0..N resumes in the desired formats.
requested formats. Requires filesystem access. To perform generation without
filesystem access, use the single() method below.
@param src Path to the source JSON resume file: "rez/resume.json". @param src Path to the source JSON resume file: "rez/resume.json".
@param dst Path to the destination resume file(s): "rez/resume.all". @param dst An array of paths to the destination resume file(s): "rez/resume.all".
@param theme Friendly name of the resume theme. Defaults to "default". @param theme Friendly name of the resume theme. Defaults to "default".
@param logger Optional logging override.
*/ */
function hmr( src, dst, theme, logger ) { function gen( src, dst, theme, logger ) {
_log = logger || console.log; _log = logger || console.log;
_opts.theme = theme; _opts.theme = theme;
@ -57,7 +57,7 @@ module.exports = function () {
}); });
// Run the transformation! // Run the transformation!
var finished = targets.map( gen ); var finished = targets.map( single );
return { return {
sheet: rez,//.rep, sheet: rez,//.rep,
@ -71,7 +71,7 @@ module.exports = function () {
@param f Full path to the destination resume to generate, for example, @param f Full path to the destination resume to generate, for example,
"/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt". "/foo/bar/resume.pdf" or "c:\foo\bar\resume.txt".
*/ */
function gen( f ) { function single( f ) {
try { try {
// Get the output file type (pdf, html, txt, etc) // Get the output file type (pdf, html, txt, etc)
@ -113,48 +113,17 @@ module.exports = function () {
]; ];
/** /**
Default options. Default options. TODO: Some of these are no longer necessary.
*/ */
var _opts = { var _opts = {
prettyPrint: true,
prettyIndent: 2,
keepBreaks: true,
nSym: '&newl;',
rSym: '&retn;',
theme: 'default', theme: 'default',
sheets: [],
filters: {
out: function( txt ) { return txt; },
raw: function( txt ) { return txt; },
xml: function( txt ) { return XML(txt); },
md: function( txt ) { return MD(txt); },
mdin: function( txt ) { return MD(txt).replace(/^\s*\<p\>|\<\/p\>\s*$/gi, ''); },
lower: function( txt ) { return txt.toLowerCase(); }
},
template: {
interpolate: /\{\{(.+?)\}\}/g,
escape: /\{\{\=(.+?)\}\}/g,
evaluate: /\{\%(.+?)\%\}/g,
comment: /\{\#(.+?)\#\}/g
},
pdf: 'wkhtmltopdf'
} }
/** /**
Regexes for linebreak preservation. Module public interface. Used by FCV Desktop.
*/
var _reg = {
regN: new RegExp( '\n', 'g' ),
regR: new RegExp( '\r', 'g' ),
regSymN: new RegExp( _opts.nSym, 'g' ),
regSymR: new RegExp( _opts.rSym, 'g' )
};
/**
Module public interface.
*/ */
return { return {
generate: hmr, generate: gen,
options: _opts, options: _opts,
formats: _fmts formats: _fmts
}; };

View File

@ -1,8 +1,8 @@
#! /usr/bin/env node #! /usr/bin/env node
/** /**
Command-line resume generation logic for FluentCMD. Command-line interface (CLI) for FluentCMD via Node.js.
@license Copyright (c) 2015 by James M. Devlin. All rights reserved. @license Copyright (c) 2015 | James M. Devlin
*/ */
var ARGS = require( 'minimist' ) var ARGS = require( 'minimist' )
@ -16,9 +16,8 @@ try {
var args = ARGS( process.argv.slice(2) ); var args = ARGS( process.argv.slice(2) );
var src = args._.filter( function( a ) { return a.endsWith('.json'); }); var src = args._.filter( function( a ) { return a.endsWith('.json'); });
var dst = args._.filter( function( a ) { return !a.endsWith('.json'); }); var dst = args._.filter( function( a ) { return !a.endsWith('.json'); });
FCMD.generate( src, dst, args.t || 'default' ); FCMD.generate( src, dst, args.t || 'informatic' );
process.platform !== 'win32' && console.log('\n');
console.log('\n');
} }
catch( ex ) { catch( ex ) {

View File

@ -1,6 +1,6 @@
/** /**
Plain JavaScript replacement of jQuery .extend based on jQuery sources. Plain JavaScript replacement of jQuery .extend based on jQuery sources.
@license Copyright (c) 2015 by James M. Devlin. All rights reserved. @license Copyright (c) 2015 | James M. Devlin
*/ */
function _extend() { function _extend() {

View File

@ -1,6 +1,6 @@
/** /**
String utility functions. String utility functions.
@license Copyright (c) 2015 by James M. Devlin. All rights reserved. @license Copyright (c) 2015 | James M. Devlin
*/ */
/** /**