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() {
|
2018-02-02 00:22:17 +00:00
|
|
|
var JRSTheme, PATH, _, errors, parsePath, pathExists;
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
_ = require('underscore');
|
|
|
|
|
|
|
|
PATH = require('path');
|
|
|
|
|
|
|
|
parsePath = require('parse-filepath');
|
|
|
|
|
|
|
|
pathExists = require('path-exists').sync;
|
|
|
|
|
2018-02-02 00:22:17 +00:00
|
|
|
errors = require('./status-codes');
|
|
|
|
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
The JRSTheme class is a representation of a JSON Resume theme asset.
|
|
|
|
@class JRSTheme
|
|
|
|
*/
|
|
|
|
|
|
|
|
JRSTheme = (function() {
|
|
|
|
function JRSTheme() {}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-02-02 00:22:17 +00:00
|
|
|
Open and parse the specified JRS theme.
|
2016-01-27 10:29:26 +00:00
|
|
|
@method open
|
|
|
|
*/
|
2016-01-30 16:31:39 +00:00
|
|
|
|
|
|
|
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,
|
2016-02-13 21:08:45 +00:00
|
|
|
primary: true,
|
2016-01-27 10:29:26 +00:00
|
|
|
ext: 'html',
|
|
|
|
css: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
pdf: {
|
|
|
|
outFormat: 'pdf',
|
|
|
|
files: [
|
|
|
|
{
|
|
|
|
action: 'transform',
|
|
|
|
render: this.render,
|
2016-02-13 21:08:45 +00:00
|
|
|
primary: true,
|
2016-01-27 10:29:26 +00:00
|
|
|
ext: 'pdf',
|
|
|
|
css: null
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
throw {
|
2018-02-02 00:22:17 +00:00
|
|
|
fluenterror: errors.missingPackageJSON
|
2016-01-27 10:29:26 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
return this;
|
2016-01-30 16:31:39 +00:00
|
|
|
};
|
|
|
|
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Determine if the theme supports the output format.
|
|
|
|
@method hasFormat
|
|
|
|
*/
|
2016-01-30 16:31:39 +00:00
|
|
|
|
|
|
|
JRSTheme.prototype.hasFormat = function(fmt) {
|
2016-01-27 10:29:26 +00:00
|
|
|
return _.has(this.formats, fmt);
|
2016-01-30 16:31:39 +00:00
|
|
|
};
|
|
|
|
|
2016-01-27 10:29:26 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Return the requested output format.
|
|
|
|
@method getFormat
|
|
|
|
*/
|
|
|
|
|
2016-01-30 16:31:39 +00:00
|
|
|
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
|