From eabab26eef27c1be9f07a8112a0a7574b29ba3ff Mon Sep 17 00:00:00 2001 From: devlinjd Date: Thu, 17 Dec 2015 10:15:59 -0500 Subject: [PATCH 1/2] Update file headers. --- src/core/convert.js | 3 +- src/core/fluent-date.js | 3 +- src/core/fresh-resume.js | 3 +- src/core/jrs-resume.js | 3 +- src/core/theme.js | 3 +- src/eng/handlebars-generator.js | 70 +++++++++++++++++++++++---------- src/eng/underscore-generator.js | 4 +- src/fluentcmd.js | 2 +- src/fluentlib.js | 3 +- src/gen/base-generator.js | 5 ++- src/gen/html-generator.js | 5 ++- src/gen/html-pdf-generator.js | 3 +- src/gen/json-generator.js | 3 +- src/gen/json-yaml-generator.js | 4 +- src/gen/latex-generator.js | 5 ++- src/gen/markdown-generator.js | 5 ++- src/gen/template-generator.js | 5 ++- src/gen/text-generator.js | 5 ++- src/gen/word-generator.js | 5 ++- src/gen/xml-generator.js | 7 ++-- src/gen/yaml-generator.js | 6 +-- src/index.js | 1 + src/utils/class.js | 5 +++ src/utils/extend.js | 5 ++- src/utils/file-exists.js | 5 ++- src/utils/html-to-wpml.js | 7 +++- src/utils/string.js | 5 ++- 27 files changed, 120 insertions(+), 60 deletions(-) diff --git a/src/core/convert.js b/src/core/convert.js index 97c8c5f1..11131591 100644 --- a/src/core/convert.js +++ b/src/core/convert.js @@ -1,6 +1,7 @@ /** FRESH to JSON Resume conversion routiens. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module convert.js */ (function(){ diff --git a/src/core/fluent-date.js b/src/core/fluent-date.js index 26ba4be1..86897463 100644 --- a/src/core/fluent-date.js +++ b/src/core/fluent-date.js @@ -1,6 +1,7 @@ /** The FluentCV date representation. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module fluent-date.js */ var moment = require('moment'); diff --git a/src/core/fresh-resume.js b/src/core/fresh-resume.js index d21449c3..261b1a8b 100644 --- a/src/core/fresh-resume.js +++ b/src/core/fresh-resume.js @@ -1,6 +1,7 @@ /** Definition of the FRESHResume class. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module fresh-resume.js */ (function() { diff --git a/src/core/jrs-resume.js b/src/core/jrs-resume.js index a1c068ae..9a5bbdd3 100644 --- a/src/core/jrs-resume.js +++ b/src/core/jrs-resume.js @@ -1,6 +1,7 @@ /** Definition of the JRSResume class. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module jrs-resume.js */ (function() { diff --git a/src/core/theme.js b/src/core/theme.js index cbdc5481..01a52f73 100644 --- a/src/core/theme.js +++ b/src/core/theme.js @@ -1,6 +1,7 @@ /** -Abstract theme representation. +Definition of the Theme class. @license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module theme.js */ (function() { diff --git a/src/eng/handlebars-generator.js b/src/eng/handlebars-generator.js index ef61ed50..33dbc12f 100644 --- a/src/eng/handlebars-generator.js +++ b/src/eng/handlebars-generator.js @@ -1,25 +1,59 @@ /** -Handlebars template generate for FluentCV. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. +Definition of the HandlebarsGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module handlebars-generator.js */ (function() { - var _ = require('underscore'); - var HANDLEBARS = require('handlebars'); - var FS = require('fs'); - var moment = require('moment'); - var MD = require('marked'); - var H2W = require('../utils/html-to-wpml'); + + var _ = require('underscore') + , HANDLEBARS = require('handlebars') + , FS = require('fs') + , moment = require('moment') + , MD = require('marked') + , H2W = require('../utils/html-to-wpml'); + + + + /** + Perform template-based resume generation using Handlebars.js. + @method generate + */ module.exports = function( json, jst, format, cssInfo, opts, theme ) { + // Pre-compile any partials present in the theme. _.each( theme.partials, function( el ) { var tplData = FS.readFileSync( el.path, 'utf8' ); var compiledTemplate = HANDLEBARS.compile( tplData ); HANDLEBARS.registerPartial( el.name, compiledTemplate ); }); + // Register necessary helpers. + registerHelpers(); + + // Compile and run the Handlebars template. + var template = HANDLEBARS.compile(jst); + return template({ + r: json, + filt: opts.filters, + cssInfo: cssInfo, + headFragment: opts.headFragment || '' + }); + + }; + + + + /** + Register useful Handlebars helpers. + @method registerHelpers + */ + function registerHelpers() { + + // Set up a date formatting helper so we can do: + // {{#formatDate val 'YYYY-MM'}} HANDLEBARS.registerHelper("formatDate", function(datetime, format) { if( moment ) { return moment( datetime ).format( format ); @@ -29,19 +63,23 @@ Handlebars template generate for FluentCV. } }); + // Set up a Markdown-to-WordProcessingML helper so we can do: + // {{#wmpl val [true|false]}} HANDLEBARS.registerHelper("wpml", function( txt, inline ) { inline = (inline && !inline.hash) || false; - txt = inline ? MD(txt.trim()).replace(/^\s*

|<\/p>\s*$/gi, '') : MD(txt.trim()); + txt = inline ? + MD(txt.trim()).replace(/^\s*

|<\/p>\s*$/gi, '') : + MD(txt.trim()); txt = H2W( txt.trim() ); return txt; }); + // Set up a generic conditional helper so we can do: + // {{#compare val otherVal operator="<"}} // http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/ HANDLEBARS.registerHelper('compare', function(lvalue, rvalue, options) { - if (arguments.length < 3) throw new Error("Handlerbars Helper 'compare' needs 2 parameters"); - var operator = options.hash.operator || "=="; var operators = { '==': function(l,r) { return l == r; }, @@ -53,21 +91,13 @@ Handlebars template generate for FluentCV. '>=': function(l,r) { return l >= r; }, 'typeof': function(l,r) { return typeof l == r; } }; - if (!operators[operator]) throw new Error("Handlerbars Helper 'compare' doesn't know the operator "+operator); var result = operators[operator](lvalue,rvalue); return result ? options.fn(this) : options.inverse(this); }); + } - var template = HANDLEBARS.compile(jst); - return template({ - r: json, - filt: opts.filters, - cssInfo: cssInfo, - headFragment: opts.headFragment || '' - }); - }; }()); diff --git a/src/eng/underscore-generator.js b/src/eng/underscore-generator.js index 341021c1..755155d0 100644 --- a/src/eng/underscore-generator.js +++ b/src/eng/underscore-generator.js @@ -1,6 +1,6 @@ /** -Underscore template generate for FluentCV. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. +Definition of the UnderscoreGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. */ (function() { diff --git a/src/fluentcmd.js b/src/fluentcmd.js index 2d5accbf..f2658ab3 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -1,6 +1,6 @@ /** Internal resume generation logic for FluentCV. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. @module fluentcmd.js */ diff --git a/src/fluentlib.js b/src/fluentlib.js index f6e12602..927216f4 100644 --- a/src/fluentlib.js +++ b/src/fluentlib.js @@ -1,6 +1,7 @@ /** External API surface for FluentCV:CLI. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. +@module fluentlib.js */ module.exports = { diff --git a/src/gen/base-generator.js b/src/gen/base-generator.js index 86bc4527..9e1bc899 100644 --- a/src/gen/base-generator.js +++ b/src/gen/base-generator.js @@ -1,6 +1,7 @@ /** -Base resume generator for FluentCV. -@license Copyright (c) 2015 | James M. Devlin +Definition of the BaseGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module base-generator.js */ (function() { diff --git a/src/gen/html-generator.js b/src/gen/html-generator.js index 4c330090..41bfbcd2 100644 --- a/src/gen/html-generator.js +++ b/src/gen/html-generator.js @@ -1,6 +1,7 @@ /** -HTML resume generator for FluentCV. -@license Copyright (c) 2015 James M. Devlin / FluentDesk +Definition of the HTMLGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module html-generator.js */ (function() { diff --git a/src/gen/html-pdf-generator.js b/src/gen/html-pdf-generator.js index ae55e10a..fa065959 100644 --- a/src/gen/html-pdf-generator.js +++ b/src/gen/html-pdf-generator.js @@ -1,6 +1,7 @@ /** Definition of the HtmlPdfGenerator class. -@license Copyright (c) 2015 James M. Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module html-pdf-generator.js */ (function() { diff --git a/src/gen/json-generator.js b/src/gen/json-generator.js index 2099f418..9e884e4b 100644 --- a/src/gen/json-generator.js +++ b/src/gen/json-generator.js @@ -1,6 +1,7 @@ /** Definition of the JsonGenerator class. -@license Copyright (c) 2015 | James M. Devlin +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module json-generator.js */ var BaseGenerator = require('./base-generator'); diff --git a/src/gen/json-yaml-generator.js b/src/gen/json-yaml-generator.js index c198af80..325cde76 100644 --- a/src/gen/json-yaml-generator.js +++ b/src/gen/json-yaml-generator.js @@ -1,7 +1,7 @@ /** -A JSON-driven YAML resume generator for FluentLib. +Definition of the JsonYamlGenerator class. @module json-yaml-generator.js -@license MIT. Copyright (c) 2015 James Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. */ (function() { diff --git a/src/gen/latex-generator.js b/src/gen/latex-generator.js index 1e323153..20e4a51e 100644 --- a/src/gen/latex-generator.js +++ b/src/gen/latex-generator.js @@ -1,6 +1,7 @@ /** -LaTeX resume generator for FluentCV. -@license MIT. Copyright (c) 2015 James Devlin / FluentDesk +Definition of the LaTeXGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module latex-generator.js */ var TemplateGenerator = require('./template-generator'); diff --git a/src/gen/markdown-generator.js b/src/gen/markdown-generator.js index b200e552..a93d383e 100644 --- a/src/gen/markdown-generator.js +++ b/src/gen/markdown-generator.js @@ -1,6 +1,7 @@ /** -Markdown resume generator for FluentCV. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +Definition of the MarkdownGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module markdown-generator.js */ var TemplateGenerator = require('./template-generator'); diff --git a/src/gen/template-generator.js b/src/gen/template-generator.js index 26859b44..56450224 100644 --- a/src/gen/template-generator.js +++ b/src/gen/template-generator.js @@ -1,6 +1,7 @@ /** -Template-based resume generator base for FluentCV. -@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. +Definition of the TemplateGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module template-generator.js */ (function() { diff --git a/src/gen/text-generator.js b/src/gen/text-generator.js index 5aa077be..d3611453 100644 --- a/src/gen/text-generator.js +++ b/src/gen/text-generator.js @@ -1,6 +1,7 @@ /** -Plain text resume generator for FluentCV. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +Definition of the TextGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module text-generator.js */ var TemplateGenerator = require('./template-generator'); diff --git a/src/gen/word-generator.js b/src/gen/word-generator.js index 0ca3f017..1e15f3d1 100644 --- a/src/gen/word-generator.js +++ b/src/gen/word-generator.js @@ -1,6 +1,7 @@ /** -MS Word resume generator for FluentCV. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +Definition of the WordGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module word-generator.js */ (function() { diff --git a/src/gen/xml-generator.js b/src/gen/xml-generator.js index 593f47cf..04146131 100644 --- a/src/gen/xml-generator.js +++ b/src/gen/xml-generator.js @@ -1,6 +1,7 @@ /** -XML resume generator for FluentCV. -@license Copyright (c) 2015 | James M. Devlin +Definition of the XMLGenerator class. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module xml-generator.js */ var BaseGenerator = require('./base-generator'); @@ -8,7 +9,7 @@ var BaseGenerator = require('./base-generator'); /** The XmlGenerator generates an XML resume via the TemplateGenerator. */ -var XmlGenerator = module.exports = BaseGenerator.extend({ +var XMLGenerator = module.exports = BaseGenerator.extend({ init: function(){ this._super( 'xml' ); diff --git a/src/gen/yaml-generator.js b/src/gen/yaml-generator.js index 000198cd..bb9f9953 100644 --- a/src/gen/yaml-generator.js +++ b/src/gen/yaml-generator.js @@ -1,7 +1,7 @@ /** -A YAML resume generator for FluentLib. +Definition of the YAMLGenerator class. @module yaml-generator.js -@license MIT. Copyright (c) 2015 James Devlin / FluentDesk +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. */ @@ -13,7 +13,7 @@ A YAML resume generator for FluentLib. YamlGenerator generates a YAML-formatted resume via TemplateGenerator. */ - var YamlGenerator = module.exports = TemplateGenerator.extend({ + var YAMLGenerator = module.exports = TemplateGenerator.extend({ init: function(){ this._super( 'yml', 'yml' ); diff --git a/src/index.js b/src/index.js index e50315fe..876dacea 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ /** Command-line interface (CLI) for FluentCV:CLI. @license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk. +@module index.js */ var ARGS = require( 'minimist' ) diff --git a/src/utils/class.js b/src/utils/class.js index 9479e89b..d49493da 100644 --- a/src/utils/class.js +++ b/src/utils/class.js @@ -1,3 +1,8 @@ +/** +Definition of John Resig's `Class` class. +@module class.js +*/ + /* Simple JavaScript Inheritance * By John Resig http://ejohn.org/ * MIT Licensed. diff --git a/src/utils/extend.js b/src/utils/extend.js index 6f08191e..0daeaa45 100644 --- a/src/utils/extend.js +++ b/src/utils/extend.js @@ -1,6 +1,7 @@ /** -Plain JavaScript replacement of jQuery .extend based on jQuery sources. -@license Copyright (c) 2015 by James M. Devlin. All rights reserved. +Definition of the `extend` method. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module extend.js */ function _extend() { diff --git a/src/utils/file-exists.js b/src/utils/file-exists.js index 2b615358..ef99ef94 100644 --- a/src/utils/file-exists.js +++ b/src/utils/file-exists.js @@ -1,6 +1,7 @@ /** -File-exists checker for Node.js. -@license Copyright (c) 2015 | James M. Devlin +Definition of the `fileExists` method. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module file-exists.js */ var FS = require('fs'); diff --git a/src/utils/html-to-wpml.js b/src/utils/html-to-wpml.js index b0136efd..5b95c4c3 100644 --- a/src/utils/html-to-wpml.js +++ b/src/utils/html-to-wpml.js @@ -1,3 +1,8 @@ +/** +Definition of the Markdown to WordProcessingML conversion routine. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module html-to-wpml.js +*/ (function(){ @@ -7,7 +12,7 @@ module.exports = function( html ) { var final = ''; - var is_bold = false, is_italic = false; + var is_bold = false, is_italic = false, is_link = false; var depth = 0; var tokens = HTML5Tokenizer.tokenize( html ); diff --git a/src/utils/string.js b/src/utils/string.js index 2ec3a88d..8cee01f9 100644 --- a/src/utils/string.js +++ b/src/utils/string.js @@ -1,6 +1,7 @@ /** -String utility functions. -@license Copyright (c) 2015 | James M. Devlin +Definitions of string utility functions. +@license MIT. Copyright (c) 2015 James Devlin / FluentDesk. +@module string.js */ /** From e80d8fb5c87e96ed88ba97ed87317fcb7892f4d7 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Thu, 17 Dec 2015 10:29:22 -0500 Subject: [PATCH 2/2] Bump version. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3dbbf1fe..fb0cfbdf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fluentcv", - "version": "0.10.2", + "version": "0.10.3", "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": { "type": "git", @@ -33,7 +33,7 @@ "homepage": "https://github.com/fluentdesk/fluentcv", "dependencies": { "colors": "^1.1.2", - "fluent-themes": "~0.6.2-beta", + "fluent-themes": "~0.6.3-beta", "fresca": "~0.2.1", "fs-extra": "^0.24.0", "handlebars": "^4.0.5",