mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-06-28 06:41:04 +01:00
Add baseline support for local generation of JSON Resume themes.
This commit is contained in:
@ -143,15 +143,12 @@ Definition of the FRESHResume class.
|
||||
};
|
||||
|
||||
/**
|
||||
Open and parse the specified JSON resume sheet. Merge the JSON object model
|
||||
onto this Sheet instance with extend() and convert sheet dates to a safe &
|
||||
Initialize the FreshResume from JSON data.
|
||||
Open and parse the specified FRESH resume. Merge the JSON object model onto
|
||||
this Sheet instance with extend() and convert sheet dates to a safe &
|
||||
consistent format. Then sort each section by startDate descending.
|
||||
*/
|
||||
FreshResume.prototype.parse = function( stringData, opts ) {
|
||||
|
||||
// Parse the incoming JSON representation
|
||||
var rep = JSON.parse( stringData );
|
||||
|
||||
FreshResume.prototype.parseJSON = function( rep, opts ) {
|
||||
// Convert JSON Resume to FRESH if necessary
|
||||
if( rep.basics ) {
|
||||
rep = CONVERTER.toFRESH( rep );
|
||||
@ -178,6 +175,13 @@ Definition of the FRESHResume class.
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Initialize the the FreshResume from string data.
|
||||
*/
|
||||
FreshResume.prototype.parse = function( stringData, opts ) {
|
||||
return this.parseJSON( JSON.parse( stringData ), opts );
|
||||
};
|
||||
|
||||
/**
|
||||
Return a unique list of all keywords across all skills.
|
||||
*/
|
||||
|
@ -70,6 +70,7 @@ Definition of the JRSResume class.
|
||||
};
|
||||
|
||||
/**
|
||||
Initialize the JRS Resume from string data.
|
||||
Open and parse the specified JSON resume sheet. Merge the JSON object model
|
||||
onto this Sheet instance with extend() and convert sheet dates to a safe &
|
||||
consistent format. Then sort each section by startDate descending.
|
||||
@ -77,7 +78,14 @@ Definition of the JRSResume class.
|
||||
JRSResume.prototype.parse = function( stringData, opts ) {
|
||||
opts = opts || { };
|
||||
var rep = JSON.parse( stringData );
|
||||
return this.parseJSON( rep, opts );
|
||||
};
|
||||
|
||||
/**
|
||||
Initialize the JRSRume from JSON data.
|
||||
*/
|
||||
JRSResume.prototype.parseJSON = function( rep, opts ) {
|
||||
opts = opts || { };
|
||||
extend( true, this, rep );
|
||||
// Set up metadata
|
||||
if( opts.imp === undefined || opts.imp ) {
|
||||
|
@ -1,13 +0,0 @@
|
||||
(function(){
|
||||
|
||||
var FRESHResume = require('../core/fresh-resume');
|
||||
|
||||
module.exports = function loadSourceResumes( src, log, fn ) {
|
||||
return src.map( function( res ) {
|
||||
log( 'Reading '.info + 'SOURCE'.infoBold + ' resume: '.info +
|
||||
res.cyan.bold );
|
||||
return (fn && fn(res)) || (new FRESHResume()).open( res );
|
||||
});
|
||||
};
|
||||
|
||||
}());
|
43
src/core/resume-factory.js
Normal file
43
src/core/resume-factory.js
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
Core resume-loading logic for HackMyResume.
|
||||
@module resume-factory.js
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
require('string.prototype.startswith');
|
||||
var FS = require('fs');
|
||||
var ResumeConverter = require('./convert');
|
||||
|
||||
/**
|
||||
A simple factory class for FRESH and JSON Resumes.
|
||||
@class ResumeFactory
|
||||
*/
|
||||
module.exports = {
|
||||
|
||||
/**
|
||||
Load one or more resumes in a specific source format.
|
||||
*/
|
||||
load: function ( src, log, fn, toFormat ) {
|
||||
|
||||
toFormat = toFormat && (toFormat.toLowerCase().trim()) || 'fresh';
|
||||
var ResumeClass = require('../core/' + toFormat + '-resume');
|
||||
|
||||
return src.map( function( res ) {
|
||||
var rezJson = JSON.parse( FS.readFileSync( res ) );
|
||||
var orgFormat = ( rezJson.meta && rezJson.meta.format &&
|
||||
rezJson.meta.format.startsWith('FRESH@') ) ?
|
||||
'fresh' : 'jrs';
|
||||
if(orgFormat !== toFormat) {
|
||||
rezJson = ResumeConverter[ 'to' + toFormat.toUpperCase() ]( rezJson );
|
||||
}
|
||||
// TODO: Core should not log
|
||||
log( 'Reading '.info + orgFormat.toUpperCase().infoBold + ' resume: '.info + res.cyan.bold );
|
||||
return (fn && fn(res)) || (new ResumeClass()).parseJSON( rezJson );
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}());
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
Definition of the Theme class.
|
||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||
@license MIT. Copyright (c) 2015 hacksalot / FluentDesk.
|
||||
@module theme.js
|
||||
*/
|
||||
|
||||
@ -12,6 +12,7 @@ Definition of the Theme class.
|
||||
, _ = require('underscore')
|
||||
, PATH = require('path')
|
||||
, parsePath = require('parse-filepath')
|
||||
, pathExists = require('path-exists').sync
|
||||
, EXTEND = require('../utils/extend')
|
||||
, moment = require('moment')
|
||||
, RECURSIVE_READ_DIR = require('recursive-readdir-sync');
|
||||
@ -29,9 +30,26 @@ Definition of the Theme class.
|
||||
*/
|
||||
Theme.prototype.open = function( themeFolder ) {
|
||||
|
||||
// Open the [theme-name].json file; should have the same name as folder
|
||||
this.folder = themeFolder;
|
||||
|
||||
// Open the [theme-name].json file; should have the same name as folder
|
||||
var pathInfo = parsePath( themeFolder );
|
||||
|
||||
// Set up a formats hash for the theme
|
||||
var formatsHash = { };
|
||||
|
||||
// See if the theme has a package.json. If so, load it.
|
||||
var packageJsonPath = PATH.join(themeFolder, 'package.json');
|
||||
if( pathExists( packageJsonPath ) ) {
|
||||
var themePack = require( themeFolder );
|
||||
var themePkgJson = require( packageJsonPath );
|
||||
this.name = themePkgJson.name;
|
||||
this.render = (themePack && themePack.render) || undefined;
|
||||
this.formats = { html: { title: 'html', outFormat: 'html', ext: 'html', path: null, data: null } };
|
||||
return this;
|
||||
}
|
||||
|
||||
// Otherwise, do a full theme load
|
||||
var themeFile = PATH.join( themeFolder, pathInfo.basename + '.json' );
|
||||
var themeInfo = JSON.parse( FS.readFileSync( themeFile, 'utf8' ) );
|
||||
var that = this;
|
||||
@ -39,9 +57,6 @@ Definition of the Theme class.
|
||||
// Move properties from the theme JSON file to the theme object
|
||||
EXTEND( true, this, themeInfo );
|
||||
|
||||
// Set up a formats has for the theme
|
||||
var formatsHash = { };
|
||||
|
||||
// Check for an explicit "formats" entry in the theme JSON. If it has one,
|
||||
// then this theme declares its files explicitly.
|
||||
if( !!this.formats ) {
|
||||
|
Reference in New Issue
Block a user