mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2024-11-25 01:40:10 +00:00
fix: resolve issues around @@@@ characters in dates
Simplify resume freezing; avoid transformations on foreign fields. Fixes #198 but needs followup to allow users to specify how and when freezing, encoding, and transformations occur.
This commit is contained in:
parent
8dca5b76e7
commit
8c81a54565
40
dist/core/jrs-resume.js
vendored
40
dist/core/jrs-resume.js
vendored
@ -285,7 +285,7 @@ Definition of the JRSResume class.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
JRSResume.prototype.harden = function() {
|
JRSResume.prototype.harden = function() {
|
||||||
var HD, HDIN, hardenStringsInObject, ret, that;
|
var HD, HDIN, ret, that, transformer;
|
||||||
that = this;
|
that = this;
|
||||||
ret = this.dupe();
|
ret = this.dupe();
|
||||||
HD = function(txt) {
|
HD = function(txt) {
|
||||||
@ -294,42 +294,10 @@ Definition of the JRSResume class.
|
|||||||
HDIN = function(txt) {
|
HDIN = function(txt) {
|
||||||
return HD(txt);
|
return HD(txt);
|
||||||
};
|
};
|
||||||
hardenStringsInObject = function(obj, inline) {
|
transformer = require('../utils/string-transformer');
|
||||||
if (!obj) {
|
return transformer(ret, ['skills', 'url', 'website', 'startDate', 'endDate', 'releaseDate', 'date', 'phone', 'email', 'address', 'postalCode', 'city', 'country', 'region', 'safeStartDate', 'safeEndDate'], function(key, val) {
|
||||||
return;
|
return HD(val);
|
||||||
}
|
|
||||||
inline = inline === void 0 || inline;
|
|
||||||
if (Object.prototype.toString.call(obj) === '[object Array]') {
|
|
||||||
return obj.forEach(function(elem, idx, ar) {
|
|
||||||
if (typeof elem === 'string' || elem instanceof String) {
|
|
||||||
return ar[idx] = inline ? HDIN(elem) : HD(elem);
|
|
||||||
} else {
|
|
||||||
return hardenStringsInObject(elem);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
} else if (typeof obj === 'object') {
|
|
||||||
return Object.keys(obj).forEach(function(key) {
|
|
||||||
var sub;
|
|
||||||
sub = obj[key];
|
|
||||||
if (typeof sub === 'string' || sub instanceof String) {
|
|
||||||
if (_.contains(['skills', 'url', 'website', 'startDate', 'endDate', 'releaseDate', 'date', 'phone', 'email', 'address', 'postalCode', 'city', 'country', 'region'], key)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (key === 'summary') {
|
|
||||||
return obj[key] = HD(obj[key]);
|
|
||||||
} else {
|
|
||||||
return obj[key] = inline ? HDIN(obj[key]) : HD(obj[key]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return hardenStringsInObject(sub);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Object.keys(ret).forEach(function(member) {
|
|
||||||
return hardenStringsInObject(ret[member]);
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return JRSResume;
|
return JRSResume;
|
||||||
|
@ -242,38 +242,12 @@ class JRSResume# extends AbstractResume
|
|||||||
#return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
#return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||||
return HD txt
|
return HD txt
|
||||||
|
|
||||||
# TODO: refactor recursion
|
transformer = require '../utils/string-transformer'
|
||||||
hardenStringsInObject = ( obj, inline ) ->
|
transformer ret,
|
||||||
|
[ 'skills','url','website','startDate','endDate', 'releaseDate', 'date',
|
||||||
return if !obj
|
'phone','email','address','postalCode','city','country','region',
|
||||||
inline = inline == undefined || inline
|
'safeStartDate','safeEndDate' ],
|
||||||
|
(key, val) -> HD val
|
||||||
if Object.prototype.toString.call( obj ) == '[object Array]'
|
|
||||||
obj.forEach (elem, idx, ar) ->
|
|
||||||
if typeof elem == 'string' || elem instanceof String
|
|
||||||
ar[idx] = if inline then HDIN(elem) else HD( elem )
|
|
||||||
else
|
|
||||||
hardenStringsInObject elem
|
|
||||||
else if typeof obj == 'object'
|
|
||||||
Object.keys( obj ).forEach (key) ->
|
|
||||||
sub = obj[key]
|
|
||||||
if typeof sub == 'string' || sub instanceof String
|
|
||||||
if _.contains(['skills','url','website','startDate','endDate',
|
|
||||||
'releaseDate','date','phone','email','address','postalCode',
|
|
||||||
'city','country','region'], key)
|
|
||||||
return
|
|
||||||
if key == 'summary'
|
|
||||||
obj[key] = HD( obj[key] )
|
|
||||||
else
|
|
||||||
obj[key] = if inline then HDIN( obj[key] ) else HD( obj[key] )
|
|
||||||
else
|
|
||||||
hardenStringsInObject sub
|
|
||||||
|
|
||||||
|
|
||||||
Object.keys( ret ).forEach (member) ->
|
|
||||||
hardenStringsInObject ret[ member ]
|
|
||||||
|
|
||||||
ret
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user