From 1c416f39d311a323a3aeb6bf73364fafd0d0ee64 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Sat, 30 Jan 2016 11:31:39 -0500 Subject: [PATCH] Fix JSON Resume theme breakage. Fixes #128. --- dist/core/jrs-theme.js | 30 +++++---- dist/renderers/jrs-generator.js | 5 +- src/core/jrs-theme.coffee | 105 +++++++++++++++-------------- src/renderers/jrs-generator.coffee | 3 +- 4 files changed, 74 insertions(+), 69 deletions(-) diff --git a/dist/core/jrs-theme.js b/dist/core/jrs-theme.js index 9cbb4b2..4e5b26d 100644 --- a/dist/core/jrs-theme.js +++ b/dist/core/jrs-theme.js @@ -6,7 +6,7 @@ Definition of the JRSTheme class. */ (function() { - var JRSTheme, PATH, _, getFormat, parsePath, pathExists; + var JRSTheme, PATH, _, parsePath, pathExists; _ = require('underscore'); @@ -25,17 +25,13 @@ Definition of the JRSTheme class. JRSTheme = (function() { function JRSTheme() {} - return JRSTheme; - - })(); - - ({ /** Open and parse the specified theme. @method open */ - open: function(thFolder) { + + JRSTheme.prototype.open = function(thFolder) { var pathInfo, pkgJsonPath, thApi, thPkg; this.folder = thFolder; pathInfo = parsePath(thFolder); @@ -78,25 +74,31 @@ Definition of the JRSTheme class. }; } return this; - }, + }; + /** Determine if the theme supports the output format. @method hasFormat */ - hasFormat: function(fmt) { + + JRSTheme.prototype.hasFormat = function(fmt) { return _.has(this.formats, fmt); - } + }; + /** Return the requested output format. @method getFormat */ - }); - getFormat = function(fmt) { - return this.formats[fmt]; - }; + JRSTheme.prototype.getFormat = function(fmt) { + return this.formats[fmt]; + }; + + return JRSTheme; + + })(); module.exports = JRSTheme; diff --git a/dist/renderers/jrs-generator.js b/dist/renderers/jrs-generator.js index e867112..1f6ad80 100644 --- a/dist/renderers/jrs-generator.js +++ b/dist/renderers/jrs-generator.js @@ -36,10 +36,11 @@ Definition of the JRSGenerator class. generate: function(json, jst, format, cssInfo, opts, theme) { var org, rezHtml, turnoff; turnoff = ['log', 'error', 'dir']; - org = turnoff.map(c)(function() { + org = turnoff.map(function(c) { var ret; ret = console[c]; - return console[c] = function() {}; + console[c] = function() {}; + return ret; }); rezHtml = theme.render(json.harden()); turnoff.forEach(function(c, idx) { diff --git a/src/core/jrs-theme.coffee b/src/core/jrs-theme.coffee index 771e245..4734824 100644 --- a/src/core/jrs-theme.coffee +++ b/src/core/jrs-theme.coffee @@ -20,68 +20,69 @@ The JRSTheme class is a representation of a JSON Resume theme asset. class JRSTheme -###* -Open and parse the specified theme. -@method open -### -open: ( thFolder ) -> - @folder = thFolder + ###* + Open and parse the specified theme. + @method open + ### + open: ( thFolder ) -> - # Open the [theme-name].json file; should have the same - # name as folder - pathInfo = parsePath thFolder + @folder = thFolder - # Open and parse the theme's package.json file. - pkgJsonPath = PATH.join thFolder, 'package.json' - if pathExists pkgJsonPath - thApi = require thFolder - thPkg = require pkgJsonPath - this.name = thPkg.name - this.render = (thApi && thApi.render) || undefined - this.engine = 'jrs' + # Open the [theme-name].json file; should have the same + # name as folder + pathInfo = parsePath thFolder - # Create theme formats (HTML and PDF). Just add the bare minimum mix of - # properties necessary to allow JSON Resume themes to share a rendering - # path with FRESH themes. - this.formats = - html: - outFormat: 'html' - files: [{ - action: 'transform', - render: this.render, - major: true, - ext: 'html', - css: null - }] - pdf: - outFormat: 'pdf' - files: [{ - action: 'transform', - render: this.render, - major: true, - ext: 'pdf', - css: null - }] - else - throw { fluenterror: HACKMYSTATUS.missingPackageJSON }; - @ + # Open and parse the theme's package.json file. + pkgJsonPath = PATH.join thFolder, 'package.json' + if pathExists pkgJsonPath + thApi = require thFolder + thPkg = require pkgJsonPath + this.name = thPkg.name + this.render = (thApi && thApi.render) || undefined + this.engine = 'jrs' + + # Create theme formats (HTML and PDF). Just add the bare minimum mix of + # properties necessary to allow JSON Resume themes to share a rendering + # path with FRESH themes. + this.formats = + html: + outFormat: 'html' + files: [{ + action: 'transform', + render: this.render, + major: true, + ext: 'html', + css: null + }] + pdf: + outFormat: 'pdf' + files: [{ + action: 'transform', + render: this.render, + major: true, + ext: 'pdf', + css: null + }] + else + throw { fluenterror: HACKMYSTATUS.missingPackageJSON }; + @ -###* -Determine if the theme supports the output format. -@method hasFormat -### -hasFormat: ( fmt ) -> _.has this.formats, fmt + ###* + Determine if the theme supports the output format. + @method hasFormat + ### + hasFormat: ( fmt ) -> _.has this.formats, fmt -###* -Return the requested output format. -@method getFormat -### -getFormat = ( fmt ) -> @formats[ fmt ] + ###* + Return the requested output format. + @method getFormat + ### + getFormat: ( fmt ) -> @formats[ fmt ] module.exports = JRSTheme; diff --git a/src/renderers/jrs-generator.coffee b/src/renderers/jrs-generator.coffee index 2ecbddc..6a39612 100644 --- a/src/renderers/jrs-generator.coffee +++ b/src/renderers/jrs-generator.coffee @@ -25,9 +25,10 @@ JRSGenerator = module.exports = # Disable JRS theme chatter (console.log, console.error, etc.) turnoff = ['log', 'error', 'dir']; - org = turnoff.map(c) -> + org = turnoff.map (c) -> ret = console[c] console[c] = () -> + ret # Freeze and render rezHtml = theme.render json.harden()