1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-07-05 01:20:06 +01:00
HackMyResume/dist/core/jrs-theme.js

108 lines
2.2 KiB
JavaScript
Raw Normal View History

2016-01-27 10:29:26 +00:00
/**
Definition of the JRSTheme class.
@module core/jrs-theme
@license MIT. See LICENSE.MD for details.
*/
(function() {
var JRSTheme, PATH, _, parsePath, pathExists;
2016-01-27 10:29:26 +00:00
_ = require('underscore');
PATH = require('path');
parsePath = require('parse-filepath');
pathExists = require('path-exists').sync;
/**
The JRSTheme class is a representation of a JSON Resume theme asset.
@class JRSTheme
*/
JRSTheme = (function() {
function JRSTheme() {}
/**
Open and parse the specified theme.
@method open
*/
JRSTheme.prototype.open = function(thFolder) {
2016-01-27 10:29:26 +00:00
var pathInfo, pkgJsonPath, thApi, thPkg;
this.folder = thFolder;
pathInfo = parsePath(thFolder);
pkgJsonPath = PATH.join(thFolder, 'package.json');
if (pathExists(pkgJsonPath)) {
thApi = require(thFolder);
thPkg = require(pkgJsonPath);
this.name = thPkg.name;
this.render = (thApi && thApi.render) || void 0;
this.engine = 'jrs';
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
};
}
return this;
};
2016-01-27 10:29:26 +00:00
/**
Determine if the theme supports the output format.
@method hasFormat
*/
JRSTheme.prototype.hasFormat = function(fmt) {
2016-01-27 10:29:26 +00:00
return _.has(this.formats, fmt);
};
2016-01-27 10:29:26 +00:00
/**
Return the requested output format.
@method getFormat
*/
JRSTheme.prototype.getFormat = function(fmt) {
return this.formats[fmt];
};
return JRSTheme;
})();
2016-01-27 10:29:26 +00:00
module.exports = JRSTheme;
}).call(this);
2016-02-02 02:14:36 +00:00
//# sourceMappingURL=jrs-theme.js.map