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

Fix JSON Resume theme breakage.

Fixes #128.
This commit is contained in:
hacksalot 2016-01-30 11:31:39 -05:00
parent d69e4635be
commit 1c416f39d3
4 changed files with 74 additions and 69 deletions

View File

@ -6,7 +6,7 @@ Definition of the JRSTheme class.
*/ */
(function() { (function() {
var JRSTheme, PATH, _, getFormat, parsePath, pathExists; var JRSTheme, PATH, _, parsePath, pathExists;
_ = require('underscore'); _ = require('underscore');
@ -25,17 +25,13 @@ Definition of the JRSTheme class.
JRSTheme = (function() { JRSTheme = (function() {
function JRSTheme() {} function JRSTheme() {}
return JRSTheme;
})();
({
/** /**
Open and parse the specified theme. Open and parse the specified theme.
@method open @method open
*/ */
open: function(thFolder) {
JRSTheme.prototype.open = function(thFolder) {
var pathInfo, pkgJsonPath, thApi, thPkg; var pathInfo, pkgJsonPath, thApi, thPkg;
this.folder = thFolder; this.folder = thFolder;
pathInfo = parsePath(thFolder); pathInfo = parsePath(thFolder);
@ -78,25 +74,31 @@ Definition of the JRSTheme class.
}; };
} }
return this; return this;
}, };
/** /**
Determine if the theme supports the output format. Determine if the theme supports the output format.
@method hasFormat @method hasFormat
*/ */
hasFormat: function(fmt) {
JRSTheme.prototype.hasFormat = function(fmt) {
return _.has(this.formats, fmt); return _.has(this.formats, fmt);
} };
/** /**
Return the requested output format. Return the requested output format.
@method getFormat @method getFormat
*/ */
});
getFormat = function(fmt) { JRSTheme.prototype.getFormat = function(fmt) {
return this.formats[fmt]; return this.formats[fmt];
}; };
return JRSTheme;
})();
module.exports = JRSTheme; module.exports = JRSTheme;

View File

@ -36,10 +36,11 @@ Definition of the JRSGenerator class.
generate: function(json, jst, format, cssInfo, opts, theme) { generate: function(json, jst, format, cssInfo, opts, theme) {
var org, rezHtml, turnoff; var org, rezHtml, turnoff;
turnoff = ['log', 'error', 'dir']; turnoff = ['log', 'error', 'dir'];
org = turnoff.map(c)(function() { org = turnoff.map(function(c) {
var ret; var ret;
ret = console[c]; ret = console[c];
return console[c] = function() {}; console[c] = function() {};
return ret;
}); });
rezHtml = theme.render(json.harden()); rezHtml = theme.render(json.harden());
turnoff.forEach(function(c, idx) { turnoff.forEach(function(c, idx) {

View File

@ -20,68 +20,69 @@ The JRSTheme class is a representation of a JSON Resume theme asset.
class JRSTheme 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 @folder = thFolder
# name as folder
pathInfo = parsePath thFolder
# Open and parse the theme's package.json file. # Open the [theme-name].json file; should have the same
pkgJsonPath = PATH.join thFolder, 'package.json' # name as folder
if pathExists pkgJsonPath pathInfo = parsePath thFolder
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 # Open and parse the theme's package.json file.
# properties necessary to allow JSON Resume themes to share a rendering pkgJsonPath = PATH.join thFolder, 'package.json'
# path with FRESH themes. if pathExists pkgJsonPath
this.formats = thApi = require thFolder
html: thPkg = require pkgJsonPath
outFormat: 'html' this.name = thPkg.name
files: [{ this.render = (thApi && thApi.render) || undefined
action: 'transform', this.engine = 'jrs'
render: this.render,
major: true, # Create theme formats (HTML and PDF). Just add the bare minimum mix of
ext: 'html', # properties necessary to allow JSON Resume themes to share a rendering
css: null # path with FRESH themes.
}] this.formats =
pdf: html:
outFormat: 'pdf' outFormat: 'html'
files: [{ files: [{
action: 'transform', action: 'transform',
render: this.render, render: this.render,
major: true, major: true,
ext: 'pdf', ext: 'html',
css: null css: null
}] }]
else pdf:
throw { fluenterror: HACKMYSTATUS.missingPackageJSON }; 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. Determine if the theme supports the output format.
@method hasFormat @method hasFormat
### ###
hasFormat: ( fmt ) -> _.has this.formats, fmt hasFormat: ( fmt ) -> _.has this.formats, fmt
###* ###*
Return the requested output format. Return the requested output format.
@method getFormat @method getFormat
### ###
getFormat = ( fmt ) -> @formats[ fmt ] getFormat: ( fmt ) -> @formats[ fmt ]
module.exports = JRSTheme; module.exports = JRSTheme;

View File

@ -25,9 +25,10 @@ JRSGenerator = module.exports =
# Disable JRS theme chatter (console.log, console.error, etc.) # Disable JRS theme chatter (console.log, console.error, etc.)
turnoff = ['log', 'error', 'dir']; turnoff = ['log', 'error', 'dir'];
org = turnoff.map(c) -> org = turnoff.map (c) ->
ret = console[c] ret = console[c]
console[c] = () -> console[c] = () ->
ret
# Freeze and render # Freeze and render
rezHtml = theme.render json.harden() rezHtml = theme.render json.harden()