mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-05-15 01:57:08 +01:00
Compare commits
23 Commits
Author | SHA1 | Date | |
---|---|---|---|
8cb3e8849e | |||
07a072f8d7 | |||
8a56c61d56 | |||
99722e3bd1 | |||
aa0ef4e8a4 | |||
537bd4a7b9 | |||
9bd41d5825 | |||
4cc3fd3a1f | |||
4752c3040e | |||
61c7d6b8f9 | |||
89b7ed4d5b | |||
fdfdd970a7 | |||
22bb3252cd | |||
b4907dc1b9 | |||
2c6436be5e | |||
1e44ce5e5e | |||
9de5069c20 | |||
b0b2af8278 | |||
f9c4a70ca4 | |||
1782d06b37 | |||
5dee90b8e3 | |||
090b8a271a | |||
330866a518 |
64
README.md
64
README.md
@ -1,10 +1,10 @@
|
|||||||
fluentcmd
|
fluentCV
|
||||||
=========
|
========
|
||||||
*Generate beautiful, targeted resumes from your command line or shell.*
|
*Generate beautiful, targeted resumes from your command line or shell.*
|
||||||
|
|
||||||
FluentCMD is a **hackable, data-driven, dev-friendly resume authoring tool** with support for HTML, Markdown, Word, PDF, plain text, smoke signal, carrier pigeon, and other arbitrary-format resumes and CVs.
|
FluentCV is a **hackable, data-driven, dev-friendly resume authoring tool** with support for HTML, Markdown, Word, PDF, plain text, smoke signal, carrier pigeon, and other arbitrary-format resumes and CVs.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Looking for a desktop GUI version with pretty timelines and graphs? Check out [FluentCV Desktop][7].
|
Looking for a desktop GUI version with pretty timelines and graphs? Check out [FluentCV Desktop][7].
|
||||||
|
|
||||||
@ -22,10 +22,10 @@ Looking for a desktop GUI version with pretty timelines and graphs? Check out [F
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
FluentCMD requires a recent version of [Node.js][4] and [NPM][5]. Then:
|
FluentCV requires a recent version of [Node.js][4] and [NPM][5]. Then:
|
||||||
|
|
||||||
1. (Optional, for PDF support) Install the latest official [wkhtmltopdf][3] binary for your platform.
|
1. (Optional, for PDF support) Install the latest official [wkhtmltopdf][3] binary for your platform.
|
||||||
2. Install **fluentcmd** by running `npm install fluentcmd -g`.
|
2. Install **fluentCV** by running `npm install fluentcv -g`.
|
||||||
3. You're ready to go.
|
3. You're ready to go.
|
||||||
|
|
||||||
## Use
|
## Use
|
||||||
@ -33,32 +33,32 @@ FluentCMD requires a recent version of [Node.js][4] and [NPM][5]. Then:
|
|||||||
Assuming you've got a JSON-formatted resume handy, generating resumes in different formats and combinations easy. Just run:
|
Assuming you've got a JSON-formatted resume handy, generating resumes in different formats and combinations easy. Just run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fluentcmd [inputs] [outputs] [-t theme].
|
fluentcv [inputs] [outputs] [-t theme].
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `[inputs]` is one or more .json resume files, separated by spaces; `[outputs]` is one or more destination resumes, each prefaced with the `-o` option; and `[theme]` is the desired theme. For example:
|
Where `[inputs]` is one or more .json resume files, separated by spaces; `[outputs]` is one or more destination resumes, each prefaced with the `-o` option; and `[theme]` is the desired theme. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate all resume formats (HTML, PDF, DOC, TXT, YML, etc.)
|
# Generate all resume formats (HTML, PDF, DOC, TXT, YML, etc.)
|
||||||
fluentcmd resume.json -o out/resume.all -t modern
|
fluentcv resume.json -o out/resume.all -t modern
|
||||||
|
|
||||||
# Generate a specific resume format
|
# Generate a specific resume format
|
||||||
fluentcmd resume.json -o out/resume.html
|
fluentcv resume.json -o out/resume.html
|
||||||
fluentcmd resume.json -o out/resume.pdf
|
fluentcv resume.json -o out/resume.pdf
|
||||||
fluentcmd resume.json -o out/resume.md
|
fluentcv resume.json -o out/resume.md
|
||||||
fluentcmd resume.json -o out/resume.doc
|
fluentcv resume.json -o out/resume.doc
|
||||||
fluentcmd resume.json -o out/resume.json
|
fluentcv resume.json -o out/resume.json
|
||||||
fluentcmd resume.json -o out/resume.txt
|
fluentcv resume.json -o out/resume.txt
|
||||||
fluentcmd resume.json -o out/resume.yml
|
fluentcv resume.json -o out/resume.yml
|
||||||
|
|
||||||
# Specify 2 inputs and 3 outputs
|
# Specify 2 inputs and 3 outputs
|
||||||
fluentcmd in1.json in2.json -o out.html -o out.doc -o out.pdf
|
fluentcv in1.json in2.json -o out.html -o out.doc -o out.pdf
|
||||||
```
|
```
|
||||||
|
|
||||||
You should see something to the effect of:
|
You should see something to the effect of:
|
||||||
|
|
||||||
```
|
```
|
||||||
*** FluentCMD v0.6.0 ***
|
*** FluentCV v0.7.2 ***
|
||||||
Reading JSON resume: foo/resume.json
|
Reading JSON resume: foo/resume.json
|
||||||
Applying MODERN Theme (7 formats)
|
Applying MODERN Theme (7 formats)
|
||||||
Generating HTML resume: out/resume.html
|
Generating HTML resume: out/resume.html
|
||||||
@ -77,11 +77,11 @@ Generating YAML resume: out/resume.yml
|
|||||||
You can specify a predefined or custom theme via the optional `-t` parameter. For a predefined theme, include the theme name. For a custom theme, include the path to the custom theme's folder.
|
You can specify a predefined or custom theme via the optional `-t` parameter. For a predefined theme, include the theme name. For a custom theme, include the path to the custom theme's folder.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fluentcmd resume.json -t modern
|
fluentcv resume.json -t modern
|
||||||
fluentcmd resume.json -t ~/foo/bar/my-custom-theme/
|
fluentcv resume.json -t ~/foo/bar/my-custom-theme/
|
||||||
```
|
```
|
||||||
|
|
||||||
As of v0.6.0, available predefined themes are `modern`, `minimist`, and `hello-world`.
|
As of v0.7.2, available predefined themes are `modern`, `minimist`, and `hello-world`, and `compact`.
|
||||||
|
|
||||||
### Merging resumes
|
### Merging resumes
|
||||||
|
|
||||||
@ -89,13 +89,13 @@ You can **merge multiple resumes together** by specifying them in order from mos
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Merge specific.json onto base.json and generate all formats
|
# Merge specific.json onto base.json and generate all formats
|
||||||
fluentcmd base.json specific.json -o resume.all
|
fluentcv base.json specific.json -o resume.all
|
||||||
```
|
```
|
||||||
|
|
||||||
This can be useful for overriding a base (generic) resume with information from a specific (targeted) resume. For example, you might override your generic catch-all "software developer" resume with specific details from your targeted "game developer" resume, or combine two partial resumes into a "complete" resume. Merging follows conventional [extend()][9]-style behavior and there's no arbitrary limit to how many resumes you can merge:
|
This can be useful for overriding a base (generic) resume with information from a specific (targeted) resume. For example, you might override your generic catch-all "software developer" resume with specific details from your targeted "game developer" resume, or combine two partial resumes into a "complete" resume. Merging follows conventional [extend()][9]-style behavior and there's no arbitrary limit to how many resumes you can merge:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fluentcmd in1.json in2.json in3.json in4.json -o out.html -o out.doc
|
fluentcv in1.json in2.json in3.json in4.json -o out.html -o out.doc
|
||||||
Reading JSON resume: in1.json
|
Reading JSON resume: in1.json
|
||||||
Reading JSON resume: in2.json
|
Reading JSON resume: in2.json
|
||||||
Reading JSON resume: in3.json
|
Reading JSON resume: in3.json
|
||||||
@ -107,37 +107,37 @@ Generating WORD resume: out.doc
|
|||||||
|
|
||||||
### Multiple targets
|
### Multiple targets
|
||||||
|
|
||||||
You can specify **multiple output targets** and FluentCMD will build them:
|
You can specify **multiple output targets** and FluentCV will build them:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate out1.doc, out1.pdf, and foo.txt from me.json.
|
# Generate out1.doc, out1.pdf, and foo.txt from me.json.
|
||||||
fluentcmd me.json -o out1.doc -o out1.pdf -o foo.txt
|
fluentcv me.json -o out1.doc -o out1.pdf -o foo.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also omit the output file(s) and/or theme completely:
|
You can also omit the output file(s) and/or theme completely:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Equivalent to "fluentcmd resume.json resume.all -t modern"
|
# Equivalent to "fluentcv resume.json resume.all -t modern"
|
||||||
fluentcmd resume.json
|
fluentcv resume.json
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using .all
|
### Using .all
|
||||||
|
|
||||||
The special `.all` extension tells FluentCMD to generate all supported output formats for the given resume. For example, this...
|
The special `.all` extension tells FluentCV to generate all supported output formats for the given resume. For example, this...
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate all resume formats (HTML, PDF, DOC, TXT, etc.)
|
# Generate all resume formats (HTML, PDF, DOC, TXT, etc.)
|
||||||
fluentcmd me.json -o out/resume.all
|
fluentcv me.json -o out/resume.all
|
||||||
```
|
```
|
||||||
|
|
||||||
..tells FluentCV to read `me.json` and generate `out/resume.md`, `out/resume.doc`, `out/resume.html`, `out/resume.txt`, `out/resume.pdf`, and `out/resume.json`.
|
..tells FluentCV to read `me.json` and generate `out/resume.md`, `out/resume.doc`, `out/resume.html`, `out/resume.txt`, `out/resume.pdf`, and `out/resume.json`.
|
||||||
|
|
||||||
### Prettifying
|
### Prettifying
|
||||||
|
|
||||||
FluentCMD applies [js-beautify][10]-style HTML prettification by default to HTML-formatted resumes. To disable prettification, the `--nopretty` or `-n` flag can be used:
|
FluentCV applies [js-beautify][10]-style HTML prettification by default to HTML-formatted resumes. To disable prettification, the `--nopretty` or `-n` flag can be used:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fluentcmd resume.json out.all --nopretty
|
fluentcv resume.json out.all --nopretty
|
||||||
```
|
```
|
||||||
|
|
||||||
### Silent Mode
|
### Silent Mode
|
||||||
@ -145,8 +145,8 @@ fluentcmd resume.json out.all --nopretty
|
|||||||
Use `-s` or `--silent` to run in silent mode:
|
Use `-s` or `--silent` to run in silent mode:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fluentcmd resume.json -o someFile.all -s
|
fluentcv resume.json -o someFile.all -s
|
||||||
fluentcmd resume.json -o someFile.all --silent
|
fluentcv resume.json -o someFile.all --silent
|
||||||
```
|
```
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 73 KiB |
14
package.json
14
package.json
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"name": "fluentcmd",
|
"name": "fluentcv",
|
||||||
"version": "0.6.0",
|
"version": "0.8.0",
|
||||||
"description": "Generate beautiful, targeted resumes from your command line, shell, or in Javascript with Node.js.",
|
"description": "Generate beautiful, targeted resumes from your command line, shell, or in Javascript with Node.js.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/fluentdesk/fluentcmd.git"
|
"url": "https://github.com/fluentdesk/fluentcv.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"resume",
|
"resume",
|
||||||
@ -16,15 +16,15 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"preferGlobal": "true",
|
"preferGlobal": "true",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/fluentdesk/fluentcmd/issues"
|
"url": "https://github.com/fluentdesk/fluentcv/issues"
|
||||||
},
|
},
|
||||||
"main": "src/fluentcmd.js",
|
"main": "src/fluentcmd.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"fluentcmd": "src/index.js"
|
"fluentcv": "src/index.js"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/fluentdesk/fluentcmd",
|
"homepage": "https://github.com/fluentdesk/fluentcv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fluent-themes": "0.1.0-beta",
|
"fluent-themes": "0.4.0-beta",
|
||||||
"fs-extra": "^0.24.0",
|
"fs-extra": "^0.24.0",
|
||||||
"html": "0.0.10",
|
"html": "0.0.10",
|
||||||
"is-my-json-valid": "^2.12.2",
|
"is-my-json-valid": "^2.12.2",
|
||||||
|
@ -28,7 +28,7 @@ function FluentDate( dt ) {
|
|||||||
FluentDate/*.prototype*/.fmt = function( dt ) {
|
FluentDate/*.prototype*/.fmt = function( dt ) {
|
||||||
if( (typeof dt === 'string' || dt instanceof String) ) {
|
if( (typeof dt === 'string' || dt instanceof String) ) {
|
||||||
dt = dt.toLowerCase().trim();
|
dt = dt.toLowerCase().trim();
|
||||||
if( /^(present|now)$/.test(dt) ) { // "Present", "Now"
|
if( /^(present|now|current)$/.test(dt) ) { // "Present", "Now"
|
||||||
return moment();
|
return moment();
|
||||||
}
|
}
|
||||||
else if( /^\D+\s+\d{4}$/.test(dt) ) { // "Mar 2015"
|
else if( /^\D+\s+\d{4}$/.test(dt) ) { // "Mar 2015"
|
||||||
@ -40,7 +40,7 @@ FluentDate/*.prototype*/.fmt = function( dt ) {
|
|||||||
else if( /^\d{4}-\d{1,2}$/.test(dt) ) { // "2015-03", "1998-4"
|
else if( /^\d{4}-\d{1,2}$/.test(dt) ) { // "2015-03", "1998-4"
|
||||||
return moment( dt, 'YYYY-MM' );
|
return moment( dt, 'YYYY-MM' );
|
||||||
}
|
}
|
||||||
else if( /^\s\d{4}$/.test(dt) ) { // "2015"
|
else if( /^\s*\d{4}\s*$/.test(dt) ) { // "2015"
|
||||||
return moment( dt, 'YYYY' );
|
return moment( dt, 'YYYY' );
|
||||||
}
|
}
|
||||||
else if( /^\s*$/.test(dt) ) { // "", " "
|
else if( /^\s*$/.test(dt) ) { // "", " "
|
||||||
|
@ -39,8 +39,8 @@ Abstract character/resume sheet representation.
|
|||||||
Save the sheet to disk (for environments that have disk access).
|
Save the sheet to disk (for environments that have disk access).
|
||||||
*/
|
*/
|
||||||
Sheet.prototype.save = function( filename ) {
|
Sheet.prototype.save = function( filename ) {
|
||||||
filename = filename || this.meta.fileName;
|
this.meta.fileName = filename || this.meta.fileName;
|
||||||
FS.writeFileSync( filename, this.stringify(), 'utf8' );
|
FS.writeFileSync( this.meta.fileName, this.stringify(), 'utf8' );
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ Abstract character/resume sheet representation.
|
|||||||
function replacer( key,value ) { // Exclude these keys from stringification
|
function replacer( key,value ) { // Exclude these keys from stringification
|
||||||
return _.some(['meta', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
return _.some(['meta', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||||
'isModified', 'htmlPreview'],
|
'isModified', 'htmlPreview', 'display_progress_bar'],
|
||||||
function( val ) { return key.trim() === val; }
|
function( val ) { return key.trim() === val; }
|
||||||
) ? undefined : value;
|
) ? undefined : value;
|
||||||
}
|
}
|
||||||
@ -119,6 +119,7 @@ Abstract character/resume sheet representation.
|
|||||||
delete this.publications;
|
delete this.publications;
|
||||||
delete this.interests;
|
delete this.interests;
|
||||||
delete this.skills;
|
delete this.skills;
|
||||||
|
delete this.basics.profiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,11 @@ Abstract theme representation.
|
|||||||
return friendly[val] || val;
|
return friendly[val] || val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remember the theme folder; might be custom
|
||||||
|
this.folder = themeFolder;
|
||||||
|
|
||||||
|
// Iterate over all files in the theme folder, producing an array, fmts,
|
||||||
|
// containing info for each file.
|
||||||
var tplFolder = PATH.join( themeFolder, 'templates' );
|
var tplFolder = PATH.join( themeFolder, 'templates' );
|
||||||
var fmts = FS.readdirSync( tplFolder ).map( function( file ) {
|
var fmts = FS.readdirSync( tplFolder ).map( function( file ) {
|
||||||
var absPath = PATH.join( tplFolder, file );
|
var absPath = PATH.join( tplFolder, file );
|
||||||
@ -46,20 +51,24 @@ Abstract theme representation.
|
|||||||
return temp;
|
return temp;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Freebie formats every theme gets
|
// Add freebie formats every theme gets
|
||||||
fmts.push( [ 'json', { title: 'json', pre: 'json', ext: 'json', path: null, data: null } ] );
|
fmts.push( [ 'json', { title: 'json', pre: 'json', ext: 'json', path: null, data: null } ] );
|
||||||
fmts.push( [ 'yml', { title: 'yaml', pre: 'yml', ext: 'yml', path: null, data: null } ] );
|
fmts.push( [ 'yml', { title: 'yaml', pre: 'yml', ext: 'yml', path: null, data: null } ] );
|
||||||
|
|
||||||
// Handle CSS files
|
// Now, get all the CSS files...
|
||||||
var cssFiles = fmts.filter(function( fmt ){
|
this.cssFiles = fmts.filter(function( fmt ){ return fmt[1].ext === 'css'; });
|
||||||
return fmt[1].ext === 'css';
|
|
||||||
});
|
// ...and assemble information on them
|
||||||
cssFiles.forEach(function( cssf ) {
|
this.cssFiles.forEach(function( cssf ) {
|
||||||
// For each CSS file, get its corresponding HTML file
|
// For each CSS file, get its corresponding HTML file
|
||||||
var idx = _.findIndex(fmts, function( fmt ) { return fmt[1].pre === cssf[1].pre && fmt[1].ext === 'html' });
|
var idx = _.findIndex(fmts, function( fmt ) {
|
||||||
|
return fmt[1].pre === cssf[1].pre && fmt[1].ext === 'html'
|
||||||
|
});
|
||||||
fmts[ idx ][1].css = cssf[1].data;
|
fmts[ idx ][1].css = cssf[1].data;
|
||||||
fmts[ idx ][1].cssPath = cssf[1].path;
|
fmts[ idx ][1].cssPath = cssf[1].path;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Remove CSS files from the formats array
|
||||||
fmts = fmts.filter( function( fmt) {
|
fmts = fmts.filter( function( fmt) {
|
||||||
return fmt[1].ext !== 'css';
|
return fmt[1].ext !== 'css';
|
||||||
});
|
});
|
||||||
@ -67,7 +76,9 @@ Abstract theme representation.
|
|||||||
// Create a hash out of the formats for this theme
|
// Create a hash out of the formats for this theme
|
||||||
this.formats = _.object( fmts );
|
this.formats = _.object( fmts );
|
||||||
|
|
||||||
|
// Set the official theme name
|
||||||
this.name = PATH.parse( themeFolder ).name;
|
this.name = PATH.parse( themeFolder ).name;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
Internal resume generation logic for FluentCMD.
|
Internal resume generation logic for FluentCV.
|
||||||
@license Copyright (c) 2015 | James M. Devlin
|
@license Copyright (c) 2015 | James M. Devlin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ module.exports = function () {
|
|||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Default FluentCMD options.
|
Default FluentCV options.
|
||||||
*/
|
*/
|
||||||
var _opts = {
|
var _opts = {
|
||||||
theme: 'modern',
|
theme: 'modern',
|
||||||
|
@ -6,6 +6,7 @@ Core resume generation module for FluentCV.
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
Sheet: require('./core/sheet'),
|
Sheet: require('./core/sheet'),
|
||||||
Theme: require('./core/theme'),
|
Theme: require('./core/theme'),
|
||||||
|
FluentDate: require('./core/fluent-date'),
|
||||||
HtmlGenerator: require('./gen/html-generator'),
|
HtmlGenerator: require('./gen/html-generator'),
|
||||||
TextGenerator: require('./gen/text-generator'),
|
TextGenerator: require('./gen/text-generator'),
|
||||||
HtmlPdfGenerator: require('./gen/html-pdf-generator'),
|
HtmlPdfGenerator: require('./gen/html-pdf-generator'),
|
||||||
|
@ -1,32 +1,40 @@
|
|||||||
/**
|
/**
|
||||||
HTML resume generator for FluentCV.
|
HTML resume generator for FluentCV.
|
||||||
@license Copyright (c) 2015 by James M. Devlin. All rights reserved.
|
@license Copyright (c) 2015 James M. Devlin / FluentDesk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
(function() {
|
||||||
var FS = require('fs-extra');
|
|
||||||
var HTML = require( 'html' );
|
|
||||||
|
|
||||||
var HtmlGenerator = module.exports = TemplateGenerator.extend({
|
var TemplateGenerator = require('./template-generator')
|
||||||
|
, FS = require('fs-extra')
|
||||||
|
, HTML = require( 'html' )
|
||||||
|
, PATH = require('path');
|
||||||
|
|
||||||
init: function() {
|
var HtmlGenerator = module.exports = TemplateGenerator.extend({
|
||||||
this._super( 'html' );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
init: function() {
|
||||||
Generate an HTML resume with optional pretty printing.
|
this._super( 'html' );
|
||||||
*/
|
},
|
||||||
onBeforeSave: function( mk, theme, outputFile ) {
|
|
||||||
var themeFile = theme.getFormat('html').path;
|
|
||||||
var cssSrc = themeFile.replace( /.html$/g, '.css' );
|
|
||||||
var cssDst = outputFile.replace( /.html$/g, '.css' );
|
|
||||||
var that = this;
|
|
||||||
FS.copySync( cssSrc, cssDst, { clobber: true }, function( e ) {
|
|
||||||
throw { fluenterror: that.codes.copyCss, data: [cssSrc,cssDst] };
|
|
||||||
});
|
|
||||||
|
|
||||||
return this.opts.prettify ?
|
/**
|
||||||
HTML.prettyPrint( mk, this.opts.prettify ) : mk;
|
Copy satellite CSS files to the destination and optionally pretty-print
|
||||||
}
|
the HTML resume prior to saving.
|
||||||
|
*/
|
||||||
|
onBeforeSave: function( info ) {
|
||||||
|
var cssSrc = PATH.join( info.theme.folder, 'templates', '*.css' )
|
||||||
|
, outFolder = PATH.parse( info.outputFile ).dir, that = this;
|
||||||
|
|
||||||
});
|
info.theme.cssFiles.forEach( function( f ) {
|
||||||
|
var fi = PATH.parse( f[1].path );
|
||||||
|
FS.copySync( f[1].path, PATH.join( outFolder, fi.base ), { clobber: true }, function( e ) {
|
||||||
|
throw { fluenterror: that.codes.copyCss, data: [cssSrc,cssDst] };
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.opts.prettify ?
|
||||||
|
HTML.prettyPrint( info.mk, this.opts.prettify ) : info.mk;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}());
|
||||||
|
@ -1,74 +1,71 @@
|
|||||||
/**
|
/**
|
||||||
HTML-based PDF resume generator for FluentCV.
|
Definition of the HtmlPdfGenerator class.
|
||||||
@license Copyright (c) 2015 by James M. Devlin. All rights reserved.
|
@license Copyright (c) 2015 James M. Devlin / FluentDesk
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
(function() {
|
||||||
var FS = require('fs-extra');
|
|
||||||
var HTML = require( 'html' );
|
|
||||||
|
|
||||||
var HtmlPdfGenerator = module.exports = TemplateGenerator.extend({
|
var TemplateGenerator = require('./template-generator')
|
||||||
|
, FS = require('fs-extra')
|
||||||
init: function() {
|
, HTML = require( 'html' );
|
||||||
this._super( 'pdf', 'html' );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Generate an HTML resume with optional pretty printing.
|
An HTML-based PDF resume generator for FluentCV.
|
||||||
TODO: Avoid copying the CSS file to dest if we don't need to.
|
|
||||||
*/
|
*/
|
||||||
onBeforeSave: function( mk, themeFile, outputFile ) {
|
var HtmlPdfGenerator = module.exports = TemplateGenerator.extend({
|
||||||
// var cssSrc = themeFile.replace( /pdf\.html$/gi, 'html.css' );
|
|
||||||
// var cssDst = outputFile.replace( /\.pdf$/gi, '.css' );
|
|
||||||
// var that = this;
|
|
||||||
// FS.copySync( cssSrc, cssDst, { clobber: true }, function( e ) {
|
|
||||||
// if( e ) that.err( "Couldn't copy CSS file to destination: " + e);
|
|
||||||
// });
|
|
||||||
// return true ?
|
|
||||||
// HTML.prettyPrint( mk, { indent_size: 2 } ) : mk;
|
|
||||||
|
|
||||||
pdf(mk, outputFile);
|
init: function() {
|
||||||
return mk;
|
this._super( 'pdf', 'html' );
|
||||||
}
|
},
|
||||||
|
|
||||||
});
|
/**
|
||||||
|
Generate the binary PDF.
|
||||||
/**
|
*/
|
||||||
Generate a PDF from HTML.
|
onBeforeSave: function( info ) {
|
||||||
*/
|
pdf(info.mk, info.outputFile);
|
||||||
function pdf( markup, fOut ) {
|
return info.mk;
|
||||||
|
|
||||||
var pdfCount = 0;
|
|
||||||
if( false ) { //( _opts.pdf === 'phantom' || _opts.pdf == 'all' ) {
|
|
||||||
pdfCount++;
|
|
||||||
require('phantom').create( function( ph ) {
|
|
||||||
ph.createPage( function( page ) {
|
|
||||||
page.setContent( markup );
|
|
||||||
page.set('paperSize', {
|
|
||||||
format: 'A4',
|
|
||||||
orientation: 'portrait',
|
|
||||||
margin: '1cm'
|
|
||||||
});
|
|
||||||
page.set("viewportSize", {
|
|
||||||
width: 1024, // TODO: option-ify
|
|
||||||
height: 768 // TODO: Use "A" sizes
|
|
||||||
});
|
|
||||||
page.set('onLoadFinished', function(success) {
|
|
||||||
page.render( fOut );
|
|
||||||
pdfCount++;
|
|
||||||
ph.exit();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{ dnodeOpts: { weak: false } } );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if( true ) { // _opts.pdf === 'wkhtmltopdf' || _opts.pdf == 'all' ) {
|
|
||||||
var fOut2 = fOut;
|
|
||||||
if( pdfCount == 1 ) {
|
|
||||||
fOut2 = fOut2.replace(/\.pdf$/g, '.b.pdf');
|
|
||||||
}
|
}
|
||||||
require('wkhtmltopdf')( markup, { pageSize: 'letter' } )
|
|
||||||
.pipe( FS.createWriteStream( fOut2 ) );
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generate a PDF from HTML.
|
||||||
|
*/
|
||||||
|
function pdf( markup, fOut ) {
|
||||||
|
|
||||||
|
var pdfCount = 0;
|
||||||
|
if( false ) { //( _opts.pdf === 'phantom' || _opts.pdf == 'all' ) {
|
||||||
pdfCount++;
|
pdfCount++;
|
||||||
|
require('phantom').create( function( ph ) {
|
||||||
|
ph.createPage( function( page ) {
|
||||||
|
page.setContent( markup );
|
||||||
|
page.set('paperSize', {
|
||||||
|
format: 'A4',
|
||||||
|
orientation: 'portrait',
|
||||||
|
margin: '1cm'
|
||||||
|
});
|
||||||
|
page.set("viewportSize", {
|
||||||
|
width: 1024, // TODO: option-ify
|
||||||
|
height: 768 // TODO: Use "A" sizes
|
||||||
|
});
|
||||||
|
page.set('onLoadFinished', function(success) {
|
||||||
|
page.render( fOut );
|
||||||
|
pdfCount++;
|
||||||
|
ph.exit();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
{ dnodeOpts: { weak: false } } );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if( true ) { // _opts.pdf === 'wkhtmltopdf' || _opts.pdf == 'all' ) {
|
||||||
|
var fOut2 = fOut;
|
||||||
|
if( pdfCount == 1 ) {
|
||||||
|
fOut2 = fOut2.replace(/\.pdf$/g, '.b.pdf');
|
||||||
|
}
|
||||||
|
require('wkhtmltopdf')( markup, { pageSize: 'letter' } )
|
||||||
|
.pipe( FS.createWriteStream( fOut2 ) );
|
||||||
|
pdfCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
}());
|
||||||
|
@ -35,7 +35,7 @@ var _defaultOpts = {
|
|||||||
},
|
},
|
||||||
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
||||||
indent_size: 2,
|
indent_size: 2,
|
||||||
unformatted: ['em','strong'],
|
unformatted: ['em','strong','a'],
|
||||||
max_char: 80, // ← See lib/html.js in above-linked repo
|
max_char: 80, // ← See lib/html.js in above-linked repo
|
||||||
//wrap_line_length: 120, <-- Don't use this
|
//wrap_line_length: 120, <-- Don't use this
|
||||||
}
|
}
|
||||||
@ -89,11 +89,11 @@ var TemplateGenerator = module.exports = BaseGenerator.extend({
|
|||||||
// Load theme and CSS data
|
// Load theme and CSS data
|
||||||
var tplFolder = PATH.join( tFolder, 'templates' );
|
var tplFolder = PATH.join( tFolder, 'templates' );
|
||||||
var curFmt = theme.getFormat( this.format );
|
var curFmt = theme.getFormat( this.format );
|
||||||
var ctx = { file: curFmt.css ? curFmt.cssPath : null, data: curFmt.css || null };
|
var cssInfo = { file: curFmt.css ? curFmt.cssPath : null, data: curFmt.css || null };
|
||||||
|
|
||||||
// Compile and invoke the template!
|
// Compile and invoke the template!
|
||||||
var mk = this.single( rez, curFmt.data, this.format, ctx, opts );
|
var mk = this.single( rez, curFmt.data, this.format, cssInfo, opts );
|
||||||
this.onBeforeSave && (mk = this.onBeforeSave( mk, theme, f ));
|
this.onBeforeSave && (mk = this.onBeforeSave( { mk: mk, theme: theme, outputFile: f } ));
|
||||||
FS.writeFileSync( f, mk, { encoding: 'utf8', flags: 'w' } );
|
FS.writeFileSync( f, mk, { encoding: 'utf8', flags: 'w' } );
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#! /usr/bin/env node
|
#! /usr/bin/env node
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Command-line interface (CLI) for FluentCMD via Node.js.
|
Command-line interface (CLI) for FluentCV via Node.js.
|
||||||
@license Copyright (c) 2015 | James M. Devlin
|
@license Copyright (c) 2015 | James M. Devlin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ catch( ex ) {
|
|||||||
function main() {
|
function main() {
|
||||||
|
|
||||||
// Setup.
|
// Setup.
|
||||||
var title = '*** FluentCMD v' + PKG.version + ' ***';
|
var title = '*** FluentCV v' + PKG.version + ' ***';
|
||||||
if( process.argv.length <= 2 ) { logMsg(title); throw { fluenterror: 3 }; }
|
if( process.argv.length <= 2 ) { logMsg(title); throw { fluenterror: 3 }; }
|
||||||
var args = ARGS( process.argv.slice(2) );
|
var args = ARGS( process.argv.slice(2) );
|
||||||
opts = getOpts( args );
|
opts = getOpts( args );
|
||||||
@ -37,8 +37,6 @@ function main() {
|
|||||||
|
|
||||||
// Generate!
|
// Generate!
|
||||||
FCMD.generate( src, dst, opts, logMsg );
|
FCMD.generate( src, dst, opts, logMsg );
|
||||||
|
|
||||||
process.exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function logMsg( msg ) {
|
function logMsg( msg ) {
|
||||||
|
Reference in New Issue
Block a user