mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-02 20:37:08 +01:00
Gather.
This commit is contained in:
167
dist/core/fresh-theme.js
vendored
167
dist/core/fresh-theme.js
vendored
@ -6,7 +6,7 @@ Definition of the FRESHTheme class.
|
||||
*/
|
||||
|
||||
(function() {
|
||||
var EXTEND, FRESHTheme, FS, HMSTATUS, PATH, READFILES, _, _load, friendlyName, loadSafeJson, moment, parsePath, pathExists, validator;
|
||||
var EXTEND, FRESHTheme, FS, HMSTATUS, PATH, READFILES, _, _load, _loadOne, friendlyName, loadSafeJson, moment, parsePath, pathExists, validator;
|
||||
|
||||
FS = require('fs');
|
||||
|
||||
@ -31,9 +31,7 @@ Definition of the FRESHTheme class.
|
||||
READFILES = require('recursive-readdir-sync');
|
||||
|
||||
|
||||
/*
|
||||
The FRESHTheme class is a representation of a FRESH theme
|
||||
asset. See also: JRSTheme.
|
||||
/* A representation of a FRESH theme asset.
|
||||
@class FRESHTheme
|
||||
*/
|
||||
|
||||
@ -41,9 +39,7 @@ Definition of the FRESHTheme class.
|
||||
function FRESHTheme() {}
|
||||
|
||||
|
||||
/*
|
||||
Open and parse the specified theme.
|
||||
*/
|
||||
/* Open and parse the specified theme. */
|
||||
|
||||
FRESHTheme.prototype.open = function(themeFolder) {
|
||||
var cached, formatsHash, pathInfo, that, themeFile, themeInfo;
|
||||
@ -96,9 +92,7 @@ Definition of the FRESHTheme class.
|
||||
})();
|
||||
|
||||
|
||||
/* Load the theme implicitly, by scanning the theme folder for files. TODO:
|
||||
Refactor duplicated code with loadExplicit.
|
||||
*/
|
||||
/* Load and parse theme source files. */
|
||||
|
||||
_load = function(formatsHash) {
|
||||
var copyOnly, fmts, major, that, tplFolder;
|
||||
@ -107,74 +101,8 @@ Definition of the FRESHTheme class.
|
||||
tplFolder = PATH.join(this.folder, 'src');
|
||||
copyOnly = ['.ttf', '.otf', '.png', '.jpg', '.jpeg', '.pdf'];
|
||||
fmts = READFILES(tplFolder).map(function(absPath) {
|
||||
var absPathSafe, act, idx, isMajor, obj, outFmt, pathInfo, portion, ref, ref1, reg, res;
|
||||
pathInfo = parsePath(absPath);
|
||||
absPathSafe = absPath.trim().toLowerCase();
|
||||
outFmt = '';
|
||||
isMajor = false;
|
||||
if (that.formats) {
|
||||
outFmt = _.find(Object.keys(that.formats), function(fmtKey) {
|
||||
var fmtVal;
|
||||
fmtVal = that.formats[fmtKey];
|
||||
return _.some(fmtVal.transform, function(fpath) {
|
||||
var absPathB;
|
||||
absPathB = PATH.join(that.folder, fpath).trim().toLowerCase();
|
||||
return absPathB === absPathSafe;
|
||||
});
|
||||
});
|
||||
if (outFmt) {
|
||||
isMajor = true;
|
||||
}
|
||||
}
|
||||
if (!outFmt) {
|
||||
portion = pathInfo.dirname.replace(tplFolder, '');
|
||||
if (portion && portion.trim()) {
|
||||
if (portion[1] === '_') {
|
||||
return;
|
||||
}
|
||||
reg = /^(?:\/|\\)(html|latex|doc|pdf|png|partials)(?:\/|\\)?/ig;
|
||||
res = reg.exec(portion);
|
||||
if (res) {
|
||||
if (res[1] !== 'partials') {
|
||||
outFmt = res[1];
|
||||
} else {
|
||||
that.partials = that.partials || [];
|
||||
that.partials.push({
|
||||
name: pathInfo.name,
|
||||
path: absPath
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!outFmt) {
|
||||
idx = pathInfo.name.lastIndexOf('-');
|
||||
outFmt = idx === -1 ? pathInfo.name : pathInfo.name.substr(idx + 1);
|
||||
isMajor = true;
|
||||
}
|
||||
act = _.contains(copyOnly, pathInfo.extname) ? 'copy' : 'transform';
|
||||
formatsHash[outFmt] = formatsHash[outFmt] || {
|
||||
outFormat: outFmt,
|
||||
files: []
|
||||
};
|
||||
if ((ref = that.formats) != null ? (ref1 = ref[outFmt]) != null ? ref1.symLinks : void 0 : void 0) {
|
||||
formatsHash[outFmt].symLinks = that.formats[outFmt].symLinks;
|
||||
}
|
||||
obj = {
|
||||
action: act,
|
||||
path: absPath,
|
||||
major: isMajor,
|
||||
orgPath: PATH.relative(tplFolder, absPath),
|
||||
ext: pathInfo.extname.slice(1),
|
||||
title: friendlyName(outFmt),
|
||||
pre: outFmt,
|
||||
data: FS.readFileSync(absPath, 'utf8'),
|
||||
css: null
|
||||
};
|
||||
formatsHash[outFmt].files.push(obj);
|
||||
return obj;
|
||||
});
|
||||
return _loadOne.call(this, absPath, formatsHash, tplFolder);
|
||||
}, this);
|
||||
this.cssFiles = fmts.filter(function(fmt) {
|
||||
return fmt && (fmt.ext === 'css');
|
||||
});
|
||||
@ -200,14 +128,87 @@ Definition of the FRESHTheme class.
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
Return a more friendly name for certain formats.
|
||||
TODO: Refactor
|
||||
*/
|
||||
/* Load a single theme file. */
|
||||
|
||||
_loadOne = function(absPath, formatsHash, tplFolder) {
|
||||
var absPathSafe, act, idx, obj, outFmt, pathInfo, portion, ref, ref1, reg, res, shouldTransform;
|
||||
pathInfo = parsePath(absPath);
|
||||
absPathSafe = absPath.trim().toLowerCase();
|
||||
outFmt = '';
|
||||
shouldTransform = false;
|
||||
if (this.explicit) {
|
||||
outFmt = _.find(Object.keys(this.formats), function(fmtKey) {
|
||||
var fmtVal;
|
||||
fmtVal = this.formats[fmtKey];
|
||||
return _.some(fmtVal.transform, function(fpath) {
|
||||
var absPathB;
|
||||
absPathB = PATH.join(this.folder, fpath).trim().toLowerCase();
|
||||
return absPathB === absPathSafe;
|
||||
}, this);
|
||||
}, this);
|
||||
if (outFmt) {
|
||||
act = 'transform';
|
||||
}
|
||||
}
|
||||
if (!outFmt) {
|
||||
portion = pathInfo.dirname.replace(tplFolder, '');
|
||||
if (portion && portion.trim()) {
|
||||
if (portion[1] === '_') {
|
||||
return;
|
||||
}
|
||||
reg = /^(?:\/|\\)(html|latex|doc|pdf|png|partials)(?:\/|\\)?/ig;
|
||||
res = reg.exec(portion);
|
||||
if (res) {
|
||||
if (res[1] !== 'partials') {
|
||||
outFmt = res[1];
|
||||
if (!this.explicit) {
|
||||
act = 'transform';
|
||||
}
|
||||
} else {
|
||||
this.partials = this.partials || [];
|
||||
this.partials.push({
|
||||
name: pathInfo.name,
|
||||
path: absPath
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!outFmt) {
|
||||
idx = pathInfo.name.lastIndexOf('-');
|
||||
outFmt = idx === -1 ? pathInfo.name : pathInfo.name.substr(idx + 1);
|
||||
if (!this.explicit) {
|
||||
act = 'transform';
|
||||
}
|
||||
}
|
||||
formatsHash[outFmt] = formatsHash[outFmt] || {
|
||||
outFormat: outFmt,
|
||||
files: []
|
||||
};
|
||||
if ((ref = this.formats) != null ? (ref1 = ref[outFmt]) != null ? ref1.symLinks : void 0 : void 0) {
|
||||
formatsHash[outFmt].symLinks = this.formats[outFmt].symLinks;
|
||||
}
|
||||
obj = {
|
||||
action: act,
|
||||
path: absPath,
|
||||
orgPath: PATH.relative(tplFolder, absPath),
|
||||
ext: pathInfo.extname.slice(1),
|
||||
title: friendlyName(outFmt),
|
||||
pre: outFmt,
|
||||
data: FS.readFileSync(absPath, 'utf8'),
|
||||
css: null
|
||||
};
|
||||
formatsHash[outFmt].files.push(obj);
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
/* Return a more friendly name for certain formats. */
|
||||
|
||||
friendlyName = function(val) {
|
||||
var friendly;
|
||||
val = val.trim().toLowerCase();
|
||||
val = (val && val.trim().toLowerCase()) || '';
|
||||
friendly = {
|
||||
yml: 'yaml',
|
||||
md: 'markdown',
|
||||
|
1
dist/generators/template-generator.js
vendored
1
dist/generators/template-generator.js
vendored
@ -131,7 +131,6 @@ Definition of the TemplateGenerator class. TODO: Refactor
|
||||
opts.beforeWrite(thisFilePath);
|
||||
}
|
||||
MKDIRP.sync(PATH.dirname(thisFilePath));
|
||||
console.log(file.info.path);
|
||||
if (file.info.action !== 'copy') {
|
||||
FS.writeFileSync(thisFilePath, file.data, {
|
||||
encoding: 'utf8',
|
||||
|
34
dist/helpers/generic-helpers.js
vendored
34
dist/helpers/generic-helpers.js
vendored
@ -38,18 +38,21 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
GenericHelpers = module.exports = {
|
||||
|
||||
/**
|
||||
Convert the input date to a specified format through Moment.js.
|
||||
If date is invalid, will return the time provided by the user,
|
||||
or default to the fallback param or 'Present' if that is set to true
|
||||
@method formatDate
|
||||
Display a formatted date with optional fallback text.
|
||||
Convert the input date to the specified format through Moment.js. If date is
|
||||
valid, return the formatted date string. If date is null, undefined, or other
|
||||
falsy value, return the value of the 'fallback' parameter, if specified, or
|
||||
null if no fallback was specified. If date is invalid, but not null/undefined/
|
||||
falsy, return it as-is.
|
||||
*/
|
||||
formatDate: function(datetime, format, fallback) {
|
||||
formatDate: function(datetime, dtFormat, fallback) {
|
||||
var momentDate;
|
||||
if (moment) {
|
||||
momentDate = moment(datetime);
|
||||
if (momentDate.isValid()) {
|
||||
return momentDate.format(format);
|
||||
}
|
||||
if (dtFormat == null) {
|
||||
dtFormat = 'YYYY-MM';
|
||||
}
|
||||
momentDate = moment(datetime);
|
||||
if (momentDate.isValid()) {
|
||||
return momentDate.format(dtFormat);
|
||||
}
|
||||
return datetime || (typeof fallback === 'string' ? fallback : (fallback === true ? 'Present' : null));
|
||||
},
|
||||
@ -99,8 +102,8 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
},
|
||||
|
||||
/**
|
||||
Return true if the section is present on the resume and has at least one
|
||||
element.
|
||||
Block-level helper. Emit the enclosed content if the resume has a section with
|
||||
the specified name. Otherwise, emit an empty string ''.
|
||||
@method section
|
||||
*/
|
||||
section: function(title, options) {
|
||||
@ -292,7 +295,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
},
|
||||
|
||||
/**
|
||||
Return true if the context has the property or subpropery.
|
||||
Emit the enclosed content if the resume has the named property or subproperty.
|
||||
@method has
|
||||
*/
|
||||
has: function(title, options) {
|
||||
@ -328,10 +331,7 @@ Generic template helper definitions for HackMyResume / FluentCV.
|
||||
return (this.opts.stitles && this.opts.stitles[sname.toLowerCase().trim()]) || stitle;
|
||||
},
|
||||
|
||||
/**
|
||||
Convert inline Markdown to inline WordProcessingML.
|
||||
@method wpml
|
||||
*/
|
||||
/** Convert inline Markdown to inline WordProcessingML. */
|
||||
wpml: function(txt, inline) {
|
||||
if (!txt) {
|
||||
return '';
|
||||
|
Reference in New Issue
Block a user