From 3e7d9c04112d613e6db2b0ce7f8e329f7dd9ea20 Mon Sep 17 00:00:00 2001 From: hacksalot Date: Wed, 30 Dec 2015 12:37:26 -0500 Subject: [PATCH] Integrate JRSTheme class. --- src/core/{theme.js => fresh-theme.js} | 0 src/gen/template-generator.js | 27 ++++++++++++++++++--------- src/hackmyapi.js | 3 ++- src/verbs/generate.js | 6 +++++- 4 files changed, 25 insertions(+), 11 deletions(-) rename src/core/{theme.js => fresh-theme.js} (100%) diff --git a/src/core/theme.js b/src/core/fresh-theme.js similarity index 100% rename from src/core/theme.js rename to src/core/fresh-theme.js diff --git a/src/gen/template-generator.js b/src/gen/template-generator.js index 60a7a6f..20c3ea6 100644 --- a/src/gen/template-generator.js +++ b/src/gen/template-generator.js @@ -17,7 +17,8 @@ Definition of the TemplateGenerator class. , MKDIRP = require('mkdirp') , BaseGenerator = require( './base-generator' ) , EXTEND = require('../utils/extend') - , Theme = require('../core/theme'); + , FRESHTheme = require('../core/fresh-theme') + , JRSTheme = require('../core/jrs-theme'); @@ -220,20 +221,28 @@ Definition of the TemplateGenerator class. Given a theme title, load the corresponding theme. */ function themeFromMoniker() { + // Verify the specified theme name/path var tFolder = PATH.join( parsePath( require.resolve('fluent-themes') ).dirname, this.opts.theme ); - var exists = require('path-exists').sync; - if( !exists( tFolder ) ) { - tFolder = PATH.resolve( this.opts.theme ); - if( !exists( tFolder ) ) { - throw { fluenterror: this.codes.themeNotFound, data: this.opts.theme}; - } - } - var t = this.opts.themeObj || new Theme().open( tFolder ); + var t; + if( this.opts.theme.startsWith('jsonresume-theme-') ) { + console.log('LOADING JSON RESUME'); + t = new JRSTheme().open( tFolder ); + } + else { + var exists = require('path-exists').sync; + if( !exists( tFolder ) ) { + tFolder = PATH.resolve( this.opts.theme ); + if( !exists( tFolder ) ) { + throw { fluenterror: this.codes.themeNotFound, data: this.opts.theme}; + } + } + t = this.opts.themeObj || new FRESHTheme().open( tFolder ); + } // Load the theme and format return { diff --git a/src/hackmyapi.js b/src/hackmyapi.js index f36c40a..a118028 100644 --- a/src/hackmyapi.js +++ b/src/hackmyapi.js @@ -8,7 +8,8 @@ module.exports = { Sheet: require('./core/fresh-resume'), FRESHResume: require('./core/fresh-resume'), JRSResume: require('./core/jrs-resume'), - Theme: require('./core/theme'), + FRESHTheme: require('./core/fresh-theme'), + JRSTheme: require('./core/jrs-theme'), FluentDate: require('./core/fluent-date'), HtmlGenerator: require('./gen/html-generator'), TextGenerator: require('./gen/text-generator'), diff --git a/src/verbs/generate.js b/src/verbs/generate.js index 2291f53..344a9ba 100644 --- a/src/verbs/generate.js +++ b/src/verbs/generate.js @@ -6,10 +6,12 @@ , MD = require('marked') , MKDIRP = require('mkdirp') , _opts = require('../core/default-options') - , FluentTheme = require('../core/theme') + , FluentTheme = require('../core/fresh-theme') + , JRSTheme = require('../core/jrs-theme') , ResumeFactory = require('../core/resume-factory') , _ = require('underscore') , _fmts = require('../core/default-formats') + , unused = require('string.prototype.startswith') , _err, _log, rez; /** @@ -51,6 +53,8 @@ // Load the theme var theTheme = (new FluentTheme()).open( tFolder ); + var theTheme = _opts.theme.startsWith('jsonresume-theme') ? + new JRSTheme().open(tFolder) : new FluentTheme().open( tFolder ); _opts.themeObj = theTheme; var numFormats = theTheme.formats ? Object.keys(theTheme.formats).length : 2; _log( 'Applying '.info + theTheme.name.toUpperCase().infoBold +