1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-07 18:20:05 +01:00

Merge pull request #29 from hacksalot/final/v1.1.0

final/v1.1.0
This commit is contained in:
hacksalot 2015-12-20 20:46:19 -05:00
commit 7c0354046c
4 changed files with 60 additions and 32 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "hackmyresume", "name": "hackmyresume",
"version": "1.0.1", "version": "1.1.0",
"description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.", "description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -13,19 +13,23 @@ Generic template helper definitions for FluentCV.
, _ = require('underscore'); , _ = require('underscore');
/** /**
Register useful Handlebars helpers. Generic template helper function definitions.
@method registerHelpers @class GenericHelpers
*/ */
module.exports = { var GenericHelpers = module.exports = {
// Set up a date formatting helper so we can do: /**
// {{formatDate val 'YYYY-MM'}} Convert the input date to a specified format through Moment.js.
@method formatDate
*/
formatDate: function(datetime, format) { formatDate: function(datetime, format) {
return moment ? moment( datetime ).format( format ) : datetime; return moment ? moment( datetime ).format( format ) : datetime;
}, },
// Set up a Markdown-to-WordProcessingML helper so we can do: /**
// {{wmpl val [true|false]}} Convert inline Markdown to inline WordProcessingML.
@method wpml
*/
wpml: function( txt, inline ) { wpml: function( txt, inline ) {
if(!txt) return ''; if(!txt) return '';
inline = (inline && !inline.hash) || false; inline = (inline && !inline.hash) || false;
@ -36,24 +40,31 @@ Generic template helper definitions for FluentCV.
return txt; return txt;
}, },
// Set up a last-word helper so we can do: /**
// {{lastWord val [true|false]}} Emit a conditional link.
@method link
*/
link: function( text, url ) { link: function( text, url ) {
return url && url.trim() ? return url && url.trim() ?
('<a href="' + url + '">' + text + '</a>') : text; ('<a href="' + url + '">' + text + '</a>') : text;
}, },
// Set up a last-word helper so we can do: /**
// {{lastWord val [true|false]}} Return the last word of the specified text.
@method lastWord
*/
lastWord: function( txt ) { lastWord: function( txt ) {
return txt && txt.trim() ? _.last( txt.split(' ') ) : ''; return txt && txt.trim() ? _.last( txt.split(' ') ) : '';
}, },
// Set up a skill colorizing helper: /**
// {{skillColor val}} Convert a skill level to an RGB color triplet.
// Skill level can be expressed as a string ("beginner", "intermediate", @method skillColor
// etc.), as an integer (1,5,etc), as a string integer ("1", "5", etc.), @param lvl Input skill level. Skill level can be expressed as a string
// or as an RRGGBB color triplet ('#C00000', '#FFFFAA'). ("beginner", "intermediate", etc.), as an integer (1,5,etc), as a string
integer ("1", "5", etc.), or as an RRGGBB color triplet ('#C00000',
'#FFFFAA').
*/
skillColor: function( lvl ) { skillColor: function( lvl ) {
var idx = skillLevelToIndex( lvl ); var idx = skillLevelToIndex( lvl );
var skillColors = (this.theme && this.theme.palette && var skillColors = (this.theme && this.theme.palette &&
@ -62,40 +73,52 @@ Generic template helper definitions for FluentCV.
return skillColors[idx]; return skillColors[idx];
}, },
// Set up a skill colorizing helper: /**
// {{skillColor val}} Return an appropriate height.
@method lastWord
*/
skillHeight: function( lvl ) { skillHeight: function( lvl ) {
var idx = skillLevelToIndex( lvl ); var idx = skillLevelToIndex( lvl );
return ['38.25', '30', '16', '8', '0'][idx]; return ['38.25', '30', '16', '8', '0'][idx];
}, },
// Set up a Markdown-to-WordProcessingML helper so we can do: /**
// {{initialWords val [true|false]}} Return all but the last word of the input text.
@method initialWords
*/
initialWords: function( txt ) { initialWords: function( txt ) {
return txt && txt.trim() ? _.initial( txt.split(' ') ).join(' ') : ''; return txt && txt.trim() ? _.initial( txt.split(' ') ).join(' ') : '';
}, },
// Set up a URL-trimming helper to drop the protocol so we can do: /**
// {{trimURL url}} Trim the protocol (http or https) from a URL/
@method trimURL
*/
trimURL: function( url ) { trimURL: function( url ) {
return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : ''; return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : '';
}, },
// Set up a URL-trimming helper to drop the protocol so we can do: /**
// {{trimURL url}} Convert text to lowercase.
@method toLower
*/
toLower: function( txt ) { toLower: function( txt ) {
return txt && txt.trim() ? txt.toLowerCase() : ''; return txt && txt.trim() ? txt.toLowerCase() : '';
}, },
// Set up a Markdown-to-WordProcessingML helper so we can do: /**
// {{either A B}} Return true if either value is truthy.
@method either
*/
either: function( lhs, rhs, options ) { either: function( lhs, rhs, options ) {
if (lhs || rhs) return options.fn(this); if (lhs || rhs) return options.fn(this);
}, },
// Set up a generic conditional helper so we can do: /**
// {{compare val otherVal operator="<"}} Perform a generic comparison.
// http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/ See: http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates
@method compare
*/
compare: function(lvalue, rvalue, options) { compare: function(lvalue, rvalue, options) {
if (arguments.length < 3) if (arguments.length < 3)
throw new Error("Handlerbars Helper 'compare' needs 2 parameters"); throw new Error("Handlerbars Helper 'compare' needs 2 parameters");

View File

@ -47,7 +47,6 @@ function main() {
opts = getOpts( a ); opts = getOpts( a );
logMsg( title ); logMsg( title );
// Get the action to be performed // Get the action to be performed
var params = a._.map( function(p){ return p.toLowerCase().trim(); }); var params = a._.map( function(p){ return p.toLowerCase().trim(); });
var verb = params[0]; var verb = params[0];
@ -56,7 +55,7 @@ function main() {
return; return;
} }
// Get source and dest params // Find the TO keyword, if any
var splitAt = _.indexOf( params, 'to' ); var splitAt = _.indexOf( params, 'to' );
if( splitAt === a._.length - 1 ) { if( splitAt === a._.length - 1 ) {
// 'TO' cannot be the last argument // 'TO' cannot be the last argument
@ -66,8 +65,10 @@ function main() {
return; return;
} }
// Massage inputs and outputs
var src = a._.slice(1, splitAt === -1 ? undefined : splitAt ); var src = a._.slice(1, splitAt === -1 ? undefined : splitAt );
var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 ); var dst = splitAt === -1 ? [] : a._.slice( splitAt + 1 );
( splitAt === -1 ) && dst.push( src.pop() ); // Allow omitting TO keyword
var parms = [ src, dst, opts, logMsg ]; var parms = [ src, dst, opts, logMsg ];
// Invoke the action // Invoke the action

View File

@ -17,3 +17,7 @@ String.isNullOrWhitespace = function( input ) {
String.prototype.endsWith = function(suffix) { String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1; return this.indexOf(suffix, this.length - suffix.length) !== -1;
}; };
String.is = function( val ) {
return typeof val === 'string' || val instanceof String;
};