jsonresume-theme-modern/index.js

52 lines
1.4 KiB
JavaScript
Raw Permalink Normal View History

2014-07-08 08:45:52 +01:00
var fs = require('fs');
var gravatar = require('gravatar');
2014-07-08 08:50:56 +01:00
var _ = require('lodash')
2014-07-08 08:49:24 +01:00
var Mustache = require('mustache');
2014-07-08 08:24:23 +01:00
function render(resumeObject) {
2014-07-08 08:45:52 +01:00
_.each(resumeObject.work, function(w){
w.startDateYear = w.startDate.substr(0,4);
if(w.endDate) {
w.endDateYear = w.endDate.substr(0,4);
} else {
w.endDateYear = 'Present'
}
});
_.each(resumeObject.education, function(e){
if( !e.area || !e.studyType ){
e.educationDetail = (e.area == null ? '' : e.area) + (e.studyType == null ? '' : e.studyType);
} else {
e.educationDetail = e.area + ", "+ e.studyType;
}
2014-07-08 08:45:52 +01:00
e.startDateYear = e.startDate.substr(0,4);
if(e.endDate) {
e.endDateYear = e.endDate.substr(0,4);
} else {
e.endDateYear = 'Present'
}
});
2014-07-31 03:38:52 +01:00
if(resumeObject.basics && resumeObject.basics.email) {
2014-09-15 12:31:02 +01:00
resumeObject.basics.gravatar = gravatar.url(resumeObject.basics.email, {
2014-07-08 08:45:52 +01:00
s: '100',
r: 'pg',
d: 'mm'
});
}
2014-07-31 05:02:34 +01:00
resumeObject.profiles = {};
2014-07-08 08:45:52 +01:00
2014-07-31 05:02:34 +01:00
_.each(resumeObject.basics.profiles, function(profile){
resumeObject.profiles[profile.network] = profile.username;
});
console.log(resumeObject.profiles);
2014-07-08 08:48:16 +01:00
var theme = fs.readFileSync(__dirname + '/resume.template', 'utf8');
2014-07-08 08:45:52 +01:00
var resumeHTML = Mustache.render(theme, resumeObject);
2014-07-08 08:52:15 +01:00
return resumeHTML;
2014-07-08 05:44:13 +01:00
};
module.exports = {
2014-07-08 08:24:23 +01:00
render: render
}