diff --git a/src/core/convert.js b/src/core/convert.js index 97c8c5f..1113159 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 26ba4be..8689746 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 d21449c..261b1a8 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 a1c068a..9a5bbdd 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 cbdc548..01a52f7 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 ef61ed5..33dbc12 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 341021c..755155d 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 2d5accb..f2658ab 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 f6e1260..927216f 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 86bc452..9e1bc89 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 4c33009..41bfbcd 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 ae55e10..fa06595 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 2099f41..9e884e4 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 c198af8..325cde7 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 1e32315..20e4a51 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 b200e55..a93d383 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 26859b4..5645022 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 5aa077b..d361145 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 0ca3f01..1e15f3d 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 593f47c..0414613 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 000198c..bb9f995 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 e50315f..876dace 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 9479e89..d49493d 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 6f08191..0daeaa4 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 2b61535..ef99ef9 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 b0136ef..5b95c4c 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 2ec3a88..8cee01f 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 */ /**