1
0
mirror of https://github.com/JuanCanham/HackMyResume.git synced 2024-11-22 08:20:11 +00:00

More MEGADESK.

This commit is contained in:
devlinjd 2015-12-09 00:13:58 -05:00
parent f3c9f92263
commit 857de65750
3 changed files with 35 additions and 16 deletions

View File

@ -57,6 +57,12 @@ Definition of the FRESHResume class.
return this;
}
FreshResume.prototype.dupe = function() {
var rnew = new FreshResume();
rnew.parse( this.stringify(), { } );
return rnew;
};
/**
Convert the supplied object to a JSON string, sanitizing meta-properties along
the way.
@ -77,30 +83,42 @@ Definition of the FRESHResume class.
FreshResume.prototype.markdownify = function() {
var that = this;
var ret = extend(true, { }, this);
var ret = this.dupe();
function MDIN(txt){
return MD(txt || '' ).replace(/^\s*\<p\>|\<\/p\>\s*$/gi, '');
}
// TODO: refactor recursion
function markdownifyStringsInObject( obj ) {
function markdownifyStringsInObject( obj, inline ) {
if( !obj ) return;
inline = inline === undefined || inline;
if( Object.prototype.toString.call( obj ) === '[object Array]' ) {
obj.forEach(function(elem){
obj.forEach(function(elem, idx, ar){
if( typeof elem === 'string' || elem instanceof String )
ar[idx] = inline ? MDIN(elem) : MD( elem );
else
markdownifyStringsInObject( elem );
});
}
else if (typeof obj === 'object') {
if( obj._isAMomentObject || obj.safe )
return;
Object.keys( obj ).forEach(function(key) {
var sub = obj[key];
if( typeof sub === 'string' || sub instanceof String )
obj[key] = MD( obj[key] );
if( typeof sub === 'string' || sub instanceof String ) {
if( key !== 'url' )
obj[key] = inline ? MDIN( obj[key] ) : MD( obj[key] );
}
else
markdownifyStringsInObject( sub );
});
}
}
Object.keys( ret ).forEach(function(member){
markdownifyStringsInObject( that[ member ] );
markdownifyStringsInObject( ret[ member ] );
});
return ret;
@ -191,7 +209,8 @@ Definition of the FRESHResume class.
Get the default (empty) sheet.
*/
FreshResume.default = function() {
return new FreshResume().open( PATH.join( __dirname, 'empty-fresh.json'), 'Empty' );
return new FreshResume().open(
PATH.join( __dirname, 'empty-fresh.json'), 'Empty' );
}
/**

View File

@ -140,6 +140,7 @@ Abstract theme representation.
var idx = _.findIndex(fmts, function( fmt ) {
return fmt.pre === cssf.pre && fmt.ext === 'html'
});
cssf.action = null;
fmts[ idx ].css = cssf.data;
fmts[ idx ].cssPath = cssf.path;
});

View File

@ -22,12 +22,11 @@ Underscore template generate for FluentCV.
jst = jst.replace( delims.comment, '');
// Compile and run the template. TODO: avoid unnecessary recompiles.
var compiled = _.template(jst);
var mr = json.markdownify();
var ret = compiled({
r: json.markdownify(),
filt: opts.filters,
XML: require('xml-escape'),
RAW: json,
cssInfo: cssInfo,
headFragment: opts.headFragment || ''
});