mirror of
https://github.com/JuanCanham/HackMyResume.git
synced 2025-04-19 22:30:26 +01:00
Compare commits
366 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ab6e7ee1a0 | ||
|
8cccd2ffbb | ||
|
c6efdeca05 | ||
|
42d249b407 | ||
|
8a46d642e5 | ||
|
b7cd01597e | ||
|
73c5674af8 | ||
|
b077ff42e4 | ||
|
1bc3485812 | ||
|
7597eda198 | ||
|
3badb46ae4 | ||
|
30affe351d | ||
|
407f9f8cd7 | ||
|
922c1968ca | ||
|
093a2c6a56 | ||
|
031b666b0a | ||
|
033b29fd3a | ||
|
c4f7350528 | ||
|
7144126175 | ||
|
a5739f337f | ||
|
98f20c368c | ||
|
2281b4ea7f | ||
|
7196bff27c | ||
|
7cfdb95a04 | ||
|
58fe46dc83 | ||
|
17e5c6c172 | ||
|
ea3c72845e | ||
|
06805578a2 | ||
|
20815d7eff | ||
|
8648befcdd | ||
|
c08c5f0fa3 | ||
|
38a073b09a | ||
|
2346562428 | ||
|
2bf5bb72cf | ||
|
7262578c81 | ||
|
66f3cb15c9 | ||
|
6f07141b0d | ||
|
dc88073bcc | ||
|
8c81a54565 | ||
|
8dca5b76e7 | ||
|
2767b16b47 | ||
|
f1343add71 | ||
|
81d9d5f157 | ||
|
caca653666 | ||
|
55196c2766 | ||
|
00067d012a | ||
|
9da69c3310 | ||
|
02f0af1ff8 | ||
|
b1515fc656 | ||
|
ba719166f7 | ||
|
db6ec47dcc | ||
|
f53c316ecb | ||
|
e889481ad8 | ||
|
2b31f5bb58 | ||
|
7912ec9ef5 | ||
|
e6e0b135ed | ||
|
54d056c4b7 | ||
|
157a2a6145 | ||
|
688767d415 | ||
|
1dbb78c53f | ||
|
9c096541ce | ||
|
5161a3a823 | ||
|
76a386c9df | ||
|
7d78deec5f | ||
|
a265fb633d | ||
|
069506e86d | ||
|
7f656175f0 | ||
|
94fc54174c | ||
|
231357badc | ||
|
fde2146a0b | ||
|
c6adab7f9e | ||
|
7f7c936897 | ||
|
a9e35203c2 | ||
|
c913de4bf7 | ||
|
6b125ed907 | ||
|
17259cedbf | ||
|
12a14dadeb | ||
|
35fb2f5dac | ||
|
097e81caf8 | ||
|
6adf195281 | ||
|
79c304a08b | ||
|
394d5cf821 | ||
|
6092f985f2 | ||
|
2c26c21144 | ||
|
6bd0b817af | ||
|
97fe171775 | ||
|
9718c652ab | ||
|
9aad6d6138 | ||
|
d25f8d0f97 | ||
|
d2d9039abb | ||
|
3dc6ff2158 | ||
|
36f5f46753 | ||
|
8cc6334cd1 | ||
|
b7ef40709e | ||
|
efe97ad793 | ||
|
a243354044 | ||
|
92c477e139 | ||
|
ec591b9432 | ||
|
419c935d82 | ||
|
d31f6caf50 | ||
|
7e2a3c3e7e | ||
|
406d3358eb | ||
|
98ef625d7b | ||
|
be8a7a8361 | ||
|
37720677f0 | ||
|
0cd59416b8 | ||
|
abdeeb4385 | ||
|
bb7944bee7 | ||
|
9de1156144 | ||
|
9ae2703eeb | ||
|
a3ed56dd15 | ||
|
214c53a3ab | ||
|
ba6b8d45f5 | ||
|
3c166a21a0 | ||
|
fe46d15031 | ||
|
664eea752f | ||
|
fed59b704e | ||
|
3cf850ea0e | ||
|
1b0bc87b60 | ||
|
5d3b993737 | ||
|
917fd8e3f3 | ||
|
6ac2cd490b | ||
|
8100190978 | ||
|
7c36ff8331 | ||
|
255a518565 | ||
|
2d595350c6 | ||
|
ca92d41d9e | ||
|
3f8e795c61 | ||
|
9927e79900 | ||
|
dbef9f0a35 | ||
|
c889664c31 | ||
|
7a60cd0bab | ||
|
964350d3c7 | ||
|
b57d9f05af | ||
|
b26799f9fc | ||
|
daeffd27b5 | ||
|
f87eb46549 | ||
|
da7cd28734 | ||
|
31e0bb69cc | ||
|
5c248cca2a | ||
|
f83eb018e8 | ||
|
317a250917 | ||
|
aaa5e1fc1f | ||
|
1bc4263a46 | ||
|
e191af1fb0 | ||
|
7c0a9bcc02 | ||
|
d894f62607 | ||
|
2758038858 | ||
|
661fb91861 | ||
|
3c551eb923 | ||
|
5bf4bda6de | ||
|
49ae016f08 | ||
|
89957aed76 | ||
|
233025ddcc | ||
|
11dd8952d8 | ||
|
d7c83613df | ||
|
a456093f13 | ||
|
dd4851498a | ||
|
f72b02a0f4 | ||
|
63a0c78fc5 | ||
|
fd39cc9fd9 | ||
|
70f45d468d | ||
|
212b01092c | ||
|
36d641801b | ||
|
bd278268f6 | ||
|
abe31e30e0 | ||
|
314d8d8763 | ||
|
ed0792e8f8 | ||
|
90765bf90b | ||
|
f1ba7765ee | ||
|
27c7a0264a | ||
|
8e806dc04f | ||
|
8ec6b5ed6a | ||
|
4ef4ec5d42 | ||
|
2f523b845b | ||
|
1c416f39d3 | ||
|
1de0eff7b3 | ||
|
f8a39b0908 | ||
|
d69e4635be | ||
|
4b7d594502 | ||
|
896b7055c1 | ||
|
0f65e4c9f3 | ||
|
e9971eb882 | ||
|
beb60d4074 | ||
|
4440d23584 | ||
|
aca67cec29 | ||
|
75a953aa73 | ||
|
15a0af8410 | ||
|
9f811336e4 | ||
|
a07faf6d50 | ||
|
f098ed507f | ||
|
80c36b96bc | ||
|
630cf59cfb | ||
|
165eb5d9cd | ||
|
d12e970af5 | ||
|
cf18c5d90d | ||
|
0497696dcf | ||
|
d007bd9bf6 | ||
|
5838b085c7 | ||
|
58b6ad841e | ||
|
fc937e3ec8 | ||
|
8652c7ecdf | ||
|
c882235eff | ||
|
d6c5239f9e | ||
|
4b2db3f720 | ||
|
9736777828 | ||
|
d3194fba19 | ||
|
fa29f9794d | ||
|
07915002bb | ||
|
fbcc06dcda | ||
|
7413a3a257 | ||
|
e6d2255291 | ||
|
2840ec3f87 | ||
|
05cd863ebf | ||
|
20961afb62 | ||
|
1256095e25 | ||
|
f073c79b8d | ||
|
ac9e4aa1a0 | ||
|
915f35b1e6 | ||
|
4fe74057f9 | ||
|
5a1ec033bb | ||
|
6801e39f97 | ||
|
f6f383751f | ||
|
43ed564a6e | ||
|
7b3364c356 | ||
|
58a7fc09e5 | ||
|
01c053702d | ||
|
a935fe7dc2 | ||
|
c9825fa016 | ||
|
9eb9207348 | ||
|
6b171e69db | ||
|
5b0ee89e34 | ||
|
8bd3ddc7fd | ||
|
984ae95576 | ||
|
f77cced7f3 | ||
|
57787f1bc7 | ||
|
9419f905df | ||
|
001fd893c1 | ||
|
babe4b4b31 | ||
|
201f39442e | ||
|
47f6aff561 | ||
|
cef9a92cb6 | ||
|
2253e4ead7 | ||
|
2f628f8564 | ||
|
23cd52885b | ||
|
181419ae28 | ||
|
a81ad0fef2 | ||
|
d220cedfeb | ||
|
e72564162b | ||
|
c98d05270e | ||
|
3e3803ed85 | ||
|
c8d8e566f8 | ||
|
712cba57b8 | ||
|
c9e45d4991 | ||
|
e9edc0d15c | ||
|
b99a09c88a | ||
|
5c95fe7af1 | ||
|
17f2ebb753 | ||
|
fc67f680ee | ||
|
88879257e6 | ||
|
fff45e1431 | ||
|
934d8a6123 | ||
|
defe9b6e95 | ||
|
4c5ccc001a | ||
|
de5c2ecb95 | ||
|
dbb95aef3a | ||
|
c9ae2ffef3 | ||
|
86af2a2c4f | ||
|
37ea6cf804 | ||
|
a9c685c6a4 | ||
|
7765e85336 | ||
|
7af50c51f6 | ||
|
19b30d55ec | ||
|
eddda8146e | ||
|
1a0b91a58f | ||
|
1b94ada709 | ||
|
1966b0a862 | ||
|
8ced6a730a | ||
|
6cd1e60e79 | ||
|
be691e4230 | ||
|
07b23109f9 | ||
|
32769a2b0b | ||
|
280977cb62 | ||
|
ddceec68a2 | ||
|
b961fd1c07 | ||
|
342b960f63 | ||
|
f965bf456a | ||
|
69be38110f | ||
|
3800e19418 | ||
|
e29ed58a1c | ||
|
11bfcd4bef | ||
|
fbc2e9a4db | ||
|
7814786957 | ||
|
542776fd2e | ||
|
815ee3dc7e | ||
|
376e720f4b | ||
|
b224c8939b | ||
|
0ecac98cff | ||
|
1416f57d0b | ||
|
65c7e41c53 | ||
|
c8cc673ad5 | ||
|
656dbe2fc2 | ||
|
a4ee7127ee | ||
|
fee21a7b17 | ||
|
32fd8dc636 | ||
|
2c8f444d42 | ||
|
bd8b587c5b | ||
|
4c954b79df | ||
|
b7fffbcf73 | ||
|
0829800b65 | ||
|
d7cfc76636 | ||
|
311030474d | ||
|
ec69e668ff | ||
|
f18910f490 | ||
|
540ad48d61 | ||
|
540c745069 | ||
|
c5b8eec33a | ||
|
bece335a64 | ||
|
3aabb5028d | ||
|
732bc9809a | ||
|
d77b484e55 | ||
|
43564bf380 | ||
|
88c71f6e9c | ||
|
47e8605f50 | ||
|
9466a8c0dd | ||
|
d878270bc6 | ||
|
3b38c4818f | ||
|
62c967526f | ||
|
6e5a44798b | ||
|
1fbfe2507b | ||
|
d6a3aab68a | ||
|
9fdfd1b5a6 | ||
|
f4e763bd9c | ||
|
fbfff2a4e4 | ||
|
1c93932737 | ||
|
cba29511bc | ||
|
1d655a4ddb | ||
|
ca94513630 | ||
|
971d4a5439 | ||
|
f3dcbd9081 | ||
|
29c53af843 | ||
|
8d24087faa | ||
|
95df8e5af4 | ||
|
8a1da777b0 | ||
|
44555da00f | ||
|
46bd5d51cc | ||
|
3964d300aa | ||
|
d6280e6d89 | ||
|
4a2a47f551 | ||
|
ae51930c9c | ||
|
fb33455bea | ||
|
28c703daf7 | ||
|
0246a5da19 | ||
|
840d17c67b | ||
|
9f22e94cf7 | ||
|
97ebecd84a | ||
|
96b9bb68e3 | ||
|
c5a5d3761d | ||
|
c147403b1c | ||
|
a2723452c2 | ||
|
cb3488276d | ||
|
43419c27cf | ||
|
0f0c399dd5 | ||
|
cb46497346 | ||
|
850c640368 | ||
|
60e455b36d |
17
.eslintrc.yml
Normal file
17
.eslintrc.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
env:
|
||||||
|
es6: true
|
||||||
|
node: true
|
||||||
|
extends: 'eslint:recommended'
|
||||||
|
rules:
|
||||||
|
# indent:
|
||||||
|
# - error
|
||||||
|
# - 4
|
||||||
|
linebreak-style:
|
||||||
|
- error
|
||||||
|
- unix
|
||||||
|
quotes:
|
||||||
|
- error
|
||||||
|
- single
|
||||||
|
semi:
|
||||||
|
- error
|
||||||
|
- always
|
6
.gitattributes
vendored
6
.gitattributes
vendored
@ -1,9 +1,11 @@
|
|||||||
# Auto detect text files and perform LF normalization
|
# Auto detect text files and perform LF normalization
|
||||||
|
|
||||||
* text=auto
|
* text=auto
|
||||||
*.js text eol=lf
|
*.js text eol=lf
|
||||||
*.json text eol=lf
|
*.json text eol=lf
|
||||||
|
|
||||||
# Standard to msysgit
|
# Standard to msysgit
|
||||||
|
|
||||||
*.doc diff=astextplain
|
*.doc diff=astextplain
|
||||||
*.DOC diff=astextplain
|
*.DOC diff=astextplain
|
||||||
*.docx diff=astextplain
|
*.docx diff=astextplain
|
||||||
@ -14,3 +16,7 @@
|
|||||||
*.PDF diff=astextplain
|
*.PDF diff=astextplain
|
||||||
*.rtf diff=astextplain
|
*.rtf diff=astextplain
|
||||||
*.RTF diff=astextplain
|
*.RTF diff=astextplain
|
||||||
|
|
||||||
|
# Git LFS
|
||||||
|
|
||||||
|
*.ai filter=lfs diff=lfs merge=lfs -text
|
||||||
|
38
.gitignore
vendored
38
.gitignore
vendored
@ -1,4 +1,40 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
tests/sandbox/
|
doc/
|
||||||
docs/
|
docs/
|
||||||
|
local/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
*.map
|
||||||
|
|
||||||
|
# Emacs detritus
|
||||||
|
# -*- mode: gitignore; -*-
|
||||||
|
*~
|
||||||
|
\#*\#
|
||||||
|
/.emacs.desktop
|
||||||
|
/.emacs.desktop.lock
|
||||||
|
*.elc
|
||||||
|
auto-save-list
|
||||||
|
tramp
|
||||||
|
.\#*
|
||||||
|
|
||||||
|
# Org-mode
|
||||||
|
.org-id-locations
|
||||||
|
*_archive
|
||||||
|
|
||||||
|
# flymake-mode
|
||||||
|
*_flymake.*
|
||||||
|
|
||||||
|
# eshell files
|
||||||
|
/eshell/history
|
||||||
|
/eshell/lastdir
|
||||||
|
|
||||||
|
# elpa packages
|
||||||
|
/elpa/
|
||||||
|
|
||||||
|
# reftex files
|
||||||
|
*.rel
|
||||||
|
|
||||||
|
# AUCTeX auto folder
|
||||||
|
/auto/
|
||||||
|
|
||||||
|
# cask packages
|
||||||
|
.cask/
|
||||||
|
13
.npmignore
Normal file
13
.npmignore
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
assets/
|
||||||
|
test/
|
||||||
|
doc/
|
||||||
|
.travis.yml
|
||||||
|
.eslintrc.yml
|
||||||
|
Gruntfile.js
|
||||||
|
.gitattributes
|
||||||
|
ROADMAP.md
|
||||||
|
BUILDING.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
CHANGELOG.md
|
||||||
|
FAQ.md
|
||||||
|
*.map
|
28
.travis.yml
28
.travis.yml
@ -1,9 +1,23 @@
|
|||||||
|
sudo: required
|
||||||
|
before_install:
|
||||||
|
# Prevents a shared object .so error when running wkhtmltopdf on certain
|
||||||
|
# platforms (e.g., vanilla Ubuntu 16.04 LTS). Not necessary on current Travis.
|
||||||
|
# - sudo apt-get install libxrender1
|
||||||
|
install:
|
||||||
|
# Install & link HackMyResume
|
||||||
|
- npm install && npm link
|
||||||
|
# Download and extract the latest wkhtmltopdf binaries
|
||||||
|
- mkdir tmp && wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz -O tmp/wk.tar.xz
|
||||||
|
- tar -xf tmp/wk.tar.xz -C ./tmp
|
||||||
|
# Copy wkhtmltopdf binaries to /usr/bin (also makes them path-accessible)
|
||||||
|
- sudo cp -R ./tmp/wkhtmltox/bin/* /usr/bin/
|
||||||
|
# Now you can invoke "wkhtmltopdf" and "wkhtmltoimage" safely in tests.
|
||||||
|
- wkhtmltopdf -V
|
||||||
|
- wkhtmltoimage -V
|
||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "0.10"
|
- "6"
|
||||||
- "0.11"
|
- "7"
|
||||||
- "0.12"
|
- "8"
|
||||||
- "4.0"
|
- "9"
|
||||||
- "4.1"
|
- "lts/*"
|
||||||
- "4.2"
|
|
||||||
- "5.0"
|
|
||||||
|
50
BUILDING.md
Normal file
50
BUILDING.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
Building
|
||||||
|
========
|
||||||
|
|
||||||
|
*See [CONTRIBUTING.md][contrib] for more information on contributing to the
|
||||||
|
HackMyResume or FluentCV projects.*
|
||||||
|
|
||||||
|
HackMyResume is a standard Node.js command line app implemented in a mix of
|
||||||
|
CoffeeScript and JavaScript. Setting up a build environment is easy:
|
||||||
|
|
||||||
|
|
||||||
|
## Prerequisites ##
|
||||||
|
|
||||||
|
1. OS: Linux, OS X, or Windows
|
||||||
|
|
||||||
|
2. Install [Node.js][node] and [Grunt][grunt].
|
||||||
|
|
||||||
|
|
||||||
|
## Set up a build environment ###
|
||||||
|
|
||||||
|
1. Fork [hacksalot/HackMyResume][hmr] to your GitHub account.
|
||||||
|
|
||||||
|
2. Clone your fork locally.
|
||||||
|
|
||||||
|
3. From within the top-level HackMyResume folder, run `npm install` to install
|
||||||
|
project dependencies.
|
||||||
|
|
||||||
|
4. Create a new branch, based on the latest HackMyResume `dev` branch, to
|
||||||
|
contain your work.
|
||||||
|
|
||||||
|
5. Run `npm link` in the HackMyResume folder so that the `hackmyresume` command
|
||||||
|
will reference your local installation (you may need to
|
||||||
|
`npm uninstall -g hackmyresume` first).
|
||||||
|
|
||||||
|
## Making changes
|
||||||
|
|
||||||
|
1. HackMyResume sources live in the [`/src`][src] folder.
|
||||||
|
|
||||||
|
2. When you're ready to submit your changes, run `grunt test` to run the HMR
|
||||||
|
test suite. Fix any errors that occur.
|
||||||
|
|
||||||
|
3. Commit and push your changes.
|
||||||
|
|
||||||
|
4. Submit a pull request targeting the HackMyResume `dev` branch.
|
||||||
|
|
||||||
|
|
||||||
|
[node]: https://nodejs.org/en/
|
||||||
|
[grunt]: http://gruntjs.com/
|
||||||
|
[hmr]: https://github.com/hacksalot/HackMyResume
|
||||||
|
[src]: https://github.com/hacksalot/HackMyResume/tree/master/src
|
||||||
|
[contrib]: https://github.com/hacksalot/HackMyResume/blob/master/CONTRIBUTING.md
|
503
CHANGELOG.md
Normal file
503
CHANGELOG.md
Normal file
@ -0,0 +1,503 @@
|
|||||||
|
CHANGELOG
|
||||||
|
=========
|
||||||
|
|
||||||
|
## v1.9.0-beta
|
||||||
|
|
||||||
|
*Welcome to the first new version of HackMyResume in over a year. The purpose of
|
||||||
|
this release is to gather feature enhancements and bug fixes collected over the
|
||||||
|
past 18 months as we reorganize, rebrand, and prepare for the 2.0 release.*
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support for **private resume fields**. Mark any non-leaf node in your resume
|
||||||
|
JSON with the `private` property and it will be omitted from outbound resumes.
|
||||||
|
|
||||||
|
```json
|
||||||
|
"employment": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"employer": "Acme Real Estate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"employer": "Area 51 Alien Research Laboratory",
|
||||||
|
"private": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"employer": "H&R Block"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
- Support for **PDF generation through WeasyPrint** in addition to the
|
||||||
|
existing support for wkhtmltopdf and PhantomJS.
|
||||||
|
|
||||||
|
- Theme authors can now develop and package **custom Handlebars theme helpers**
|
||||||
|
via the `helpers` key of the `theme.json` file (FRESH themes only) (#158).
|
||||||
|
|
||||||
|
- Help system has been updated with a `HELP` command and dedicated help pages
|
||||||
|
for each command.
|
||||||
|
|
||||||
|
- Theme authors can **relocate theme assets** with the `baseFolder` property in
|
||||||
|
the FRESH `theme.json`.
|
||||||
|
|
||||||
|
- HackMyResume will now **validate the options file** (if any) loaded with `-o`
|
||||||
|
or `--options` and warn the user if necessary.
|
||||||
|
|
||||||
|
- Ability to **disable Handlebars encoding/escaping** of resume fields with
|
||||||
|
`--no-escape`.
|
||||||
|
|
||||||
|
- Introduced the [fresh-test-themes][ftt] project as a repository for simple,
|
||||||
|
test-only resume themes in the FRESH format.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Dropped support for Node 4 and 5. HackMyResume officially runs on Node 6+.
|
||||||
|
|
||||||
|
- The FRESCA project has been renamed to [fresh-resume-schema][fresca]. FRESCA
|
||||||
|
is still the nickname.
|
||||||
|
|
||||||
|
- The HackMyResume web page has moved to https://fluentdesk.com/hackmyresume.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue that would cause the `convert` command to detect the inbound
|
||||||
|
resume type (FRESH or JRS) incorrectly (#162).
|
||||||
|
|
||||||
|
- Fixed an issue where generating new JRS resumes would cause a `null` or
|
||||||
|
`undefined` error (#165).
|
||||||
|
|
||||||
|
- Fixed an issue preventing mixed-case themes from being loaded (#172).
|
||||||
|
|
||||||
|
- Fixed an issue requiring JSON Resume themes contain `json-resume-theme` in the
|
||||||
|
theme path (#173).
|
||||||
|
|
||||||
|
- Fixed an issue that would cause strange `@@@@` characters to appear in
|
||||||
|
generated resumes (#207, #168, #198).
|
||||||
|
|
||||||
|
- Fixed an issue that would cause resume generation to hang after a JSON Resume
|
||||||
|
themed resume was generated (#182).
|
||||||
|
|
||||||
|
- Fixed an issue that would cause nothing to be generated for Markdown (.md)
|
||||||
|
formats (#179).
|
||||||
|
|
||||||
|
- Fixed an issue that would prevent a JRS resume from being converted to FRESH
|
||||||
|
via the `convert` command (#180).
|
||||||
|
|
||||||
|
- Fixed an issue that would cause broken styling for JSON Resume themes (#155).
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- Tests: fixed resume duration tests (#181).
|
||||||
|
|
||||||
|
- Style: move to
|
||||||
|
|
||||||
|
## v1.8.0
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Updated `Awesome` theme to latest version of [Awesome-CV][acv].
|
||||||
|
|
||||||
|
- Introduced new theme helpers: `pad`, `date`.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue where the `Awesome` theme wouldn't correctly generate LaTeX
|
||||||
|
outputs (#138).
|
||||||
|
|
||||||
|
- Emit a line number for syntax errors around embedded newlines in JSON strings
|
||||||
|
(#137).
|
||||||
|
|
||||||
|
- Fix several PDF / PNG generation errors (#132, others).
|
||||||
|
|
||||||
|
- Display a more helpful error message when attempting to generate a PDF or PNG
|
||||||
|
on a machine where PhantomJS and/or wkhtmltopdf are either not installed or
|
||||||
|
not path-accessible.
|
||||||
|
|
||||||
|
- Fixed an issue that would cause long-running PDF/PNG generation to fail in
|
||||||
|
certain environments.
|
||||||
|
|
||||||
|
- Fixed an issue involving an unhelpful spawn-related exception (#136).
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- JSHint will no longer gripe at the use of `== null` and `!= null` in
|
||||||
|
CoffeeScript transpilation.
|
||||||
|
|
||||||
|
- Introduced [template-friendly Awesome-CV fork][awefork] to isolate template
|
||||||
|
expansion logic & provide better durability for HackMyResume's `awesome` theme.
|
||||||
|
|
||||||
|
- Fixed a couple temporary regressions (#139, #140) on the dev branch.
|
||||||
|
|
||||||
|
- Additional tests.
|
||||||
|
|
||||||
|
- Minor breaking HackMyResume API changes.
|
||||||
|
|
||||||
|
## v1.7.4
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- [Build instructions](https://github.com/hacksalot/HackMyResume/blob/master/BUILDING.md).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- More precise date handling.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Issue with incomplete PDF generation (#127).
|
||||||
|
|
||||||
|
- Issue with building JSON Resume themes (#128).
|
||||||
|
|
||||||
|
- Issue with generating `.json` output format by itself (#97).
|
||||||
|
|
||||||
|
## v1.7.3
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Issue with generated PDFs being chopped off and displaying a mysterious sequence of numbers of unknown and possibly alien origin (#127).
|
||||||
|
|
||||||
|
- Unsightly border on Modern:PDF.
|
||||||
|
|
||||||
|
- Modern|Positive:PDF formats now correctly reference their PDF-specific CSS files.
|
||||||
|
|
||||||
|
- `Incorrect helper use` warning in Positive:DOC.
|
||||||
|
|
||||||
|
## v1.7.2
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Interim release supporting FluentCV Desktop.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- Moved [HackMyCore](https://github.com/hacksalot/HackMyCore) dependency to
|
||||||
|
submodule.
|
||||||
|
|
||||||
|
## v1.7.1
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Caffeinate. CoffeeScript now used throughout
|
||||||
|
[HackMyResume](https://github.com/hacksalot/HackMyResume) and
|
||||||
|
[HackMyCore](https://github.com/hacksalot/HackMyCore); generated JavaScript
|
||||||
|
lives in `/dist`.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Issue with generating a single PDF with the `.pdf` extension (#99).
|
||||||
|
|
||||||
|
## v1.7.0
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- [Internal] Relocated HMR processing code to the
|
||||||
|
[HackMyCore](https://github.com/hacksalot/HackMyCore) project. Shouldn't affect
|
||||||
|
normal use.
|
||||||
|
|
||||||
|
## v1.6.0
|
||||||
|
|
||||||
|
### Major Improvements
|
||||||
|
|
||||||
|
- Better consistency and coverage for all FRESH resumes and themes ([#45][i45]).
|
||||||
|
|
||||||
|
- Initial support for overridable fonts in FRESH themes. Like a particular
|
||||||
|
theme, but want to change the typography? The specific fonts used by a theme
|
||||||
|
can now be overridden by the user. (FRESH themes only).
|
||||||
|
|
||||||
|
- New resume sections! Support for `projects` and `affiliation` resume sections
|
||||||
|
for technical and creative projects and memberships / clubs / associations,
|
||||||
|
respectively ([#92][i92]).
|
||||||
|
|
||||||
|
- New command! `PEEK` at any arbitrary field or entry on your `.json` resume.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Improved handling of start and end dates on `employment`, `projects`,
|
||||||
|
`education`, and other sections with start/end dates.
|
||||||
|
|
||||||
|
- Support for an `.ignore` property on any FRESH or JSON Resume section or field.
|
||||||
|
Ignored properties will be treated by HackMyResume as if they weren't present.
|
||||||
|
|
||||||
|
- Emit extended status and error info with the `--debug` or `-d` switch.
|
||||||
|
|
||||||
|
- The `-o` or `--options` switch can now handle either the path to a **JSON
|
||||||
|
settings file** or **raw JSON/JavaScript**. Since the JSON double quote syntax
|
||||||
|
is a bit cumbersome from the command line, HackMyResume accepts regular
|
||||||
|
JavaScript object literal syntax:
|
||||||
|
|
||||||
|
hackmyresume build resume.json -o "{ theme: 'compact', silent: 'true' }"
|
||||||
|
|
||||||
|
- Ability to disable sorting of resume sections (employments, projects, etc.)
|
||||||
|
with the `--no-sort` option. HMR will respect the order of items as they appear
|
||||||
|
in your resume `.json` file.
|
||||||
|
|
||||||
|
- Improvements to the starter resume emitted by `hackmyresume new`.
|
||||||
|
|
||||||
|
- Theme Authoring: Annotated the HTML and MS Word (XML) formats of the Modern
|
||||||
|
theme for FRESH theme authors.
|
||||||
|
|
||||||
|
- Theme Authoring: Support for templatized CSS files in FRESH themes. CSS files
|
||||||
|
are now expanded via Handlebars or Underscore prior to copying to the
|
||||||
|
destination.
|
||||||
|
|
||||||
|
- Added CHANGELOG.md (this file).
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Rewrote the HackMyResume man/help page.
|
||||||
|
|
||||||
|
- Minor incremental updates to the [FRESCA][fresca] schema.
|
||||||
|
|
||||||
|
- PDF generation now uses asynchronous `spawn()` which has better compatibility
|
||||||
|
with old or boutique versions of Node.js.
|
||||||
|
|
||||||
|
- Refactored colors in HackMyResume output. Errors will now display as red,
|
||||||
|
warnings as yellow, successful operations as green, and informational messages
|
||||||
|
as cyan.
|
||||||
|
|
||||||
|
- Theme messages and usage tips will no longer display during resume generation
|
||||||
|
by default. Use the `--tips` option to view them.
|
||||||
|
|
||||||
|
- The `--no-tips` option (default: false) has been replaced with the `--tips`
|
||||||
|
option, also defaulting to false.
|
||||||
|
|
||||||
|
- Removed the `hello-world` theme from the [prebuilt themes][themes] that ship
|
||||||
|
with HackMyResume. It can be installed separately from NPM:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install fresh-theme-hello-world
|
||||||
|
hackmyresume resume.json -t node_modules/fresh-theme-hello-world
|
||||||
|
```
|
||||||
|
|
||||||
|
- sd
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- PDF generation issues on older versions of Node.
|
||||||
|
|
||||||
|
- Stack traces not being emitted correctly.
|
||||||
|
|
||||||
|
- Missing `speaking` section will now appear on generated resumes ([#101][i101]).
|
||||||
|
|
||||||
|
- Incomplete `education` details will now appear on generated resumes ([#65][i65]).
|
||||||
|
|
||||||
|
- Missing employment end date being interpreted as "employment ends today"
|
||||||
|
([#84][i84]).
|
||||||
|
|
||||||
|
- Merging multiple source resumes during `BUILD` sometimes fails.
|
||||||
|
|
||||||
|
- Document `--pdf` flag in README ([#111][i111]).
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- Logging messages have been moved out of core HackMyResume code ahead of
|
||||||
|
localization support.
|
||||||
|
|
||||||
|
- All HackMyResume console output is described in `msg.yml`.
|
||||||
|
|
||||||
|
- Relaxed pure JavaScript requirement. CoffeeScript will now start appearing
|
||||||
|
in HackMyResume and FluentCV sources!
|
||||||
|
|
||||||
|
- Additional tests.
|
||||||
|
|
||||||
|
## v1.5.2
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Tweak stack trace under `--debug`.
|
||||||
|
|
||||||
|
## v1.5.1
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Preliminary support for `-d` or `--debug` flag. Forces HackMyResume to emit a stack trace under error conditions.
|
||||||
|
|
||||||
|
## v1.5.0
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- HackMyResume now supports **CLI-based generation of PDF formats across multiple engines (Phantom, wkhtmltopdf, etc)**. Instead of talking to these engines over a programmatic API, as in prior versions, HackMyResume 1.5+ speaks to them over the same command-line interface (CLI) you'd use if you were using these tools directly.
|
||||||
|
|
||||||
|
- HackMyResume will now (attempt to) **generate a PDF output for JSON Resume themes** (in addition to HTML).
|
||||||
|
|
||||||
|
- Minor README and FAQ additions.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Cleaner, quicker installs**. Installing HackMyResume with `npm install hackmyresume -g` will no longer trigger a lengthy, potentially error-prone install for Phantom.js and/or wkhtmltopdf for PDF support. Instead, users can install these engines externally and HMR will use them when present.
|
||||||
|
|
||||||
|
- Minor error handling improvements.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an error with generating specific formats with the `BUILD` command (#97).
|
||||||
|
|
||||||
|
- Fixed numerous latent/undocumented bugs and glitches.
|
||||||
|
|
||||||
|
## v1.4.2
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Introduced [FAQ](https://github.com/hacksalot/HackMyResume/blob/master/FAQ.md).
|
||||||
|
- Additional README notes.
|
||||||
|
|
||||||
|
## v1.4.1
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- `hackmyresume new` now generates a [valid starter resume with sample data](https://github.com/fluentdesk/fresh-resume-starter).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed warning message when `hackmyresume new` is run without a filename.
|
||||||
|
|
||||||
|
## v1.4.0
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **"Projects" support**: FRESH resumes and themes can now store and display
|
||||||
|
open source, commercial, private, personal, and creative projects.
|
||||||
|
- **New command: ANALYZE**. Inspect your resume for gaps, keyword counts, and other metrics. (Experimental.)
|
||||||
|
- **Side-by-side PDF generation** with Phantom and wkhtmltopdf. Use the `--pdf` or `-p` flag to pick between `phantom` and `wkhtmltopdf` generation.
|
||||||
|
- **Disable PDF generation** with the `--pdf none` switch.
|
||||||
|
- **Inherit formats between themes**. Themes can now inherit formats (Word, HTML, .txt, etc.) from other themes. (FRESH themes only.)
|
||||||
|
- **Rename resume sections** to different languages or wordings.
|
||||||
|
- **Specify complex options via external file**. Use with the `-o` or `--opts` option.
|
||||||
|
- **Disable colors** with the `--no-color` flag.
|
||||||
|
- **Theme messages and usage tips** instructions will now appear in the default HackMyResume output for the `build` command. Run `hackmyresume build resume.json -t awesome` for an example. Turn off with the `--no-tips` flag.
|
||||||
|
- **Treat validation errors as warnings** with the `--assert` switch (VALIDATE command only).
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed a minor glitch in the FRESCA schema.
|
||||||
|
- Fixed encoding issues in the `Highlights` section of certain resumes.
|
||||||
|
- Fix behavior of `-s` and `--silent` flags.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- PDF generation now defaults to Phantom for all platforms, with `wkhtmltopdf`
|
||||||
|
accessible with `--pdf wkhtmltopdf`.
|
||||||
|
- Resumes are now validated, by default, prior to generation. This
|
||||||
|
behavior can be disabled with the `--novalidate` or `--force` switch.
|
||||||
|
- Syntax errors in source FRESH and JSON Resumes are now captured for all
|
||||||
|
commands.
|
||||||
|
- Minor updates to README.
|
||||||
|
- Most themes now inherit Markdown and Plain Text formats from the **Basis**
|
||||||
|
theme.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- Switched from color to chalk.
|
||||||
|
- Command invocations now handled through commander.js.
|
||||||
|
- Improved FRESH theme infrastructure (more partials, more DRY).
|
||||||
|
|
||||||
|
## v1.3.1
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Add additional Travis badges.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix extraneous console log output when generating a FRESH theme to MS Word.
|
||||||
|
- Fix Travis tests on `dev`.
|
||||||
|
|
||||||
|
## v1.3.0
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- **Local generation of JSON Resume themes**. To use a JSON Resume theme, first install it with `npm install jsonresume-theme-[blah]` (most JSON Resume themes are on NPM). Then pass it into HackMyResume via the `-t` parameter:
|
||||||
|
|
||||||
|
`hackmyresume BUILD resume.json TO out/somefile.all -t node_modules/jsonresume-theme-classy`
|
||||||
|
- **Better Markdown support.** HackMyResume will start flowing basic Markdown styles to JSON Resume (HTML) themes. FRESH's existing Markdown support has also been improved.
|
||||||
|
- **.PNG output formats** will start appearing in themes that declare an HTML output.
|
||||||
|
- **Tweak CSS embedding / linking via the --css option** (`<style></style>` vs `<link>`). Only works for HTML (or HTML-driven) formats of FRESH themes. Use `--css=link` to link in CSS assets and `--css=embed` to embed the styles in the HTML document. For example `hackmyresume BUILD resume.json TO out/resume.all --css=link`.
|
||||||
|
- **Improved Handlebars/Underscore helper support** for FRESH themes. Handlebars themes can access helpers via `{{helperName}}`. Underscore themes can access helpers via the `h` object.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- **Distinguish between validation errors and syntax errors** when validating a FRESH or JRS resume with `hackmyresume validate <blah>`.
|
||||||
|
- **Emit line and column info** for syntax errors during validation of FRESH and JRS resumes.
|
||||||
|
- **FRESH themes now embed CSS into HTML formats by default** so that the HTML resume output doesn't have an external CSS file dependency by default. Users can specify normal linked stylesheets by setting `--css=link`.
|
||||||
|
- **Renamed fluent-themes repo to fresh-themes** in keeping with the other parts of the project.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix various encoding errors in MS Word outputs.
|
||||||
|
- Fix assorted FRESH-to-JRS and JRS-to-FRESH conversion glitches.
|
||||||
|
- Fix error when running HMR with no parameters.
|
||||||
|
- Other minor fixes.
|
||||||
|
|
||||||
|
## v1.3.0-beta
|
||||||
|
|
||||||
|
- Numerous changes supporting v1.3.0.
|
||||||
|
|
||||||
|
## v1.2.2
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Various in-passing fixes.
|
||||||
|
|
||||||
|
## v1.2.1
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fix `require('FRESCA')` error.
|
||||||
|
- Fix `.history` and `.map` errors on loading incomplete or empty JRS resumes.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Better test coverage of incomplete/empty resumes.
|
||||||
|
|
||||||
|
## v1.2.0
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed the `new` command: Generate a new FRESH-format resume with `hackmyresume new resume.json` or a new JSON Resume with `hackmyresume new resume.json -f jrs`.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Introduced CLI tests.
|
||||||
|
|
||||||
|
## v1.1.0
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- MS Word formats: Fixed skill coloring/level bug.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Make the `TO` keyword optional. If no `TO` keyword is specified (for the `build` and `convert` commands), HMR will assume the last file passed in is the desired output file. So these are equivalent:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
hackmyresume BUILD resume.json TO out/resume.all
|
||||||
|
hackmyresume BUILD resume.json out/resume.all
|
||||||
|
```
|
||||||
|
|
||||||
|
`TO` only needs to be included if you have multipled output files:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
hackmyresume BUILD resume.json TO out1.doc out2.html out3.tex
|
||||||
|
```
|
||||||
|
|
||||||
|
## v1.0.1
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Correctly generate MS Word hyperlinks from Markdown source data.
|
||||||
|
|
||||||
|
## v1.0.0
|
||||||
|
|
||||||
|
- Initial public 1.0 release.
|
||||||
|
|
||||||
|
[i45]: https://github.com/hacksalot/HackMyResume/issues/45
|
||||||
|
[i65]: https://github.com/hacksalot/HackMyResume/issues/65
|
||||||
|
[i84]: https://github.com/hacksalot/HackMyResume/issues/84
|
||||||
|
[i92]: https://github.com/hacksalot/HackMyResume/issues/92
|
||||||
|
[i101]: https://github.com/hacksalot/HackMyResume/issues/101
|
||||||
|
[i111]: https://github.com/hacksalot/HackMyResume/issues/111
|
||||||
|
[fresca]: https://github.com/fresh-standard/fresh-resume-schema
|
||||||
|
[themes]: https://github.com/fresh-standard/fresh-themes
|
||||||
|
[awefork]: https://github.com/fluentdesk/Awesome-CV
|
||||||
|
[acv]: https://github.com/posquit0/Awesome-CV
|
||||||
|
[ftt]: https://github.com/fresh-standard/fresh-test-themes
|
@ -4,17 +4,11 @@ Contributing
|
|||||||
*Note: HackMyResume is also available as [FluentCV][fcv]. Contributors are
|
*Note: HackMyResume is also available as [FluentCV][fcv]. Contributors are
|
||||||
credited in both.*
|
credited in both.*
|
||||||
|
|
||||||
HackMyResume needs your help! Our contribution workflow is based on [GitHub
|
|
||||||
Flow][flow] and we respond to all pull requests and issues, usually within 24
|
|
||||||
hours. HackMyResume has no corporate affiliation and no commercial basis, which
|
|
||||||
allows the project to maintain a strict user-first policy, rapid development
|
|
||||||
velocity, and a liberal stance on contributions and exotic functionality in
|
|
||||||
keeping with the spirit (and name) of the tool.
|
|
||||||
|
|
||||||
In short, your code is welcome here.
|
|
||||||
|
|
||||||
## How To Contribute
|
## How To Contribute
|
||||||
|
|
||||||
|
*See [BUILDING.md][building] for instructions on setting up a HackMyResume
|
||||||
|
development environment.*
|
||||||
|
|
||||||
1. Optional: [**open an issue**][iss] identifying the feature or bug you'd like
|
1. Optional: [**open an issue**][iss] identifying the feature or bug you'd like
|
||||||
to implement or fix. This step isn't required — you can start hacking away on
|
to implement or fix. This step isn't required — you can start hacking away on
|
||||||
HackMyResume without clearing it with us — but helps avoid duplication of work
|
HackMyResume without clearing it with us — but helps avoid duplication of work
|
||||||
@ -25,7 +19,7 @@ similar; call it whatever you like) to perform your work in.
|
|||||||
4. **Install dependencies** by running `npm install` in the top-level
|
4. **Install dependencies** by running `npm install` in the top-level
|
||||||
HackMyResume folder.
|
HackMyResume folder.
|
||||||
5. Make your **commits** as usual.
|
5. Make your **commits** as usual.
|
||||||
6. **Verify** your changes locally with `npm test`.
|
6. **Verify** your changes locally with `grunt test`.
|
||||||
7. **Push** your commits.
|
7. **Push** your commits.
|
||||||
7. **Submit a pull request** from your feature branch to the HackMyResume `dev`
|
7. **Submit a pull request** from your feature branch to the HackMyResume `dev`
|
||||||
branch.
|
branch.
|
||||||
@ -39,7 +33,7 @@ HackMyResume is currently maintained by [hacksalot][ha] with assistance from
|
|||||||
or internal inquiries to:
|
or internal inquiries to:
|
||||||
|
|
||||||
```
|
```
|
||||||
admin@hackmyresume.com
|
admin@fluentdesk.com
|
||||||
```
|
```
|
||||||
|
|
||||||
You can reach hacksalot directly at:
|
You can reach hacksalot directly at:
|
||||||
@ -48,7 +42,7 @@ You can reach hacksalot directly at:
|
|||||||
hacksalot@indevious.com
|
hacksalot@indevious.com
|
||||||
```
|
```
|
||||||
|
|
||||||
Thanks! See you out there in the trenches.
|
Thanks for your interest in the HackMyResume project.
|
||||||
|
|
||||||
[fcv]: https://github.com/fluentdesk/fluentcv
|
[fcv]: https://github.com/fluentdesk/fluentcv
|
||||||
[flow]: https://guides.github.com/introduction/flow/
|
[flow]: https://guides.github.com/introduction/flow/
|
||||||
@ -56,3 +50,4 @@ Thanks! See you out there in the trenches.
|
|||||||
[ha]: https://github.com/hacksalot
|
[ha]: https://github.com/hacksalot
|
||||||
[th]: https://github.com/tomheon
|
[th]: https://github.com/tomheon
|
||||||
[awesome]: https://github.com/hacksalot/HackMyResume/graphs/contributors
|
[awesome]: https://github.com/hacksalot/HackMyResume/graphs/contributors
|
||||||
|
[building]: https://github.com/hacksalot/HackMyResume/blob/master/BUILDING.md
|
||||||
|
159
FAQ.md
159
FAQ.md
@ -9,19 +9,29 @@ Frequently Asked Questions (FAQ)
|
|||||||
|
|
||||||
3. Test with `hackmyresume BUILD <resume-name>.json`. Look in the `out/` folder.
|
3. Test with `hackmyresume BUILD <resume-name>.json`. Look in the `out/` folder.
|
||||||
|
|
||||||
4. Play around with different themes with the `-t` or `--theme` parameter. You can use any [FRESH](https://github.com/fluentdesk/fresh-themes) or [JSON Resume](https://jsonresume.org/themes) theme. The latter have to be installed first.
|
4. Play around with different themes with the `-t` or `--theme` parameter.
|
||||||
|
You can use any [FRESH](https://github.com/fluentdesk/fresh-themes) or
|
||||||
|
[JSON Resume](https://jsonresume.org/themes) theme. The latter have to be
|
||||||
|
installed first.
|
||||||
|
|
||||||
## What is FRESH?
|
## What is FRESH?
|
||||||
|
|
||||||
FRESH is the **F**luent **R**esume and **E**mployment **S**ystem for **H**umans. It's an open-source, user-first workflow, schema, and set of practices for technical candidates and recruiters.
|
FRESH is the **F**luent **R**esume and **E**mployment **S**ystem for **H**umans.
|
||||||
|
It's an open-source, user-first workflow, schema, and set of practices for
|
||||||
|
technical candidates and recruiters.
|
||||||
|
|
||||||
## What is FRESCA?
|
## What is FRESCA?
|
||||||
|
|
||||||
The **F**RESH **R**esume and **E**mployment **SC**hem**A**—an open-source, JSON-driven schema for resumes, CVs, and other employment artifacts. FRESCA is the recommended schema/format for FRESH, with optional support for JSON Resume.
|
The **F**RESH **R**esume and **E**mployment **SC**hem**A**—an open-source,
|
||||||
|
JSON-driven schema for resumes, CVs, and other employment artifacts. FRESCA is
|
||||||
|
the recommended schema/format for FRESH, with optional support for JSON Resume.
|
||||||
|
|
||||||
## What is JSON Resume?
|
## What is JSON Resume?
|
||||||
|
|
||||||
An [open resume standard](http://jsonresume.org/themes/) sponsored by Hired.com. Like FRESCA, JSON Resume is JSON-driven and open-source. Unlike FRESCA, JSON Resume targets a worldwide audience where FRESCA is optimized for technical candidates.
|
An [open resume standard](http://jsonresume.org/themes/) sponsored by Hired.com.
|
||||||
|
Like FRESCA, JSON Resume is JSON-driven and open-source. Unlike FRESCA, JSON
|
||||||
|
Resume targets a worldwide audience where FRESCA is optimized for technical
|
||||||
|
candidates.
|
||||||
|
|
||||||
## Should I use the FRESH or JSON Resume format/schema for my resume?
|
## Should I use the FRESH or JSON Resume format/schema for my resume?
|
||||||
|
|
||||||
@ -31,24 +41,45 @@ Both! The workflow we like to use:
|
|||||||
2. Convert it to JSON Resume format for additional themes/tools.
|
2. Convert it to JSON Resume format for additional themes/tools.
|
||||||
3. Maintain both versions.
|
3. Maintain both versions.
|
||||||
|
|
||||||
Both formats are open-source and both formats are JSON-driven. FRESH was designed as a universal container format and superset of existing formats, where the JSON Resume format is intended for a generic audience.
|
Both formats are open-source and both formats are JSON-driven. FRESH was
|
||||||
|
designed as a universal container format and superset of existing formats, where
|
||||||
|
the JSON Resume format is intended for a generic audience.
|
||||||
|
|
||||||
## How do I use a FRESH theme?
|
## How do I use a FRESH theme?
|
||||||
|
|
||||||
FRESH themes currently come preinstalled with HackMyResume.
|
Several FRESH themes come preinstalled with HackMyResume; others can be
|
||||||
|
installed from NPM and GitHub.
|
||||||
|
|
||||||
1. Specify the theme name in the `--theme` or `-t` parameter to the **build** command:
|
### To use a preinstalled FRESH theme:
|
||||||
|
|
||||||
|
1. Pass the theme name into HackMyResume via the `--theme` or `-t` parameter:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD my-resume.json --theme <theme-name>`
|
hackmyresume build resume.json --theme compact
|
||||||
```
|
```
|
||||||
|
|
||||||
`<theme-name>` can be one of `positive`, `compact`, `modern`, `minimist`, `hello-world`, or `awesome`.
|
### To use an external FRESH theme:
|
||||||
|
|
||||||
2. Check your output folder. Although under FRESH, HTML formats are hardened to a degree for local file access, it's best to view HTML formats over a local web server connection.
|
1. Install the theme locally. The easiest way to do that is with NPM.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install fresh-theme-underscore
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Pass the theme folder into HackMyResume:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume BUILD resume.json --theme node_modules/fresh-theme-underscore
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Check your output folder. It's best to view HTML formats over a local web
|
||||||
|
server connection.
|
||||||
|
|
||||||
## How do I use a JSON Resume theme?
|
## How do I use a JSON Resume theme?
|
||||||
|
|
||||||
|
JSON Resume (JRS) themes can be installed from NPM and GitHub and passed into
|
||||||
|
HackMyResume via the `--theme` or `-t` parameter.
|
||||||
|
|
||||||
1. Install the theme locally. The easiest way to do that is with NPM.
|
1. Install the theme locally. The easiest way to do that is with NPM.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -61,15 +92,19 @@ FRESH themes currently come preinstalled with HackMyResume.
|
|||||||
hackmyresume BUILD resume.json --theme node_modules/jsonresume-theme-classy
|
hackmyresume BUILD resume.json --theme node_modules/jsonresume-theme-classy
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Check your output folder. It's best to view HTML formats over a local web server connection.
|
3. Check your output folder. It's best to view HTML formats over a local web
|
||||||
|
server connection.
|
||||||
|
|
||||||
## Should I keep my resume in version control?
|
## Should I keep my resume in version control?
|
||||||
|
|
||||||
Absolutely! As text-based, JSON-driven documents, both FRESH and JSON Resume are ideal candidates for version control. Future versions of HackMyResume will have this functionality built-in.
|
Absolutely! As text-based, JSON-driven documents, both FRESH and JSON Resume are
|
||||||
|
ideal candidates for version control. Future versions of HackMyResume will have
|
||||||
|
this functionality built in.
|
||||||
|
|
||||||
## Can I change the default section titles ("Employment", "Skills", etc.)?
|
## Can I change the default section titles ("Employment", "Skills", etc.)?
|
||||||
|
|
||||||
If you're using a FRESH theme, yes. First, create a HackMyResume options file mapping resume sections to your preferred section title:
|
If you're using a FRESH theme, yes. First, create a HackMyResume options file
|
||||||
|
mapping resume sections to your preferred section title:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
// myoptions.json
|
// myoptions.json
|
||||||
@ -90,8 +125,104 @@ hackmyresume BUILD resume.json -o myoptions.json
|
|||||||
|
|
||||||
This ability is currently only supported for FRESH resume themes.
|
This ability is currently only supported for FRESH resume themes.
|
||||||
|
|
||||||
## The HackMyResume terminal color scheme is giving me a headache! Can I disable it?
|
## How does resume merging work?
|
||||||
|
|
||||||
|
Resume merging is a way of storing your resume in separate files that
|
||||||
|
HackMyResume will merge into a single "master" resume file prior to generating
|
||||||
|
specific output formats like HTML or PDF. It's a way of producing flexible,
|
||||||
|
configurable, targeted resumes with minimal duplication.
|
||||||
|
|
||||||
|
For example, a software developer who moonlights as a game programmer might
|
||||||
|
create three FRESH or JRS resumes at different levels of specificity:
|
||||||
|
|
||||||
|
- **generic.json**: A generic technical resume, suitable for all audiences.
|
||||||
|
- **game-developer.json**: Overrides and amendments for game developer
|
||||||
|
positions.
|
||||||
|
- **blizzard.json**: Overrides and amendments specific to a hypothetical
|
||||||
|
position at Blizzard.
|
||||||
|
|
||||||
|
If you run `hackmyresume BUILD generic.json TO out/resume.all`, HMR will
|
||||||
|
generate all available output formats for the `generic.json` as usual. But if
|
||||||
|
you instead run...
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume BUILD generic.json game-developer.json TO out/resume.all
|
||||||
|
```
|
||||||
|
|
||||||
|
...HackMyResume will notice that multiple source resumes were specified and
|
||||||
|
merge `game-developer.json` onto `generic.json` before generating, yielding a
|
||||||
|
resume that's more suitable for game-developer-related positions.
|
||||||
|
|
||||||
|
You can take this a step further. Let's say you want to do a targeted resume
|
||||||
|
submission to a game developer position at Blizzard, and `blizzard.json`
|
||||||
|
contains the edits and revisions you'd like to show up in the targeted resume.
|
||||||
|
In that case, merge again! Feed all three resumes to HackMyResume, in order
|
||||||
|
from most generic to most specific, and HMR will merge them all prior to
|
||||||
|
generating the final output format(s) for your resume.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Merge blizzard.json onto game-developer.json onto generic.json, then build
|
||||||
|
hackmyresume BUILD generic.json game-developer.json blizzard.json TO out/resume.all
|
||||||
|
```
|
||||||
|
|
||||||
|
There's no limit to the number of resumes you can merge this way.
|
||||||
|
|
||||||
|
You can also divide your resume into files containing different sections:
|
||||||
|
|
||||||
|
- **resume-a.json**: Contains `info`, `employment`, and `summary` sections.
|
||||||
|
- **resume-b.json**: Contains all other sections except `references`.
|
||||||
|
- **references.json**: Contains the private `references` section.
|
||||||
|
|
||||||
|
Under that scenario, `hackmyresume BUILD resume-a.json resume-b.json` would
|
||||||
|
|
||||||
|
|
||||||
|
## The HackMyResume terminal color scheme is giving me a headache. Can I disable it?
|
||||||
|
|
||||||
Yes. Use the `--no-color` option to disable terminal colors:
|
Yes. Use the `--no-color` option to disable terminal colors:
|
||||||
|
|
||||||
`hackmyresume <somecommand> <someoptions> --no-color`
|
`hackmyresume <somecommand> <someoptions> --no-color`
|
||||||
|
|
||||||
|
## What's the difference between a FRESH theme and a JSON Resume theme?
|
||||||
|
|
||||||
|
FRESH themes are multiformat (HTML, Word, PDF, etc.) and required to support
|
||||||
|
Markdown formatting, configurable section titles, and various other features.
|
||||||
|
|
||||||
|
JSON Resume themes are typically HTML-driven, but capable of expansion to other
|
||||||
|
formats through tools. JSON Resume themes don't support Markdown natively, but
|
||||||
|
HMR does its best to apply your Markdown, when present, to any JSON Resume
|
||||||
|
themes it encounters.
|
||||||
|
|
||||||
|
## Do I have to have a FRESH resume to use a FRESH theme or a JSON Resume to use a JSON Resume theme?
|
||||||
|
|
||||||
|
No. You can mix and match FRESH and JRS-format themes freely. HackMyResume will
|
||||||
|
perform the necessary conversions on the fly.
|
||||||
|
|
||||||
|
## Can I build my own custom FRESH theme?
|
||||||
|
|
||||||
|
Yes. The easiest way is to copy an existing FRESH theme, like `modern` or
|
||||||
|
`compact`, and make your changes there. You can test your theme with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build resume.json --theme path/to/my/theme/folder
|
||||||
|
```
|
||||||
|
|
||||||
|
## Can I build my own custom JSON Resume theme?
|
||||||
|
|
||||||
|
Yes. The easiest way is to copy an existing JSON Rsume theme and make your
|
||||||
|
changes there. You can test your theme with:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build resume.json --theme path/to/my/theme/folder
|
||||||
|
```
|
||||||
|
|
||||||
|
## Can I build my own tools / services / apps / websites around FRESH / FRESCA?
|
||||||
|
|
||||||
|
Yes! FRESH/FRESCA formats are 100% open source, permissively licensed under MIT,
|
||||||
|
and 100% free from company-specific, tool-specific, or commercially oriented
|
||||||
|
lock-in or cruft. These are clean formats designed for users and builders.
|
||||||
|
|
||||||
|
## Can I build my own tools / services / apps / websites around JSON Resume?
|
||||||
|
|
||||||
|
Yes! HackMyResume is not affiliated with JSON Resume, but like FRESH/FRESCA,
|
||||||
|
JSON Resume is open-source, permissively licensed, and free of proprietary
|
||||||
|
lock-in. See the JSON Resume website for details.
|
||||||
|
49
Gruntfile.js
49
Gruntfile.js
@ -17,43 +17,36 @@ module.exports = function (grunt) {
|
|||||||
all: { src: ['test/*.js'] }
|
all: { src: ['test/*.js'] }
|
||||||
},
|
},
|
||||||
|
|
||||||
clean: ['test/sandbox'],
|
clean: {
|
||||||
|
test: ['test/sandbox']
|
||||||
yuidoc: {
|
|
||||||
compile: {
|
|
||||||
name: '<%= pkg.name %>',
|
|
||||||
description: '<%= pkg.description %>',
|
|
||||||
version: '<%= pkg.version %>',
|
|
||||||
url: '<%= pkg.homepage %>',
|
|
||||||
options: {
|
|
||||||
paths: 'src/',
|
|
||||||
//themedir: 'path/to/custom/theme/',
|
|
||||||
outdir: 'docs/'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
jshint: {
|
eslint: {
|
||||||
options: {
|
target: ['Gruntfile.js', 'src/**/*.js', 'test/*.js']
|
||||||
laxcomma: true,
|
|
||||||
expr: true
|
|
||||||
},
|
|
||||||
all: ['Gruntfile.js', 'src/**/*.js', 'test/*.js']
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
grunt.initConfig( opts );
|
grunt.initConfig( opts );
|
||||||
|
|
||||||
grunt.loadNpmTasks('grunt-simple-mocha');
|
grunt.loadNpmTasks('grunt-simple-mocha');
|
||||||
grunt.loadNpmTasks('grunt-contrib-yuidoc');
|
grunt.loadNpmTasks('grunt-eslint');
|
||||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
||||||
grunt.loadNpmTasks('grunt-contrib-clean');
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||||
|
|
||||||
grunt.registerTask('test', 'Test the HackMyResume library.',
|
// Use 'grunt test' for local testing
|
||||||
function( config ) { grunt.task.run( ['clean','jshint','simplemocha:all'] ); });
|
grunt.registerTask('test', 'Test the HackMyResume application.',
|
||||||
grunt.registerTask('document', 'Generate HackMyResume library documentation.',
|
function() {
|
||||||
function( config ) { grunt.task.run( ['yuidoc'] ); });
|
grunt.task.run(['clean:test','build','eslint','simplemocha:all']);
|
||||||
grunt.registerTask('default', [ 'test', 'yuidoc' ]);
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Use 'grunt build' to build HMR
|
||||||
|
grunt.registerTask('build', 'Build the HackMyResume application.',
|
||||||
|
function() {
|
||||||
|
grunt.task.run( ['eslint'] );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Default task does everything
|
||||||
|
grunt.registerTask('default', [ 'test' ]);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
The MIT License
|
The MIT License
|
||||||
===============
|
===============
|
||||||
|
|
||||||
Copyright (c) 2015 James M. Devlin (https://github.com/hacksalot)
|
Copyright (c) 2015-2018 hacksalot (https://github.com/hacksalot)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
302
README.md
302
README.md
@ -1,16 +1,17 @@
|
|||||||
HackMyResume
|
HackMyResume
|
||||||
============
|
===
|
||||||
|
|
||||||
[![Latest release][img-release]][latest-release]
|
[![Latest release][img-release]][latest-release]
|
||||||
[![Build status (MASTER)][img-master]][travis-url-master]
|
[![Build status (MASTER)][img-master]][travis-url-master]
|
||||||
[![Build status (DEV)][img-dev]][travis-url-dev]
|
[![Build status (DEV)][img-dev]][travis-url-dev]
|
||||||
|
[![Join the chat at https://gitter.im/hacksalot/HackMyResume][badge]][gh]
|
||||||
|
|
||||||
*Create polished résumés and CVs in multiple formats from your command line or
|
*Create polished résumés and CVs in multiple formats from your command line or
|
||||||
shell. Author in clean Markdown and JSON, export to Word, HTML, PDF, LaTeX,
|
shell. Author in clean Markdown and JSON, export to Word, HTML, PDF, LaTeX,
|
||||||
plain text, and other arbitrary formats. Fight the power, save trees. Compatible
|
plain text, and other arbitrary formats. Fight the power, save trees. Compatible
|
||||||
with [FRESH][fresca] and [JRS][6] resumes.*
|
with [FRESH][fresca] and [JRS][6] resumes.*
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
HackMyResume is a dev-friendly, local-only Swiss Army knife for resumes and CVs.
|
HackMyResume is a dev-friendly, local-only Swiss Army knife for resumes and CVs.
|
||||||
Use it to:
|
Use it to:
|
||||||
@ -18,12 +19,16 @@ Use it to:
|
|||||||
1. **Generate** HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML,
|
1. **Generate** HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML,
|
||||||
YAML, print, smoke signal, carrier pigeon, and other arbitrary-format resumes
|
YAML, print, smoke signal, carrier pigeon, and other arbitrary-format resumes
|
||||||
and CVs, from a single source of truth—without violating DRY.
|
and CVs, from a single source of truth—without violating DRY.
|
||||||
2. **Convert** resumes between [FRESH][fresca] and [JSON Resume][6] formats.
|
2. **Analyze** your resume for keyword density, gaps/overlaps, and other
|
||||||
3. **Validate** resumes against either format.
|
metrics.
|
||||||
|
3. **Convert** resumes between [FRESH][fresca] and [JSON Resume][6] formats.
|
||||||
|
4. **Validate** resumes against either format.
|
||||||
|
|
||||||
HackMyResume is built with Node.js and runs on recent versions of OS X, Linux,
|
HackMyResume is built with Node.js and runs on recent versions of OS X, Linux,
|
||||||
or Windows. View the [FAQ](FAQ.md).
|
or Windows. View the [FAQ](FAQ.md).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- OS X, Linux, and Windows.
|
- OS X, Linux, and Windows.
|
||||||
@ -48,13 +53,22 @@ Install the latest stable version of HackMyResume with NPM:
|
|||||||
[sudo] npm install hackmyresume -g
|
[sudo] npm install hackmyresume -g
|
||||||
```
|
```
|
||||||
|
|
||||||
Power users can install the latest bleeding-edge version (updated daily):
|
Alternately, install the latest bleeding-edge version (updated daily):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
[sudo] npm install hacksalot/hackmyresume#dev -g
|
[sudo] npm install hacksalot/hackmyresume#dev -g
|
||||||
```
|
```
|
||||||
|
|
||||||
**For PDF generation**, you'll need to install a copy of [wkhtmltopdf][3] and/or PhantomJS for your platform.
|
## Installing PDF Support (optional)
|
||||||
|
|
||||||
|
HackMyResume tries not to impose a specific PDF engine requirement on
|
||||||
|
the user, but will instead work with whatever PDF engines you have installed.
|
||||||
|
|
||||||
|
Currently, HackMyResume's PDF generation requires one of [Phantom.js][2],
|
||||||
|
[wkhtmltopdf][3], or [WeasyPrint][11] to be installed on your system and the
|
||||||
|
corresponding binary to be accessible on your PATH. This is an optional
|
||||||
|
requirement for users who care about PDF formats. If you don't care about PDF
|
||||||
|
formats, skip this step.
|
||||||
|
|
||||||
## Installing Themes
|
## Installing Themes
|
||||||
|
|
||||||
@ -79,7 +93,7 @@ Then when you're ready to generate your resume, just reference the location of
|
|||||||
the theme folder as you installed it:
|
the theme folder as you installed it:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD resume.json TO out/resume.all -t node_modules/jsonresume-theme-classy
|
hackmyresume build resume.json TO out/resume.all -t node_modules/jsonresume-theme-classy
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: You can use install themes anywhere on your file system. You don't need a
|
Note: You can use install themes anywhere on your file system. You don't need a
|
||||||
@ -96,41 +110,58 @@ Use it when you need to submit, upload, print, or email resumes in specific
|
|||||||
formats.
|
formats.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# hackmyresume BUILD <INPUTS> TO <OUTPUTS> [-t THEME]
|
# hackmyresume build <INPUTS...> TO <OUTPUTS...> [-t THEME]
|
||||||
hackmyresume BUILD resume.json TO out/resume.all
|
hackmyresume build resume.json TO out/resume.all
|
||||||
hackmyresume BUILD r1.json r2.json TO out/rez.html out/rez.md foo/rez.all
|
hackmyresume build r1.json r2.json TO out/rez.html out/rez.md foo/rez.all
|
||||||
```
|
```
|
||||||
|
|
||||||
- **new** creates a new resume in FRESH or JSON Resume format.
|
- **new** creates a new resume in FRESH or JSON Resume format.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# hackmyresume NEW <OUTPUTS> [-f <FORMAT>]
|
# hackmyresume new <OUTPUTS...> [-f <FORMAT>]
|
||||||
hackmyresume NEW resume.json
|
hackmyresume new resume.json
|
||||||
hackmyresume NEW resume.json -f fresh
|
hackmyresume new resume.json -f fresh
|
||||||
hackmyresume NEW r1.json r2.json -f jrs
|
hackmyresume new r1.json r2.json -f jrs
|
||||||
```
|
```
|
||||||
|
|
||||||
- **analyze** inspects your resume for keywords, duration, and other metrics.
|
- **analyze** inspects your resume for keywords, duration, and other metrics.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# hackmyresume analyze <INPUTS...>
|
||||||
|
hackmyresume analyze resume.json
|
||||||
|
hackmyresume analyze r1.json r2.json
|
||||||
|
```
|
||||||
|
|
||||||
- **convert** converts your source resume between FRESH and JSON Resume
|
- **convert** converts your source resume between FRESH and JSON Resume
|
||||||
formats. Use it to convert between the two formats to take advantage of tools
|
formats. Use it to convert between the two formats to take advantage of tools
|
||||||
and services.
|
and services.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# hackmyresume CONVERT <INPUTS> TO <OUTPUTS>
|
# hackmyresume convert <INPUTS...> TO <OUTPUTS...>
|
||||||
hackmyresume CONVERT resume.json TO resume-jrs.json
|
hackmyresume convert resume.json TO resume-jrs.json
|
||||||
hackmyresume CONVERT 1.json 2.json 3.json TO out/1.json out/2.json out/3.json
|
hackmyresume convert 1.json 2.json 3.json TO out/1.json out/2.json out/3.json
|
||||||
```
|
```
|
||||||
|
|
||||||
- **validate** validates the specified resume against either the FRESH or JSON
|
- **validate** validates the specified resume against either the FRESH or JSON
|
||||||
Resume schema. Use it to make sure your resume data is sufficient and complete.
|
Resume schema. Use it to make sure your resume data is sufficient and complete.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# hackmyresume VALIDATE <INPUTS>
|
# hackmyresume validate <INPUTS...>
|
||||||
hackmyresume VALIDATE resume.json
|
hackmyresume validate resume.json
|
||||||
hackmyresume VALIDATE r1.json r2.json r3.json
|
hackmyresume validate r1.json r2.json r3.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- **peek** echoes your resume or any field, property, or object path on your
|
||||||
|
resume to standard output.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# hackmyresume peek <INPUTS...> [OBJECT-PATH]
|
||||||
|
hackmyresume peek rez.json # Echo the whole resume
|
||||||
|
hackmyresume peek rez.json info.brief # Echo the "info.brief" field
|
||||||
|
hackmyresume peek rez.json employment.history[1] # Echo the 1st job
|
||||||
|
hackmyresume peek rez.json rez2.json info.brief # Compare value
|
||||||
|
```
|
||||||
|
|
||||||
## Supported Output Formats
|
## Supported Output Formats
|
||||||
|
|
||||||
HackMyResume supports these output formats:
|
HackMyResume supports these output formats:
|
||||||
@ -152,10 +183,10 @@ image | .png, .bmp | Forthcoming.
|
|||||||
## Use
|
## Use
|
||||||
|
|
||||||
Assuming you've got a JSON-formatted resume handy, generating resumes in
|
Assuming you've got a JSON-formatted resume handy, generating resumes in
|
||||||
different formats and combinations easy. Just run:
|
different formats and combinations is easy. Just run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD <INPUTS> <OUTPUTS> [-t theme].
|
hackmyresume build <inputs> to <outputs> [-t theme].
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `<INPUTS>` is one or more .json resume files, separated by spaces;
|
Where `<INPUTS>` is one or more .json resume files, separated by spaces;
|
||||||
@ -164,19 +195,19 @@ theme (default to Modern). For example:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Generate all resume formats (HTML, PDF, DOC, TXT, YML, etc.)
|
# Generate all resume formats (HTML, PDF, DOC, TXT, YML, etc.)
|
||||||
hackmyresume BUILD resume.json TO out/resume.all -t modern
|
hackmyresume build resume.json TO out/resume.all -t modern
|
||||||
|
|
||||||
# Generate a specific resume format
|
# Generate a specific resume format
|
||||||
hackmyresume BUILD resume.json TO out/resume.html
|
hackmyresume build resume.json TO out/resume.html
|
||||||
hackmyresume BUILD resume.json TO out/resume.pdf
|
hackmyresume build resume.json TO out/resume.pdf
|
||||||
hackmyresume BUILD resume.json TO out/resume.md
|
hackmyresume build resume.json TO out/resume.md
|
||||||
hackmyresume BUILD resume.json TO out/resume.doc
|
hackmyresume build resume.json TO out/resume.doc
|
||||||
hackmyresume BUILD resume.json TO out/resume.json
|
hackmyresume build resume.json TO out/resume.json
|
||||||
hackmyresume BUILD resume.json TO out/resume.txt
|
hackmyresume build resume.json TO out/resume.txt
|
||||||
hackmyresume BUILD resume.json TO out/resume.yml
|
hackmyresume build resume.json TO out/resume.yml
|
||||||
|
|
||||||
# Specify 2 inputs and 3 outputs
|
# Specify 2 inputs and 3 outputs
|
||||||
hackmyresume BUILD in1.json in2.json TO out.html out.doc out.pdf
|
hackmyresume build in1.json in2.json TO out.html out.doc out.pdf
|
||||||
```
|
```
|
||||||
|
|
||||||
You should see something to the effect of:
|
You should see something to the effect of:
|
||||||
@ -198,24 +229,36 @@ Generating YAML resume: out/resume.yml
|
|||||||
|
|
||||||
### Applying a theme
|
### Applying a theme
|
||||||
|
|
||||||
HackMyResume can work with any FRESH or JSON Resume theme. To specify a theme
|
HackMyResume can work with any FRESH or JSON Resume theme (the latter must be
|
||||||
when generating your resume, use the `-t` or `--theme` parameter:
|
installed first). To specify a theme when generating your resume, use the `-t`
|
||||||
|
or `--theme` parameter:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD resume.json TO out/rez.all -t [theme]
|
hackmyresume build resume.json TO out/rez.all -t [theme]
|
||||||
```
|
```
|
||||||
|
|
||||||
The `[theme]` parameter can be the name of a predefined theme or the path to any
|
The `[theme]` parameter can be the name of a predefined theme OR the path to any
|
||||||
FRESH or JSON Resume theme folder:
|
FRESH or JSON Resume theme folder:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD resume.json TO out/rez.all -t modern
|
hackmyresume build resume.json TO out/rez.all -t modern
|
||||||
hackmyresume BUILD resume.json TO OUT.rez.all -t ../some-folder/my-custom-theme/
|
hackmyresume build resume.json TO OUT.rez.all -t ../some-folder/my-custom-theme/
|
||||||
hackmyresume BUILD resume.json TO OUT.rez.all -t npm_modules/jsonresume-theme-classy
|
hackmyresume build resume.json TO OUT.rez.all -t node_modules/jsonresume-theme-classy
|
||||||
```
|
```
|
||||||
|
|
||||||
As of v1.4.0, available predefined themes are `positive`, `modern`, `compact`,
|
FRESH themes are currently pre-installed with HackMyResume. JSON Resume themes
|
||||||
`minimist`, and `hello-world`.
|
can be installed prior to use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Install a JSON Resume theme into a local node_modules subfolder:
|
||||||
|
npm install jsonresume-theme-[name]
|
||||||
|
# Use it with HackMyResume
|
||||||
|
hackmyresume build resume.json -t node_modules/jsonresume-theme-[name]
|
||||||
|
```
|
||||||
|
|
||||||
|
As of v1.6.0, available predefined FRESH themes are `positive`, `modern`,
|
||||||
|
`compact`, `minimist`, and `hello-world`. For a list of JSON Resume themes,
|
||||||
|
check the [NPM Registry](https://www.npmjs.com/search?q=jsonresume-theme).
|
||||||
|
|
||||||
### Merging resumes
|
### Merging resumes
|
||||||
|
|
||||||
@ -224,7 +267,7 @@ most generic to most specific:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Merge specific.json onto base.json and generate all formats
|
# Merge specific.json onto base.json and generate all formats
|
||||||
hackmyresume BUILD base.json specific.json TO resume.all
|
hackmyresume build base.json specific.json TO resume.all
|
||||||
```
|
```
|
||||||
|
|
||||||
This can be useful for overriding a base (generic) resume with information from
|
This can be useful for overriding a base (generic) resume with information from
|
||||||
@ -235,7 +278,7 @@ resume. Merging follows conventional [extend()][9]-style behavior and there's
|
|||||||
no arbitrary limit to how many resumes you can merge:
|
no arbitrary limit to how many resumes you can merge:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD in1.json in2.json in3.json in4.json TO out.html out.doc
|
hackmyresume build in1.json in2.json in3.json in4.json TO out.html 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
|
||||||
@ -251,7 +294,7 @@ You can specify **multiple output targets** and HackMyResume 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.
|
||||||
hackmyresume BUILD me.json TO out1.doc out1.pdf foo.txt
|
hackmyresume build me.json TO out1.doc out1.pdf foo.txt
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using .all
|
### Using .all
|
||||||
@ -261,27 +304,63 @@ 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.)
|
||||||
hackmyresume BUILD me.json TO out/resume.all
|
hackmyresume build me.json TO out/resume.all
|
||||||
```
|
```
|
||||||
|
|
||||||
..tells HackMyResume to read `me.json` and generate `out/resume.md`,
|
..tells HackMyResume to read `me.json` and generate `out/resume.md`,
|
||||||
`out/resume.doc`, `out/resume.html`, `out/resume.txt`, `out/resume.pdf`, and
|
`out/resume.doc`, `out/resume.html`, `out/resume.txt`, `out/resume.pdf`, and
|
||||||
`out/resume.json`.
|
`out/resume.json`.
|
||||||
|
|
||||||
|
### Building PDFs
|
||||||
|
|
||||||
|
*Users who don't care about PDFs can turn off PDF generation across all themes
|
||||||
|
and formats with the `--pdf none` switch.*
|
||||||
|
|
||||||
|
HackMyResume takes a unique approach to PDF generation. Instead of enforcing
|
||||||
|
a specific PDF engine on users, HackMyResume will attempt to work with whatever
|
||||||
|
PDF engine you have installed through the engine's command-line interface (CLI).
|
||||||
|
Currently that means any of...
|
||||||
|
|
||||||
|
- [wkhtmltopdf][3]
|
||||||
|
- [Phantom.js][2]
|
||||||
|
- [WeasyPrint][11]
|
||||||
|
|
||||||
|
..with support for other engines planned in the future. But for now, **one or
|
||||||
|
more of these engines must be installed and accessible on your PATH in order
|
||||||
|
to generate PDF resumes with HackMyResume**. That means you should be able to
|
||||||
|
invoke either of these tools directly from your shell or terminal without error:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
wkhtmltopdf input.html output.pdf
|
||||||
|
phantomjs script.js input.html output.pdf
|
||||||
|
weasyprint input.html output.pdf
|
||||||
|
```
|
||||||
|
|
||||||
|
Assuming you've installed one or both of these engines on your system, you can
|
||||||
|
tell HackMyResume which flavor of PDF generation to use via the `--pdf` option
|
||||||
|
(`-p` for short):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build resume.json TO out.all --pdf phantom
|
||||||
|
hackmyresume build resume.json TO out.all --pdf wkhtmltopdf
|
||||||
|
hackmyresume build resume.json TO out.all --pdf weasyprint
|
||||||
|
hackmyresume build resume.json TO out.all --pdf none
|
||||||
|
```
|
||||||
|
|
||||||
### Analyzing
|
### Analyzing
|
||||||
|
|
||||||
HackMyResume can analyze your resume for keywords, employment gaps, and other
|
HackMyResume can analyze your resume for keywords, employment gaps, and other
|
||||||
metrics. Run:
|
metrics. Run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume ANALYZE <my-resume>.json
|
hackmyresume analyze <my-resume>.json
|
||||||
```
|
```
|
||||||
|
|
||||||
Depending on the HackMyResume version, you should see output similar to:
|
Depending on the HackMyResume version, you should see output similar to:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
*** HackMyResume v1.4.1 ***
|
*** HackMyResume v1.6.0 ***
|
||||||
Reading resume: resume.json
|
Reading resume: resume.json
|
||||||
Analyzing FRESH resume: resume.json
|
Analyzing FRESH resume: resume.json
|
||||||
|
|
||||||
@ -371,13 +450,13 @@ resumes, use the `validate` command:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Validate myresume.json against either the FRESH or JSON Resume schema.
|
# Validate myresume.json against either the FRESH or JSON Resume schema.
|
||||||
hackmyresume VALIDATE resumeA.json resumeB.json
|
hackmyresume validate resumeA.json resumeB.json
|
||||||
```
|
```
|
||||||
|
|
||||||
HackMyResume will validate each specified resume in turn:
|
HackMyResume will validate each specified resume in turn:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
*** HackMyResume v0.9.0 ***
|
*** HackMyResume v1.6.0 ***
|
||||||
Validating JSON resume: resumeA.json (INVALID)
|
Validating JSON resume: resumeA.json (INVALID)
|
||||||
Validating JSON resume: resumeB.json (VALID)
|
Validating JSON resume: resumeB.json (VALID)
|
||||||
```
|
```
|
||||||
@ -388,7 +467,7 @@ HackMyResume can convert between the [FRESH][fresca] and [JSON Resume][6]
|
|||||||
formats. Just run:
|
formats. Just run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume CONVERT <INPUTS> <OUTPUTS>
|
hackmyresume convert <INPUTS> <OUTPUTS>
|
||||||
```
|
```
|
||||||
|
|
||||||
where <INPUTS> is one or more resumes in FRESH or JSON Resume format, and
|
where <INPUTS> is one or more resumes in FRESH or JSON Resume format, and
|
||||||
@ -396,22 +475,44 @@ where <INPUTS> is one or more resumes in FRESH or JSON Resume format, and
|
|||||||
autodetect the format (FRESH or JRS) of each input resume and convert it to the
|
autodetect the format (FRESH or JRS) of each input resume and convert it to the
|
||||||
other format (JRS or FRESH).
|
other format (JRS or FRESH).
|
||||||
|
|
||||||
### External options
|
### File-based Options
|
||||||
|
|
||||||
Starting in v1.4.x you can pass options into HackMyResume via an external
|
You can pass options into HackMyResume via an external options or ".hackmyrc"
|
||||||
options or ".hackmyrc" file.
|
file with the `--options` or `-o` switch:
|
||||||
|
|
||||||
```javascript
|
```bash
|
||||||
|
hackmyresume build resume.json -o path/to/options.json
|
||||||
|
```
|
||||||
|
|
||||||
|
The options file can contain any documented HackMyResume option, including
|
||||||
|
`theme`, `silent`, `debug`, `pdf`, `css`, and other settings.
|
||||||
|
|
||||||
|
```json
|
||||||
{
|
{
|
||||||
// Set the default theme to "compact"
|
|
||||||
"theme": "compact",
|
"theme": "compact",
|
||||||
// Change the "employment" section title text to "Work"
|
|
||||||
"sectionTitles": {
|
"sectionTitles": {
|
||||||
"employment": "Work"
|
"employment": "Work"
|
||||||
|
},
|
||||||
|
|
||||||
|
"wkhtmltopdf": {
|
||||||
|
"margin-top": "20mm"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If an option is specified on both the command line and in an external options
|
||||||
|
file, the command-line option wins.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# path/to/options.json specifes the POSITIVE theme
|
||||||
|
# -t parameter specifies the COMPACT theme
|
||||||
|
# The -t parameter wins.
|
||||||
|
hackmyresume build resume.json -o path/to/options.json -t compact
|
||||||
|
> Reading resume: resume.json
|
||||||
|
> Applying COMPACT theme (7 formats)
|
||||||
|
```
|
||||||
|
|
||||||
### Prettifying
|
### Prettifying
|
||||||
|
|
||||||
HackMyResume applies [js-beautify][10]-style HTML prettification by default to
|
HackMyResume applies [js-beautify][10]-style HTML prettification by default to
|
||||||
@ -419,7 +520,7 @@ HTML-formatted resumes. To disable prettification, the `--no-prettify` or `-n`
|
|||||||
flag can be used:
|
flag can be used:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD resume.json out.all --no-prettify
|
hackmyresume build resume.json out.all --no-prettify
|
||||||
```
|
```
|
||||||
|
|
||||||
### Silent Mode
|
### Silent Mode
|
||||||
@ -427,15 +528,90 @@ hackmyresume BUILD resume.json out.all --no-prettify
|
|||||||
Use `-s` or `--silent` to run in silent mode:
|
Use `-s` or `--silent` to run in silent mode:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
hackmyresume BUILD resume.json -o someFile.all -s
|
hackmyresume build resume.json -o someFile.all -s
|
||||||
hackmyresume BUILD resume.json -o someFile.all --silent
|
hackmyresume build resume.json -o someFile.all --silent
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Debug Mode
|
||||||
|
|
||||||
|
Use `-d` or `--debug` to force HMR to emit a call stack when errors occur. In
|
||||||
|
the future, this option will emit detailed error logging.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build resume.json -d
|
||||||
|
hackmyresume analyze resume.json --debug
|
||||||
|
```
|
||||||
|
|
||||||
|
### Disable Encoding
|
||||||
|
|
||||||
|
Use the `--no-escape` option to disable encoding in Handlebars themes. Note:
|
||||||
|
this option has no effect for non-Handlebars themes.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build resume.json --no-escape
|
||||||
|
```
|
||||||
|
|
||||||
|
### Private Resume Fields
|
||||||
|
|
||||||
|
Have a gig, education stint, membership, or other relevant history that you'd
|
||||||
|
like to hide from *most* (e.g. public) resumes but sometimes show on others? Tag it with
|
||||||
|
`"private": true` to omit it from outbound generated resumes by default.
|
||||||
|
|
||||||
|
|
||||||
|
```json
|
||||||
|
"employment": {
|
||||||
|
"history": [
|
||||||
|
{
|
||||||
|
"employer": "Acme Real Estate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"employer": "Area 51 Alien Research Laboratory",
|
||||||
|
"private": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"employer": "H&R Block"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, when you want a copy of your resume that includes the private gig / stint
|
||||||
|
/ etc., tell HackMyResume that it's OK to emit private fields. The way you do
|
||||||
|
that is with the `--private` switch.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build resume.json private-resume.all --private
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Custom theme helpers
|
||||||
|
|
||||||
|
You can attach your own custom Handlebars helpers to a FRESH theme with the
|
||||||
|
`helpers` key of your theme's `theme.json` file.
|
||||||
|
|
||||||
|
```js
|
||||||
|
{
|
||||||
|
"title": "my-cool-theme",
|
||||||
|
|
||||||
|
// ...
|
||||||
|
|
||||||
|
"helpers": [
|
||||||
|
"../path/to/helpers/*.js",
|
||||||
|
"some-other-helper.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
HackMyResume will attempt to load each path or glob and register any specified
|
||||||
|
files with [Handlebars.registerHelper][hrh], making them available to your
|
||||||
|
theme.
|
||||||
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
HackMyResume is a community-driven free and open source project under the MIT
|
HackMyResume is a community-driven free and open source project under the MIT
|
||||||
License. Contributions are encouraged and we respond to all PRs and issues,
|
License. Contributions are encouraged and we respond to all PRs and issues in
|
||||||
usually within 24 hours. See [CONTRIBUTING.md][contribute] for details.
|
time. See [CONTRIBUTING.md][contribute] for details.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
@ -451,8 +627,9 @@ MIT. Go crazy. See [LICENSE.md][1] for details.
|
|||||||
[8]: https://youtu.be/N9wsjroVlu8
|
[8]: https://youtu.be/N9wsjroVlu8
|
||||||
[9]: https://api.jquery.com/jquery.extend/
|
[9]: https://api.jquery.com/jquery.extend/
|
||||||
[10]: https://github.com/beautify-web/js-beautify
|
[10]: https://github.com/beautify-web/js-beautify
|
||||||
|
[11]: http://weasyprint.org/
|
||||||
[fresh]: https://github.com/fluentdesk/FRESH
|
[fresh]: https://github.com/fluentdesk/FRESH
|
||||||
[fresca]: https://github.com/fluentdesk/FRESCA
|
[fresca]: https://github.com/fresh-standard/fresh-resume-schema
|
||||||
[dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
|
[dry]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself
|
||||||
[img-release]: https://img.shields.io/github/release/hacksalot/HackMyResume.svg?label=version
|
[img-release]: https://img.shields.io/github/release/hacksalot/HackMyResume.svg?label=version
|
||||||
[img-master]: https://img.shields.io/travis/hacksalot/HackMyResume/master.svg
|
[img-master]: https://img.shields.io/travis/hacksalot/HackMyResume/master.svg
|
||||||
@ -463,3 +640,6 @@ MIT. Go crazy. See [LICENSE.md][1] for details.
|
|||||||
[contribute]: CONTRIBUTING.md
|
[contribute]: CONTRIBUTING.md
|
||||||
[fresh-themes]: https://github.com/fluentdesk/fresh-themes
|
[fresh-themes]: https://github.com/fluentdesk/fresh-themes
|
||||||
[jrst]: https://www.npmjs.com/search?q=jsonresume-theme
|
[jrst]: https://www.npmjs.com/search?q=jsonresume-theme
|
||||||
|
[gh]: https://gitter.im/hacksalot/HackMyResume?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
|
||||||
|
[badge]: https://badges.gitter.im/hacksalot/HackMyResume.svg
|
||||||
|
[hrh]: http://handlebarsjs.com/reference.html#base-registerHelper
|
||||||
|
107
ROADMAP.md
Normal file
107
ROADMAP.md
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
Development Roadmap
|
||||||
|
===================
|
||||||
|
|
||||||
|
## Short-Term
|
||||||
|
|
||||||
|
### FluentCV Desktop: Beta 1
|
||||||
|
|
||||||
|
The **FluentCV Desktop 1.0 beta release** will present HackMyResume
|
||||||
|
functionality in a cross-platform desktop application for OS X, Linux, and
|
||||||
|
Windows.
|
||||||
|
|
||||||
|
### GitHub Integration
|
||||||
|
|
||||||
|
HackMyResume will offer GitHub integration for versioned resume storage and
|
||||||
|
retrieval via the `COMMIT` or `STORE` command(s) starting in 1.7.0 or 1.8.0.
|
||||||
|
|
||||||
|
### fresh-themes 1.0.0
|
||||||
|
|
||||||
|
The **fresh-themes 1.0** release will bring 100% coverage of the FRESH and JRS
|
||||||
|
object models—all resume sections and fields—along with
|
||||||
|
documentation, theme developer's guide, new themes, and a freeze to the FRESH
|
||||||
|
theme structure.
|
||||||
|
|
||||||
|
### Better LaTeX support
|
||||||
|
|
||||||
|
Including Markdown-to-LaTeX translation and more LaTeX-driven themes / formats.
|
||||||
|
|
||||||
|
### StackOverflow and LinkedIn support
|
||||||
|
|
||||||
|
Will start appearing in v1.7.0, with incremental improvements in 1.8.0 and
|
||||||
|
beyond.
|
||||||
|
|
||||||
|
### Improved resume sorting and arranging
|
||||||
|
|
||||||
|
**Better resume sorting** of items and sections: ascending, descending, by
|
||||||
|
date or other criteria ([#67][i67]).
|
||||||
|
|
||||||
|
### Remote resume / theme loading
|
||||||
|
|
||||||
|
Support remote loading of themes and resumes over `http`, `https`, and
|
||||||
|
`git://`. Enable these usage patterns:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
hackmyresume build https://somesite.com/my-resume.json -t informatic
|
||||||
|
|
||||||
|
hackmyresume build resume.json -t npm:fresh-theme-ergonomic
|
||||||
|
|
||||||
|
hackmyresume analyze https://github.com/foo/my-resume
|
||||||
|
```
|
||||||
|
|
||||||
|
### 100% code coverage
|
||||||
|
|
||||||
|
Should reduce certain classes of errors and allow HMR to display a nifty 100%
|
||||||
|
code coverage badge.
|
||||||
|
|
||||||
|
### Improved **documentation and samples**
|
||||||
|
|
||||||
|
Expanded documentation and samples throughout.
|
||||||
|
|
||||||
|
## Mid-Term
|
||||||
|
|
||||||
|
### Cover letters and job descriptions
|
||||||
|
|
||||||
|
Add support for schema-driven **cover letters** and **job descriptions**.
|
||||||
|
|
||||||
|
### Character Sheets
|
||||||
|
|
||||||
|
HackMyResume 2.0 will ship with support for, yes, RPG-style character sheets.
|
||||||
|
This will demonstrate the tool's ability to flow arbitrary JSON to concrete
|
||||||
|
document(s) and provide unique albeit niche functionality around various games
|
||||||
|
([#117][i117]).
|
||||||
|
|
||||||
|
### Rich text (.rtf) output formats
|
||||||
|
|
||||||
|
Basic support for **rich text** `.rtf` output formats.
|
||||||
|
|
||||||
|
### Investigate: groff support
|
||||||
|
|
||||||
|
Investigate adding [**groff**][groff] support, because that would, indeed, be
|
||||||
|
[dope][d] ([#37][i37]).
|
||||||
|
|
||||||
|
### Investigate: org-mode support
|
||||||
|
|
||||||
|
Investigate adding [**org mode**][om] support ([#38][i38]).
|
||||||
|
|
||||||
|
### Investigate: Scribus
|
||||||
|
|
||||||
|
Investigate adding [**Scribus SLA**][scri] support ([#54][i54]).
|
||||||
|
|
||||||
|
### Support JSON Resume 1.0.0
|
||||||
|
|
||||||
|
When released.
|
||||||
|
|
||||||
|
## Long-Term
|
||||||
|
|
||||||
|
- TBD
|
||||||
|
|
||||||
|
[groff]: http://www.gnu.org/software/groff/
|
||||||
|
[om]: http://orgmode.org/
|
||||||
|
[scri]: https://en.wikipedia.org/wiki/Scribus
|
||||||
|
[d]: https://github.com/hacksalot/HackMyResume/issues/37#issue-123818674
|
||||||
|
[i37]: https://github.com/hacksalot/HackMyResume/issues/37
|
||||||
|
[i38]: https://github.com/hacksalot/HackMyResume/issues/38
|
||||||
|
[i54]: https://github.com/hacksalot/HackMyResume/issues/54
|
||||||
|
[i67]: https://github.com/hacksalot/HackMyResume/issues/67
|
||||||
|
[i107]: https://github.com/hacksalot/HackMyResume/issues/107
|
||||||
|
[i117]: https://github.com/hacksalot/HackMyResume/issues/117
|
Binary file not shown.
Before Width: | Height: | Size: 27 KiB |
BIN
assets/hmr_analyze.png
Normal file
BIN
assets/hmr_analyze.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
assets/hmr_build.png
Normal file
BIN
assets/hmr_build.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
3
assets/logo/hackmyresume-logo.ai
Normal file
3
assets/logo/hackmyresume-logo.ai
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:a476ee59e7d86b5a7599780b5efca57ee6b6d60e1a722343277057ea793703b6
|
||||||
|
size 1642116
|
BIN
assets/logo/hackmyresume-logo.png
Normal file
BIN
assets/logo/hackmyresume-logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
2800
npm-shrinkwrap.json
generated
Normal file
2800
npm-shrinkwrap.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
68
package.json
68
package.json
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "hackmyresume",
|
"name": "hackmyresume",
|
||||||
"version": "1.4.2",
|
"version": "1.9.0-beta",
|
||||||
"description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.",
|
"description": "Generate polished résumés and CVs in HTML, Markdown, LaTeX, MS Word, PDF, plain text, JSON, XML, YAML, smoke signal, and carrier pigeon.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/hacksalot/HackMyResume.git"
|
"url": "https://github.com/hacksalot/HackMyResume.git"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "grunt clean && mocha",
|
"test": "grunt clean:test && mocha --exit",
|
||||||
"grunt": "grunt"
|
"grunt": "grunt"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@ -30,6 +30,8 @@
|
|||||||
],
|
],
|
||||||
"author": "hacksalot <hacksalot@indevious.com> (https://github.com/hacksalot)",
|
"author": "hacksalot <hacksalot@indevious.com> (https://github.com/hacksalot)",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
|
"aruberto (https://github.com/aruberto)",
|
||||||
|
"daniele-rapagnani (https://github.com/daniele-rapagnani)",
|
||||||
"jjanusch (https://github.com/driftdev)",
|
"jjanusch (https://github.com/driftdev)",
|
||||||
"robertmain (https://github.com/robertmain)",
|
"robertmain (https://github.com/robertmain)",
|
||||||
"tomheon (https://github.com/tomheon)",
|
"tomheon (https://github.com/tomheon)",
|
||||||
@ -41,57 +43,67 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/hacksalot/HackMyResume/issues"
|
"url": "https://github.com/hacksalot/HackMyResume/issues"
|
||||||
},
|
},
|
||||||
"main": "src/hackmyapi.js",
|
|
||||||
"bin": {
|
"bin": {
|
||||||
"hackmyresume": "src/index.js"
|
"hackmyresume": "src/cli/index.js"
|
||||||
},
|
},
|
||||||
|
"main": "src/index.js",
|
||||||
"homepage": "https://github.com/hacksalot/HackMyResume",
|
"homepage": "https://github.com/hacksalot/HackMyResume",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^1.1.1",
|
"chalk": "^2.3.1",
|
||||||
"commander": "^2.9.0",
|
"commander": "^2.9.0",
|
||||||
"copy": "^0.1.3",
|
"copy": "^0.3.1",
|
||||||
"fresca": "~0.3.0",
|
"escape-latex": "^1.0.0",
|
||||||
"fresh-resume-starter": "^0.1.1",
|
"extend": "^3.0.0",
|
||||||
"fresh-themes": "~0.12.0-beta",
|
"fresh-jrs-converter": "^1.0.0",
|
||||||
"fs-extra": "^0.24.0",
|
"fresh-resume-schema": "^1.0.0-beta",
|
||||||
|
"fresh-resume-starter": "^0.3.1",
|
||||||
|
"fresh-resume-validator": "^0.2.0",
|
||||||
|
"fresh-themes": "^0.17.0-beta",
|
||||||
|
"fs-extra": "^5.0.0",
|
||||||
|
"glob": "^7.1.2",
|
||||||
"handlebars": "^4.0.5",
|
"handlebars": "^4.0.5",
|
||||||
"html": "0.0.10",
|
"html": "^1.0.0",
|
||||||
"is-my-json-valid": "^2.12.2",
|
"is-my-json-valid": "^2.12.4",
|
||||||
"json-lint": "^0.1.0",
|
"json-lint": "^0.1.0",
|
||||||
"jst": "0.0.13",
|
"jsonlint": "^1.6.2",
|
||||||
"lodash": "^3.10.1",
|
"lodash": "^4.17.5",
|
||||||
"marked": "^0.3.5",
|
"marked": "^0.3.5",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
"moment": "^2.10.6",
|
"moment": "^2.11.1",
|
||||||
"parse-filepath": "^0.6.3",
|
"parse-filepath": "^1.0.2",
|
||||||
"path-exists": "^2.1.0",
|
"path-exists": "^3.0.0",
|
||||||
"phantom": "^0.8.4",
|
"pinkie-promise": "^2.0.0",
|
||||||
|
"printf": "^0.2.3",
|
||||||
"recursive-readdir-sync": "^1.0.6",
|
"recursive-readdir-sync": "^1.0.6",
|
||||||
"simple-html-tokenizer": "^0.2.0",
|
"simple-html-tokenizer": "^0.4.3",
|
||||||
"slash": "^1.0.0",
|
"slash": "^1.0.0",
|
||||||
"string-padding": "^1.0.2",
|
"string-padding": "^1.0.2",
|
||||||
|
"string.prototype.endswith": "^0.2.0",
|
||||||
"string.prototype.startswith": "^0.2.0",
|
"string.prototype.startswith": "^0.2.0",
|
||||||
|
"traverse": "^0.6.6",
|
||||||
"underscore": "^1.8.3",
|
"underscore": "^1.8.3",
|
||||||
"webshot": "^0.16.0",
|
|
||||||
"wkhtmltopdf": "^0.1.5",
|
|
||||||
"word-wrap": "^1.1.0",
|
"word-wrap": "^1.1.0",
|
||||||
"xml-escape": "^1.0.0",
|
"xml-escape": "^1.0.0",
|
||||||
"yamljs": "^0.2.4"
|
"yamljs": "^0.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "*",
|
"chai": "*",
|
||||||
"fresh-test-resumes": "^0.2.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
|
"dir-compare": "^1.4.0",
|
||||||
|
"fresh-test-resumes": "^0.9.2",
|
||||||
|
"fresh-test-themes": "^0.2.0",
|
||||||
|
"fresh-theme-underscore": "^0.1.1",
|
||||||
"grunt": "*",
|
"grunt": "*",
|
||||||
"grunt-cli": "^0.1.13",
|
"grunt-contrib-clean": "^1.1.0",
|
||||||
"grunt-contrib-clean": "^0.7.0",
|
"grunt-contrib-coffee": "^2.0.0",
|
||||||
"grunt-contrib-jshint": "^0.11.3",
|
"grunt-contrib-copy": "^1.0.0",
|
||||||
"grunt-contrib-yuidoc": "^0.10.0",
|
"grunt-eslint": "^20.1.0",
|
||||||
"grunt-simple-mocha": "*",
|
"grunt-simple-mocha": "*",
|
||||||
"jsonresume-theme-boilerplate": "^0.1.2",
|
"jsonresume-theme-boilerplate": "^0.1.2",
|
||||||
"jsonresume-theme-classy": "^1.0.9",
|
"jsonresume-theme-classy": "^1.0.9",
|
||||||
"jsonresume-theme-modern": "0.0.18",
|
"jsonresume-theme-modern": "0.0.18",
|
||||||
"jsonresume-theme-sceptile": "^1.0.5",
|
"jsonresume-theme-sceptile": "^1.0.5",
|
||||||
"mocha": "*",
|
"mocha": "*",
|
||||||
"resample": "fluentdesk/resample"
|
"stripcolorcodes": "^0.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
src/cli/analyze.hbs
Normal file
30
src/cli/analyze.hbs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
{{style "SECTIONS (" "bold"}}{{style totals.numSections "white" }}{{style ")" "bold"}}
|
||||||
|
|
||||||
|
employment: {{v totals.totals.employment "-" 2 "bold" }}
|
||||||
|
projects: {{v totals.totals.projects "-" 2 "bold" }}
|
||||||
|
education: {{v totals.totals.education "-" 2 "bold" }}
|
||||||
|
service: {{v totals.totals.service "-" 2 "bold" }}
|
||||||
|
skills: {{v totals.totals.skills "-" 2 "bold" }}
|
||||||
|
writing: {{v totals.totals.writing "-" 2 "bold" }}
|
||||||
|
speaking: {{v totals.totals.speaking "-" 2 "bold" }}
|
||||||
|
reading: {{v totals.totals.reading "-" 2 "bold" }}
|
||||||
|
social: {{v totals.totals.social "-" 2 "bold" }}
|
||||||
|
references: {{v totals.totals.references "-" 2 "bold" }}
|
||||||
|
testimonials: {{v totals.totals.testimonials "-" 2 "bold" }}
|
||||||
|
languages: {{v totals.totals.languages "-" 2 "bold" }}
|
||||||
|
interests: {{v totals.totals.interests "-" 2 "bold" }}
|
||||||
|
|
||||||
|
{{style "COVERAGE (" "bold"}}{{style coverage.pct "white"}}{{style ")" "bold"}}
|
||||||
|
|
||||||
|
Total Days: {{v coverage.duration.total "-" 5 "bold" }}
|
||||||
|
Employed: {{v coverage.duration.work "-" 5 "bold" }}
|
||||||
|
Gaps: {{v coverage.gaps.length "-" 5 "bold" }} [{{#if coverage.gaps.length }}{{#each coverage.gaps }}{{#unless @first}} {{/unless}}{{gapLength duration }}{{/each}}{{/if}}]
|
||||||
|
Overlaps: {{v coverage.overlaps.length "-" 5 "bold" }} [{{#if coverage.overlaps.length }}{{#each coverage.overlaps }}{{#unless @first}} {{/unless}}{{gapLength duration }}{{/each}}{{/if}}]
|
||||||
|
|
||||||
|
{{style "KEYWORDS (" "bold"}}{{style keywords.length "white" }}{{style ")" "bold"}}
|
||||||
|
|
||||||
|
{{#each keywords }}{{{pad name 18}}}: {{v count "-" 5 "bold"}} mention{{#isPlural count}}s{{/isPlural}}
|
||||||
|
{{/each}}
|
||||||
|
-------------------------------
|
||||||
|
{{v keywords.length "0" 9 "bold"}} {{style "KEYWORDS" "bold"}} {{v keywords.totalKeywords "0" 5 "bold"}} {{style "mentions" "bold"}}
|
328
src/cli/error.js
Normal file
328
src/cli/error.js
Normal file
@ -0,0 +1,328 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Error-handling routines for HackMyResume.
|
||||||
|
@module cli/error
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const HMSTATUS = require('../core/status-codes');
|
||||||
|
const FS = require('fs');
|
||||||
|
const PATH = require('path');
|
||||||
|
const WRAP = require('word-wrap');
|
||||||
|
const M2C = require('../utils/md2chalk');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
const extend = require('extend');
|
||||||
|
const printf = require('printf');
|
||||||
|
const SyntaxErrorEx = require('../utils/syntax-error-ex');
|
||||||
|
require('string.prototype.startswith');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Error handler for HackMyResume. All errors are handled here.
|
||||||
|
@class ErrorHandler */
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
init( debug, assert, silent ) {
|
||||||
|
this.debug = debug;
|
||||||
|
this.assert = assert;
|
||||||
|
this.silent = silent;
|
||||||
|
this.msgs = require('./msg').errors;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
err( ex, shouldExit ) {
|
||||||
|
|
||||||
|
// Short-circuit logging output if --silent is on
|
||||||
|
let stack;
|
||||||
|
const o = this.silent ? function() {} : _defaultLog;
|
||||||
|
|
||||||
|
// Special case; can probably be removed.
|
||||||
|
if (ex.pass) { throw ex; }
|
||||||
|
|
||||||
|
// Load error messages
|
||||||
|
this.msgs = this.msgs || require('./msg').errors;
|
||||||
|
|
||||||
|
// Handle packaged HMR exceptions
|
||||||
|
if (ex.fluenterror) {
|
||||||
|
|
||||||
|
// Output the error message
|
||||||
|
const objError = assembleError.call(this, ex);
|
||||||
|
o( this[ `format_${objError.etype}` ]( objError.msg ));
|
||||||
|
|
||||||
|
// Output the stack (sometimes)
|
||||||
|
if (objError.withStack) {
|
||||||
|
stack = ex.stack || (ex.inner && ex.inner.stack);
|
||||||
|
stack && o( chalk.gray( stack ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quit if necessary
|
||||||
|
if (shouldExit || ex.exit) {
|
||||||
|
if (this.debug) {
|
||||||
|
o(chalk.cyan(`Exiting with error code ${ex.fluenterror.toString()}`));
|
||||||
|
}
|
||||||
|
if (this.assert) {
|
||||||
|
ex.pass = true;
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
return process.exit(ex.fluenterror);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle raw exceptions
|
||||||
|
} else {
|
||||||
|
o(ex);
|
||||||
|
const stackTrace = ex.stack || (ex.inner && ex.inner.stack);
|
||||||
|
if (stackTrace && this.debug) {
|
||||||
|
return o(M2C(ex.stack || ex.inner.stack, 'gray'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
format_error( msg ) {
|
||||||
|
msg = msg || '';
|
||||||
|
return chalk.red.bold( msg.toUpperCase().startsWith('ERROR:') ? msg : `Error: ${msg}` );
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
format_warning( brief, msg ) {
|
||||||
|
return chalk.yellow(brief) + chalk.yellow(msg || '');
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
format_custom( msg ) { return msg; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var _defaultLog = function() { return console.log.apply(console.log, arguments); }; // eslint-disable-line no-console
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var assembleError = function( ex ) {
|
||||||
|
|
||||||
|
let se;
|
||||||
|
let msg = '';
|
||||||
|
let withStack = false;
|
||||||
|
let quit = false;
|
||||||
|
let etype = 'warning';
|
||||||
|
if (this.debug) { withStack = true; }
|
||||||
|
|
||||||
|
switch (ex.fluenterror) {
|
||||||
|
|
||||||
|
case HMSTATUS.themeNotFound:
|
||||||
|
msg = printf( M2C( this.msgs.themeNotFound.msg, 'yellow' ), ex.data);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.copyCSS:
|
||||||
|
msg = M2C( this.msgs.copyCSS.msg, 'red' );
|
||||||
|
quit = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.resumeNotFound:
|
||||||
|
//msg = M2C( this.msgs.resumeNotFound.msg, 'yellow' );
|
||||||
|
msg += M2C(FS.readFileSync(
|
||||||
|
PATH.resolve(__dirname, `help/${ex.verb}.txt`), 'utf8' ), 'white', 'yellow');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.missingCommand:
|
||||||
|
// msg = M2C( this.msgs.missingCommand.msg + " (", 'yellow');
|
||||||
|
// msg += Object.keys( FCMD.verbs ).map( (v, idx, ar) ->
|
||||||
|
// return ( if idx == ar.length - 1 then chalk.yellow('or ') else '') +
|
||||||
|
// chalk.yellow.bold(v.toUpperCase());
|
||||||
|
// ).join( chalk.yellow(', ')) + chalk.yellow(").\n\n");
|
||||||
|
|
||||||
|
msg += M2C(FS.readFileSync(
|
||||||
|
PATH.resolve(__dirname, 'help/use.txt'), 'utf8' ), 'white', 'yellow');
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invalidCommand:
|
||||||
|
msg = printf( M2C( this.msgs.invalidCommand.msg, 'yellow'), ex.attempted );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.resumeNotFoundAlt:
|
||||||
|
msg = M2C( this.msgs.resumeNotFoundAlt.msg, 'yellow' );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.inputOutputParity:
|
||||||
|
msg = M2C( this.msgs.inputOutputParity.msg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.createNameMissing:
|
||||||
|
msg = M2C( this.msgs.createNameMissing.msg );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.pdfGeneration:
|
||||||
|
msg = M2C( this.msgs.pdfGeneration.msg, 'bold' );
|
||||||
|
if (ex.inner) { msg += chalk.red(`\n${ex.inner}`); }
|
||||||
|
quit = false;
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invalid:
|
||||||
|
msg = M2C( this.msgs.invalid.msg, 'red' );
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.generateError:
|
||||||
|
msg = (ex.inner && ex.inner.toString()) || ex;
|
||||||
|
quit = false;
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.fileSaveError:
|
||||||
|
msg = printf( M2C( this.msgs.fileSaveError.msg ), (ex.inner || ex).toString() );
|
||||||
|
etype = 'error';
|
||||||
|
quit = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invalidFormat:
|
||||||
|
ex.data.forEach( function(d) {
|
||||||
|
return msg += printf( M2C( this.msgs.invalidFormat.msg, 'bold' ),
|
||||||
|
ex.theme.name.toUpperCase(), d.format.toUpperCase());
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.missingParam:
|
||||||
|
msg = printf(M2C( this.msgs.missingParam.msg ), ex.expected, ex.helper);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invalidHelperUse:
|
||||||
|
msg = printf( M2C( this.msgs.invalidHelperUse.msg ), ex.helper );
|
||||||
|
if (ex.error) {
|
||||||
|
msg += `\n--> ${assembleError.call( this, extend( true, {}, ex, {fluenterror: ex.error} )).msg}`;
|
||||||
|
}
|
||||||
|
//msg += printf( '\n--> ' + M2C( this.msgs.invalidParamCount.msg ), ex.expected );
|
||||||
|
quit = false;
|
||||||
|
etype = 'warning';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.notOnPath:
|
||||||
|
msg = printf( M2C(this.msgs.notOnPath.msg, 'bold'), ex.engine);
|
||||||
|
quit = false;
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.readError:
|
||||||
|
if (!ex.quiet) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file));
|
||||||
|
}
|
||||||
|
msg = ex.inner.toString();
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.mixedMerge:
|
||||||
|
msg = M2C(this.msgs.mixedMerge.msg);
|
||||||
|
quit = false;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invokeTemplate:
|
||||||
|
msg = M2C(this.msgs.invokeTemplate.msg, 'red');
|
||||||
|
msg += M2C( `\n${WRAP(ex.inner.toString(), { width: 60, indent: ' ' })}`, 'gray' );
|
||||||
|
etype = 'custom';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.compileTemplate:
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.themeLoad:
|
||||||
|
msg = M2C( printf( this.msgs.themeLoad.msg, ex.attempted.toUpperCase() ), 'red');
|
||||||
|
if (ex.inner && ex.inner.fluenterror) {
|
||||||
|
msg += M2C('\nError: ', 'red') + assembleError.call( this, ex.inner ).msg;
|
||||||
|
}
|
||||||
|
quit = true;
|
||||||
|
etype = 'custom';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.parseError:
|
||||||
|
if (SyntaxErrorEx.is(ex.inner)) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file ));
|
||||||
|
se = new SyntaxErrorEx(ex, ex.raw);
|
||||||
|
if ((se.line != null) && (se.col != null)) {
|
||||||
|
msg = printf(M2C( this.msgs.parseError.msg[0], 'red' ), se.line, se.col);
|
||||||
|
} else if (se.line != null) {
|
||||||
|
msg = printf(M2C( this.msgs.parseError.msg[1], 'red' ), se.line);
|
||||||
|
} else {
|
||||||
|
msg = M2C(this.msgs.parseError.msg[2], 'red');
|
||||||
|
}
|
||||||
|
} else if (ex.inner && (ex.inner.line != null) && (ex.inner.col != null)) {
|
||||||
|
msg = printf( M2C( this.msgs.parseError.msg[0], 'red' ), ex.inner.line, ex.inner.col);
|
||||||
|
} else {
|
||||||
|
msg = ex;
|
||||||
|
}
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.createError:
|
||||||
|
// inner.code could be EPERM, EACCES, etc
|
||||||
|
msg = printf(M2C( this.msgs.createError.msg ), ex.inner.path);
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.validateError:
|
||||||
|
msg = printf(M2C( this.msgs.validateError.msg ), ex.inner.toString());
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invalidOptionsFile:
|
||||||
|
msg = M2C(this.msgs.invalidOptionsFile.msg[0]);
|
||||||
|
if (SyntaxErrorEx.is(ex.inner)) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(printf( M2C(this.msgs.readError.msg, 'red'), ex.file ));
|
||||||
|
se = new SyntaxErrorEx(ex, ex.raw);
|
||||||
|
if ((se.line != null) && (se.col != null)) {
|
||||||
|
msg += printf(M2C( this.msgs.parseError.msg[0], 'red' ), se.line, se.col);
|
||||||
|
} else if (se.line != null) {
|
||||||
|
msg += printf(M2C( this.msgs.parseError.msg[1], 'red' ), se.line);
|
||||||
|
} else {
|
||||||
|
msg += M2C(this.msgs.parseError.msg[2], 'red');
|
||||||
|
}
|
||||||
|
} else if (ex.inner && (ex.inner.line != null) && (ex.inner.col != null)) {
|
||||||
|
msg += printf( M2C( this.msgs.parseError.msg[0], 'red' ), ex.inner.line, ex.inner.col);
|
||||||
|
} else {
|
||||||
|
msg += ex;
|
||||||
|
}
|
||||||
|
msg += this.msgs.invalidOptionsFile.msg[1];
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.optionsFileNotFound:
|
||||||
|
msg = M2C( this.msgs.optionsFileNotFound.msg );
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.unknownSchema:
|
||||||
|
msg = M2C( this.msgs.unknownSchema.msg[0] );
|
||||||
|
//msg += "\n" + M2C( @msgs.unknownSchema.msg[1], 'yellow' )
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.themeHelperLoad:
|
||||||
|
msg = printf(M2C( this.msgs.themeHelperLoad.msg ), ex.glob);
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HMSTATUS.invalidSchemaVersion:
|
||||||
|
msg = printf(M2C( this.msgs.invalidSchemaVersion.msg ), ex.data);
|
||||||
|
etype = 'error';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
msg, // The error message to display
|
||||||
|
withStack, // Whether to include the stack
|
||||||
|
quit,
|
||||||
|
etype
|
||||||
|
};
|
||||||
|
};
|
25
src/cli/help/analyze.txt
Normal file
25
src/cli/help/analyze.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
**analyze** | Analyze a resume for statistical insight
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume ANALYZE <resume>**
|
||||||
|
|
||||||
|
The ANALYZE command evaluates the specified resume(s) for
|
||||||
|
coverage, duration, gaps, keywords, and other metrics.
|
||||||
|
|
||||||
|
This command can be run against multiple resumes. Each
|
||||||
|
will be analyzed in turn.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<resume>**
|
||||||
|
|
||||||
|
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||||
|
specified, separated by spaces.
|
||||||
|
|
||||||
|
hackmyresume ANALYZE resume.json
|
||||||
|
hackmyresume ANALYZE r1.json r2.json r3.json
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**None.**
|
69
src/cli/help/build.txt
Normal file
69
src/cli/help/build.txt
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
**build** | Generate themed resumes in multiple formats
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume BUILD <resume> TO <target> [--theme]**
|
||||||
|
**[--pdf] [--no-escape] [--private]**
|
||||||
|
|
||||||
|
The BUILD command generates themed resumes and CVs in
|
||||||
|
multiple formats. Use it to create outbound resumes in
|
||||||
|
specific formats such HTML, MS Word, and PDF.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<resume>**
|
||||||
|
|
||||||
|
Path to a FRESH or JRS resume (*.json) containing your
|
||||||
|
resume data. Multiple resumes may be specified.
|
||||||
|
|
||||||
|
If multiple resumes are specified, they will be merged
|
||||||
|
into a single resume prior to transformation.
|
||||||
|
|
||||||
|
**<target>**
|
||||||
|
|
||||||
|
Path to the desired output resume. Multiple resumes
|
||||||
|
may be specified. The file extension will determine
|
||||||
|
the format.
|
||||||
|
|
||||||
|
.all Generate all supported formats
|
||||||
|
.html HTML 5
|
||||||
|
.doc MS Word
|
||||||
|
.pdf Adobe Acrobat PDF
|
||||||
|
.txt plain text
|
||||||
|
.md Markdown
|
||||||
|
.png PNG Image
|
||||||
|
.latex LaTeX
|
||||||
|
|
||||||
|
Note: not all formats are supported by all themes!
|
||||||
|
Check the theme's documentation for details or use
|
||||||
|
the .all extension to build all available formats.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**--theme -t <theme-name-or-path>**
|
||||||
|
|
||||||
|
Path to a FRESH or JSON Resume theme OR the name of a
|
||||||
|
built-in theme. Valid theme names are 'modern',
|
||||||
|
'positive', 'compact', 'awesome', and 'basis'.
|
||||||
|
|
||||||
|
**--pdf -p <engine>**
|
||||||
|
|
||||||
|
Specify the PDF engine to use. Legal values are
|
||||||
|
'none', 'wkhtmltopdf', 'phantom', or 'weasyprint'.
|
||||||
|
|
||||||
|
**--no-escape**
|
||||||
|
|
||||||
|
Disable escaping / encoding of resume data during
|
||||||
|
resume generation. Handlebars themes only.
|
||||||
|
|
||||||
|
**--private**
|
||||||
|
|
||||||
|
Include resume fields marked as private.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
The BUILD command can be run against multiple source as well
|
||||||
|
as multiple target resumes. If multiple source resumes are
|
||||||
|
provided, they will be merged into a single source resume
|
||||||
|
before generation. If multiple output resumes are provided,
|
||||||
|
each will be generated in turn.
|
33
src/cli/help/convert.txt
Normal file
33
src/cli/help/convert.txt
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
**convert** | Convert resumes between FRESH and JRS formats
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume CONVERT <resume> TO <target> [--format]**
|
||||||
|
|
||||||
|
The CONVERT command converts one or more resume documents
|
||||||
|
between the FRESH Resume Schema and JSON Resume formats.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<resume>**
|
||||||
|
|
||||||
|
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||||
|
specified.
|
||||||
|
|
||||||
|
**<targets>**
|
||||||
|
|
||||||
|
The path of the converted resume. Multiple resumes can
|
||||||
|
be specified, one per provided input resume.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**--format -f <fmt>**
|
||||||
|
|
||||||
|
The desired format for the new resume(s). Valid values
|
||||||
|
are 'FRESH', 'JRS', or, to target the latest edge
|
||||||
|
version of the JSON Resume Schema, 'JRS@1'.
|
||||||
|
|
||||||
|
If this parameter is omitted, the destination format
|
||||||
|
will be inferred from the source resume's format. If
|
||||||
|
the source format is FRESH, the destination format
|
||||||
|
will be JSON Resume, and vice-versa.
|
23
src/cli/help/help.txt
Normal file
23
src/cli/help/help.txt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
**help** | View help on a specific HackMyResume command
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume HELP [<command>]**
|
||||||
|
|
||||||
|
The HELP command displays help information for a specific
|
||||||
|
HackMyResume command, including the HELP command itself.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<command>**
|
||||||
|
|
||||||
|
The HackMyResume command to view help information for.
|
||||||
|
Must be BUILD, NEW, CONVERT, ANALYZE, VALIDATE, PEEK,
|
||||||
|
or HELP.
|
||||||
|
|
||||||
|
hackmyresume help convert
|
||||||
|
hackmyresume help help
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**None.**
|
29
src/cli/help/new.txt
Normal file
29
src/cli/help/new.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
**new** | Create a new FRESH or JRS resume document
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume NEW <fileName> [--format]**
|
||||||
|
|
||||||
|
The NEW command generates a new resume document in FRESH
|
||||||
|
or JSON Resume format. This document can serve as an
|
||||||
|
official source of truth for your resume and career data
|
||||||
|
as well an input to tools like HackMyResume.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<fileName>**
|
||||||
|
|
||||||
|
The filename (relative or absolute path) of the resume
|
||||||
|
to be created. Multiple resume paths can be specified,
|
||||||
|
and each will be created in turn.
|
||||||
|
|
||||||
|
hackmyresume NEW resume.json
|
||||||
|
hackmyresume NEW r1.json foo/r2.json ../r3.json
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**--format -f <fmt>**
|
||||||
|
|
||||||
|
The desired format for the new resume(s). Valid values
|
||||||
|
are 'FRESH', 'JRS', or, to target the latest edge
|
||||||
|
version of the JSON Resume Schema, 'JRS@1'.
|
31
src/cli/help/peek.txt
Normal file
31
src/cli/help/peek.txt
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
**peek** | View portions of a resume from the command line
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume PEEK <resume> <at>**
|
||||||
|
|
||||||
|
The PEEK command displays a specific piece or part of the
|
||||||
|
resume without requiring the resume to be opened in an
|
||||||
|
editor.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<resume>**
|
||||||
|
|
||||||
|
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||||
|
specified, separated by spaces.
|
||||||
|
|
||||||
|
hackmyresume PEEK r1.json r2.json r3.json "employment.history[2]"
|
||||||
|
|
||||||
|
**<at>**
|
||||||
|
|
||||||
|
The resume property or field to be displayed. Can be
|
||||||
|
any valid resume path, for example:
|
||||||
|
|
||||||
|
education[0]
|
||||||
|
info.name
|
||||||
|
employment.history[3].start
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**None.**
|
70
src/cli/help/use.txt
Normal file
70
src/cli/help/use.txt
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
**HackMyResume** | A Swiss Army knife for resumes and CVs
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume [--version] [--help] [--silent] [--debug]**
|
||||||
|
**[--options] [--no-colors] <command> [<args>]**
|
||||||
|
|
||||||
|
Commands: (type "hackmyresume help COMMAND" for details)
|
||||||
|
|
||||||
|
**BUILD** Build your resume to the destination format(s).
|
||||||
|
**ANALYZE** Analyze your resume for keywords, gaps, and metrics.
|
||||||
|
**VALIDATE** Validate your resume for errors and typos.
|
||||||
|
**NEW** Create a new resume in FRESH or JSON Resume format.
|
||||||
|
**CONVERT** Convert your resume between FRESH and JSON Resume.
|
||||||
|
**PEEK** View a specific field or element on your resume.
|
||||||
|
**HELP** View help on a specific HackMyResume command.
|
||||||
|
|
||||||
|
Common Tasks:
|
||||||
|
|
||||||
|
Generate a resume in a specific format (HTML, Word, PDF, etc.)
|
||||||
|
|
||||||
|
**hackmyresume build rez.json to out/rez.html**
|
||||||
|
**hackmyresume build rez.json to out/rez.doc**
|
||||||
|
**hackmyresume build rez.json to out/rez.pdf**
|
||||||
|
**hackmyresume build rez.json to out/rez.txt**
|
||||||
|
**hackmyresume build rez.json to out/rez.md**
|
||||||
|
**hackmyresume build rez.json to out/rez.png**
|
||||||
|
**hackmyresume build rez.json to out/rez.tex**
|
||||||
|
|
||||||
|
Build a resume to ALL available formats:
|
||||||
|
|
||||||
|
**hackmyresume build rez.json to out/rez.all**
|
||||||
|
|
||||||
|
Build a resume with a specific theme:
|
||||||
|
|
||||||
|
**hackmyresume build rez.json to out/rez.all -t themeName**
|
||||||
|
|
||||||
|
Create a new empty resume:
|
||||||
|
|
||||||
|
**hackmyresume new rez.json**
|
||||||
|
|
||||||
|
Convert a resume between FRESH and JRS formats:
|
||||||
|
|
||||||
|
**hackmyresume convert rez.json converted.json**
|
||||||
|
|
||||||
|
Analyze a resume for important metrics
|
||||||
|
|
||||||
|
**hackmyresume analyze rez.json**
|
||||||
|
|
||||||
|
Find more resume themes:
|
||||||
|
|
||||||
|
**https://www.npmjs.com/search?q=jsonresume-theme**
|
||||||
|
**https://www.npmjs.com/search?q=fresh-theme**
|
||||||
|
**https://github.com/fresh-standard/fresh-themes**
|
||||||
|
|
||||||
|
Validate a resume's structure and syntax:
|
||||||
|
|
||||||
|
**hackmyresume validate resume.json**
|
||||||
|
|
||||||
|
View help on a specific command:
|
||||||
|
|
||||||
|
**hackmyresume help [build|convert|new|analyze|validate|peek|help]**
|
||||||
|
|
||||||
|
Submit a bug or request:
|
||||||
|
|
||||||
|
**https://githut.com/hacksalot/HackMyResume/issues**
|
||||||
|
|
||||||
|
HackMyResume is free and open source software published
|
||||||
|
under the MIT license. For more information, visit the
|
||||||
|
HackMyResume website or GitHub project page.
|
26
src/cli/help/validate.txt
Normal file
26
src/cli/help/validate.txt
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
**validate** | Validate a resume for correctness
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
**hackmyresume VALIDATE <resume> [--assert]**
|
||||||
|
|
||||||
|
The VALIDATE command validates a FRESH or JRS document
|
||||||
|
against its governing schema, verifying that the resume
|
||||||
|
is correctly structured and formatted.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
|
||||||
|
**<resume>**
|
||||||
|
|
||||||
|
Path to a FRESH or JRS resume. Multiple resumes can be
|
||||||
|
specified.
|
||||||
|
|
||||||
|
hackmyresume ANALYZE resume.json
|
||||||
|
hackmyresume ANALYZE r1.json r2.json r3.json
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
**--assert -a**
|
||||||
|
|
||||||
|
Tell HackMyResume to return a non-zero process exit
|
||||||
|
code if a resume fails to validate.
|
22
src/cli/index.js
Normal file
22
src/cli/index.js
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Command-line interface (CLI) for HackMyResume.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module index.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
require('./main')( process.argv );
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( ex ) {
|
||||||
|
|
||||||
|
require('./error').err( ex, true );
|
||||||
|
|
||||||
|
}
|
421
src/cli/main.js
Normal file
421
src/cli/main.js
Normal file
@ -0,0 +1,421 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the `main` function.
|
||||||
|
@module cli/main
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const HMR = require('../index');
|
||||||
|
const PKG = require('../../package.json');
|
||||||
|
const FS = require('fs');
|
||||||
|
const EXTEND = require('extend');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
const PATH = require('path');
|
||||||
|
const HMSTATUS = require('../core/status-codes');
|
||||||
|
const safeLoadJSON = require('../utils/safe-json-loader');
|
||||||
|
//StringUtils = require '../utils/string.js'
|
||||||
|
const _ = require('underscore');
|
||||||
|
const OUTPUT = require('./out');
|
||||||
|
const PAD = require('string-padding');
|
||||||
|
const { Command } = require('commander');
|
||||||
|
const M2C = require('../utils/md2chalk');
|
||||||
|
const printf = require('printf');
|
||||||
|
const _opts = { };
|
||||||
|
const _title = chalk.white.bold(`\n*** HackMyResume v${PKG.version} ***`);
|
||||||
|
const _out = new OUTPUT( _opts );
|
||||||
|
const _err = require('./error');
|
||||||
|
let _exitCallback = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
A callable implementation of the HackMyResume CLI. Encapsulates the command
|
||||||
|
line interface as a single method accepting a parameter array.
|
||||||
|
@alias module:cli/main.main
|
||||||
|
@param rawArgs {Array} An array of command-line parameters. Will either be
|
||||||
|
process.argv (in production) or custom parameters (in test).
|
||||||
|
*/
|
||||||
|
module.exports = function( rawArgs, exitCallback ) {
|
||||||
|
|
||||||
|
const initInfo = initialize( rawArgs, exitCallback );
|
||||||
|
if (initInfo === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { args } = initInfo;
|
||||||
|
|
||||||
|
// Create the top-level (application) command...
|
||||||
|
const program = new Command('hackmyresume')
|
||||||
|
.version(PKG.version)
|
||||||
|
.description(chalk.yellow.bold('*** HackMyResume ***'))
|
||||||
|
.option('-s --silent', 'Run in silent mode')
|
||||||
|
.option('--no-color', 'Disable colors')
|
||||||
|
.option('--color', 'Enable colors')
|
||||||
|
.option('-d --debug', 'Enable diagnostics', false)
|
||||||
|
.option('-a --assert', 'Treat warnings as errors', false)
|
||||||
|
.option('-v --version', 'Show the version')
|
||||||
|
.allowUnknownOption();
|
||||||
|
program.jsonArgs = initInfo.options;
|
||||||
|
|
||||||
|
// Create the NEW command
|
||||||
|
program
|
||||||
|
.command('new')
|
||||||
|
.arguments('<sources...>')
|
||||||
|
.option('-f --format <fmt>', 'FRESH or JRS format', 'FRESH')
|
||||||
|
.alias('create')
|
||||||
|
.description('Create resume(s) in FRESH or JSON RESUME format.')
|
||||||
|
.action((function( sources ) {
|
||||||
|
execute.call( this, sources, [], this.opts(), logMsg);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create the VALIDATE command
|
||||||
|
program
|
||||||
|
.command('validate')
|
||||||
|
.arguments('<sources...>')
|
||||||
|
.description('Validate a resume in FRESH or JSON RESUME format.')
|
||||||
|
.action(function(sources) {
|
||||||
|
execute.call( this, sources, [], this.opts(), logMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the CONVERT command
|
||||||
|
program
|
||||||
|
.command('convert')
|
||||||
|
.description('Convert a resume to/from FRESH or JSON RESUME format.')
|
||||||
|
.option('-f --format <fmt>', 'FRESH or JRS format and optional version', undefined)
|
||||||
|
.action(function() {
|
||||||
|
const x = splitSrcDest.call( this );
|
||||||
|
execute.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the ANALYZE command
|
||||||
|
program
|
||||||
|
.command('analyze')
|
||||||
|
.arguments('<sources...>')
|
||||||
|
.option('--private', 'Include resume fields marked as private', false)
|
||||||
|
.description('Analyze one or more resumes.')
|
||||||
|
.action(function( sources ) {
|
||||||
|
execute.call( this, sources, [], this.opts(), logMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the PEEK command
|
||||||
|
program
|
||||||
|
.command('peek')
|
||||||
|
.arguments('<sources...>')
|
||||||
|
.description('Peek at a resume field or section')
|
||||||
|
//.action(( sources, sectionOrField ) ->
|
||||||
|
.action(function( sources ) {
|
||||||
|
const dst = (sources && (sources.length > 1)) ? [sources.pop()] : [];
|
||||||
|
execute.call( this, sources, dst, this.opts(), logMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the BUILD command
|
||||||
|
program
|
||||||
|
.command('build')
|
||||||
|
.alias('generate')
|
||||||
|
.option('-t --theme <theme>', 'Theme name or path')
|
||||||
|
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
||||||
|
.option('-c --css <option>', 'CSS linking / embedding')
|
||||||
|
.option('-p --pdf <engine>', 'PDF generation engine')
|
||||||
|
.option('--no-sort', 'Sort resume sections by date', false)
|
||||||
|
.option('--tips', 'Display theme tips and warnings.', false)
|
||||||
|
.option('--private', 'Include resume fields marked as private', false)
|
||||||
|
.option('--no-escape', 'Turn off encoding in Handlebars themes.', false)
|
||||||
|
.description('Generate resume to multiple formats')
|
||||||
|
//.action(( sources, targets, options ) ->
|
||||||
|
.action(function() {
|
||||||
|
const x = splitSrcDest.call( this );
|
||||||
|
execute.call( this, x.src, x.dst, this.opts(), logMsg);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the HELP command
|
||||||
|
program
|
||||||
|
.command('help')
|
||||||
|
.arguments('[command]')
|
||||||
|
.description('Get help on a HackMyResume command')
|
||||||
|
.action(function( cmd ) {
|
||||||
|
cmd = cmd || 'use';
|
||||||
|
const manPage = FS.readFileSync(
|
||||||
|
PATH.join(__dirname, `help/${cmd}.txt`),
|
||||||
|
'utf8');
|
||||||
|
_out.log(M2C(manPage, 'white', 'yellow.bold'));
|
||||||
|
});
|
||||||
|
|
||||||
|
program.parse( args );
|
||||||
|
|
||||||
|
if (!program.args.length) {
|
||||||
|
throw {fluenterror: 4};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Massage command-line args and setup Commander.js. */
|
||||||
|
var initialize = function( ar, exitCallback ) {
|
||||||
|
|
||||||
|
_exitCallback = exitCallback || process.exit;
|
||||||
|
const o = initOptions(ar);
|
||||||
|
if (o.ex) {
|
||||||
|
_err.init(false, true, false);
|
||||||
|
if( o.ex.op === 'parse' ) {
|
||||||
|
_err.err({
|
||||||
|
fluenterror: o.ex.op === 'parse' ? HMSTATUS.invalidOptionsFile : HMSTATUS.optionsFileNotFound,
|
||||||
|
inner: o.ex.inner,
|
||||||
|
quit: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_err.err({fluenterror: HMSTATUS.optionsFileNotFound, inner: o.ex.inner, quit: true});
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
o.silent || logMsg( _title );
|
||||||
|
|
||||||
|
// Emit debug prelude if --debug was specified
|
||||||
|
if (o.debug) {
|
||||||
|
_out.log(chalk.cyan('The -d or --debug switch was specified. DEBUG mode engaged.'));
|
||||||
|
_out.log('');
|
||||||
|
_out.log(chalk.cyan(PAD(' Platform:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.platform === 'win32' ? 'windows' : process.platform ));
|
||||||
|
_out.log(chalk.cyan(PAD(' Node.js:',25, null, PAD.RIGHT)) + chalk.cyan.bold( process.version ));
|
||||||
|
_out.log(chalk.cyan(PAD(' HackMyResume:',25, null, PAD.RIGHT)) + chalk.cyan.bold(`v${PKG.version}` ));
|
||||||
|
_out.log(chalk.cyan(PAD(' FRESCA:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies.fresca ));
|
||||||
|
//_out.log(chalk.cyan(PAD(' fresh-themes:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-themes'] ))
|
||||||
|
//_out.log(chalk.cyan(PAD(' fresh-jrs-converter:',25, null, PAD.RIGHT)) + chalk.cyan.bold( PKG.dependencies['fresh-jrs-converter'] ))
|
||||||
|
_out.log('');
|
||||||
|
}
|
||||||
|
|
||||||
|
_err.init(o.debug, o.assert, o.silent);
|
||||||
|
|
||||||
|
// Handle invalid verbs here (a bit easier here than in commander.js)...
|
||||||
|
if (o.verb && !HMR.verbs[ o.verb ] && !HMR.alias[ o.verb ] && (o.verb !== 'help')) {
|
||||||
|
_err.err({fluenterror: HMSTATUS.invalidCommand, quit: true, attempted: o.orgVerb}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Override the .missingArgument behavior
|
||||||
|
Command.prototype.missingArgument = function() {
|
||||||
|
if (this.name() !== 'help') {
|
||||||
|
_err.err({
|
||||||
|
verb: this.name(),
|
||||||
|
fluenterror: HMSTATUS.resumeNotFound
|
||||||
|
}
|
||||||
|
, true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Override the .helpInformation behavior
|
||||||
|
Command.prototype.helpInformation = function() {
|
||||||
|
const manPage = FS.readFileSync(
|
||||||
|
PATH.join(__dirname, 'help/use.txt'), 'utf8' );
|
||||||
|
return M2C(manPage, 'white', 'yellow');
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
args: o.args,
|
||||||
|
options: o.json
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Init options prior to setting up command infrastructure. */
|
||||||
|
var initOptions = function( ar ) {
|
||||||
|
|
||||||
|
let oJSON, oVerb;
|
||||||
|
oVerb;
|
||||||
|
let verb = '';
|
||||||
|
const args = ar.slice();
|
||||||
|
const cleanArgs = args.slice( 2 );
|
||||||
|
oJSON;
|
||||||
|
|
||||||
|
if (cleanArgs.length) {
|
||||||
|
|
||||||
|
// Support case-insensitive sub-commands (build, generate, validate, etc)
|
||||||
|
const vidx = _.findIndex(cleanArgs, v => v[0] !== '-');
|
||||||
|
if (vidx !== -1) {
|
||||||
|
oVerb = cleanArgs[ vidx ];
|
||||||
|
verb = (args[ vidx + 2 ] = oVerb.trim().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove --options --opts -o and process separately
|
||||||
|
const optsIdx = _.findIndex(cleanArgs, v => (v === '-o') || (v === '--options') || (v === '--opts'));
|
||||||
|
|
||||||
|
if (optsIdx !== -1) {
|
||||||
|
let optStr = cleanArgs[ optsIdx + 1];
|
||||||
|
args.splice( optsIdx + 2, 2 );
|
||||||
|
if (optStr && (optStr = optStr.trim())) {
|
||||||
|
//var myJSON = JSON.parse(optStr);
|
||||||
|
if( optStr[0] === '{') {
|
||||||
|
// TODO: remove use of evil(). - hacksalot
|
||||||
|
/* jshint ignore:start */
|
||||||
|
oJSON = eval(`(${optStr})`); // jshint ignore:line <-- no worky
|
||||||
|
/* jshint ignore:end */
|
||||||
|
} else {
|
||||||
|
const inf = safeLoadJSON( optStr );
|
||||||
|
if( !inf.ex ) {
|
||||||
|
oJSON = inf.json;
|
||||||
|
} else {
|
||||||
|
return inf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grab the --debug flag, --silent, --assert and --no-color flags
|
||||||
|
const isDebug = _.some(args, v => (v === '-d') || (v === '--debug'));
|
||||||
|
const isSilent = _.some(args, v => (v === '-s') || (v === '--silent'));
|
||||||
|
const isAssert = _.some(args, v => (v === '-a') || (v === '--assert'));
|
||||||
|
const isMono = _.some(args, v => v === '--no-color');
|
||||||
|
const isNoEscape = _.some(args, v => v === '--no-escape');
|
||||||
|
|
||||||
|
return {
|
||||||
|
color: !isMono,
|
||||||
|
debug: isDebug,
|
||||||
|
silent: isSilent,
|
||||||
|
assert: isAssert,
|
||||||
|
noescape: isNoEscape,
|
||||||
|
orgVerb: oVerb,
|
||||||
|
verb,
|
||||||
|
json: oJSON,
|
||||||
|
args
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Invoke a HackMyResume verb. */
|
||||||
|
var execute = function( src, dst, opts, log ) {
|
||||||
|
|
||||||
|
// Create the verb
|
||||||
|
const v = new (HMR.verbs[ this.name() ])();
|
||||||
|
|
||||||
|
// Initialize command-specific options
|
||||||
|
loadOptions.call(this, opts, this.parent.jsonArgs);
|
||||||
|
|
||||||
|
// Set up error/output handling
|
||||||
|
_opts.errHandler = v;
|
||||||
|
_out.init(_opts);
|
||||||
|
|
||||||
|
// Hook up event notifications
|
||||||
|
v.on('hmr:status', function() { return _out.do.apply(_out, arguments); });
|
||||||
|
v.on('hmr:error', function() { return _err.err.apply(_err, arguments); });
|
||||||
|
|
||||||
|
// Invoke the verb using promise syntax
|
||||||
|
const prom = v.invoke.call(v, src, dst, _opts, log);
|
||||||
|
prom.then(executeSuccess, executeFail);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Success handler for verb invocations. Calls process.exit by default */
|
||||||
|
var executeSuccess = function() {};
|
||||||
|
// Can't call _exitCallback here (process.exit) when PDF is running in BK
|
||||||
|
//_exitCallback 0; return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Failure handler for verb invocations. Calls process.exit by default */
|
||||||
|
var executeFail = function(err) {
|
||||||
|
//console.dir err
|
||||||
|
let finalErrorCode = -1;
|
||||||
|
if (err) {
|
||||||
|
if (err.fluenterror) {
|
||||||
|
finalErrorCode = err.fluenterror;
|
||||||
|
} else if (err.length) {
|
||||||
|
finalErrorCode = err[0].fluenterror;
|
||||||
|
} else {
|
||||||
|
finalErrorCode = err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_opts.debug) {
|
||||||
|
const msgs = require('./msg').errors;
|
||||||
|
logMsg(printf(M2C( msgs.exiting.msg, 'cyan' ), finalErrorCode));
|
||||||
|
if (err.stack) { logMsg(err.stack); }
|
||||||
|
}
|
||||||
|
_exitCallback(finalErrorCode);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Initialize HackMyResume options.
|
||||||
|
TODO: Options loading is a little hacky, for two reasons:
|
||||||
|
- Commander.js idiosyncracies
|
||||||
|
- Need to accept JSON inputs from the command line.
|
||||||
|
*/
|
||||||
|
var loadOptions = function( o, cmdO ) {
|
||||||
|
|
||||||
|
// o and this.opts() seem to be the same (command-specific options)
|
||||||
|
|
||||||
|
// Load the specified options file (if any) and apply options
|
||||||
|
if( cmdO ) {
|
||||||
|
o = EXTEND(true, o, cmdO);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge in command-line options
|
||||||
|
o = EXTEND( true, o, this.opts() );
|
||||||
|
|
||||||
|
// Kludge parent-level options until piping issue is resolved
|
||||||
|
if ((this.parent.silent !== undefined) && (this.parent.silent !== null)) {
|
||||||
|
o.silent = this.parent.silent;
|
||||||
|
}
|
||||||
|
if ((this.parent.debug !== undefined) && (this.parent.debug !== null)) {
|
||||||
|
o.debug = this.parent.debug;
|
||||||
|
}
|
||||||
|
if ((this.parent.assert !== undefined) && (this.parent.assert !== null)) {
|
||||||
|
o.assert = this.parent.assert;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.debug) {
|
||||||
|
logMsg(chalk.cyan('OPTIONS:') + '\n');
|
||||||
|
_.each(o, (val, key) =>
|
||||||
|
logMsg(chalk.cyan(' %s') + chalk.cyan.bold(' %s'),
|
||||||
|
PAD(key,22,null,PAD.RIGHT), val)
|
||||||
|
);
|
||||||
|
logMsg('');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cache
|
||||||
|
EXTEND( true, _opts, o );
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Split multiple command-line filenames by the 'TO' keyword */
|
||||||
|
var splitSrcDest = function() {
|
||||||
|
|
||||||
|
const params = this.parent.args.filter(j => String.is(j));
|
||||||
|
if (params.length === 0) {
|
||||||
|
//tmpName = @name()
|
||||||
|
throw { fluenterror: HMSTATUS.resumeNotFound, verb: this.name(), quit: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the TO keyword, if any
|
||||||
|
const splitAt = _.findIndex( params, p => p.toLowerCase() === 'to');
|
||||||
|
|
||||||
|
// TO can't be the last keyword
|
||||||
|
if ((splitAt === (params.length - 1)) && (splitAt !== -1)) {
|
||||||
|
logMsg(chalk.yellow('Please ') +
|
||||||
|
chalk.yellow.bold('specify an output file') +
|
||||||
|
chalk.yellow(' for this operation or ') +
|
||||||
|
chalk.yellow.bold('omit the TO keyword') +
|
||||||
|
chalk.yellow('.') );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
src: params.slice(0, splitAt === -1 ? undefined : splitAt ),
|
||||||
|
dst: splitAt === -1 ? [] : params.slice( splitAt + 1 )
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Simple logging placeholder. */
|
||||||
|
var logMsg = function() {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
return _opts.silent || console.log.apply( console.log, arguments );
|
||||||
|
};
|
10
src/cli/msg.js
Normal file
10
src/cli/msg.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
Message-handling routines for HackMyResume.
|
||||||
|
@module cli/msg
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const PATH = require('path');
|
||||||
|
const YAML = require('yamljs');
|
||||||
|
module.exports = YAML.load(PATH.join(__dirname, 'msg.yml'));
|
141
src/cli/msg.yml
Normal file
141
src/cli/msg.yml
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
events:
|
||||||
|
begin:
|
||||||
|
msg: Invoking **%s** command.
|
||||||
|
beforeCreate:
|
||||||
|
msg: Creating new **%s** resume: **%s**
|
||||||
|
afterCreate:
|
||||||
|
msg: Creating new **%s** resume: **%s**
|
||||||
|
afterRead:
|
||||||
|
msg: Reading **%s** resume: **%s**
|
||||||
|
beforeTheme:
|
||||||
|
msg: Verifying **%s** theme.
|
||||||
|
afterTheme:
|
||||||
|
msg: Verifying outputs: ???
|
||||||
|
beforeMerge:
|
||||||
|
msg:
|
||||||
|
- "Merging **%s**"
|
||||||
|
- " onto **%s**"
|
||||||
|
applyTheme:
|
||||||
|
msg: Applying **%s** theme (**%s** format%s)
|
||||||
|
afterBuild:
|
||||||
|
msg:
|
||||||
|
- "The **%s** theme says:"
|
||||||
|
- |
|
||||||
|
"For best results view JSON Resume themes over a
|
||||||
|
local or remote HTTP connection. For example:
|
||||||
|
|
||||||
|
npm install http-server -g
|
||||||
|
http-server <resume-folder>
|
||||||
|
|
||||||
|
For more information, see the README."
|
||||||
|
afterGenerate:
|
||||||
|
msg:
|
||||||
|
- " (with %s)"
|
||||||
|
- "Skipping %s resume: %s"
|
||||||
|
- "Generating **%s** resume: **%s**"
|
||||||
|
beforeAnalyze:
|
||||||
|
msg: "Analyzing **%s** resume: **%s**"
|
||||||
|
beforeConvert:
|
||||||
|
msg: "Converting **%s** (**%s**) to **%s** (**%s**)"
|
||||||
|
afterValidate:
|
||||||
|
msg:
|
||||||
|
- "Validating **%s** against the **%s** schema: "
|
||||||
|
- "VALID!"
|
||||||
|
- "INVALID"
|
||||||
|
- "BROKEN"
|
||||||
|
- "MISSING"
|
||||||
|
- "ERROR"
|
||||||
|
beforePeek:
|
||||||
|
msg:
|
||||||
|
- Peeking at **%s** in **%s**
|
||||||
|
- Peeking at **%s**
|
||||||
|
afterPeek:
|
||||||
|
msg: "The specified key **%s** was not found in **%s**."
|
||||||
|
afterInlineConvert:
|
||||||
|
msg: Converting **%s** to **%s** format.
|
||||||
|
errors:
|
||||||
|
themeNotFound:
|
||||||
|
msg: >
|
||||||
|
**Couldn't find the '%s' theme.** Please specify the name of a preinstalled
|
||||||
|
FRESH theme or the path to a locally installed FRESH or JSON Resume theme.
|
||||||
|
copyCSS:
|
||||||
|
msg: Couldn't copy CSS file to destination folder.
|
||||||
|
resumeNotFound:
|
||||||
|
msg: Please **feed me a resume** in FRESH or JSON Resume format.
|
||||||
|
missingCommand:
|
||||||
|
msg: Please **give me a command**
|
||||||
|
invalidCommand:
|
||||||
|
msg: Invalid command: '%s'
|
||||||
|
resumeNotFoundAlt:
|
||||||
|
msg: Please **feed me a resume** in either FRESH or JSON Resume format.
|
||||||
|
inputOutputParity:
|
||||||
|
msg: Please **specify an output file name** for every input file you wish to convert.
|
||||||
|
createNameMissing:
|
||||||
|
msg: Please **specify the filename** of the resume to create.
|
||||||
|
pdfGeneration:
|
||||||
|
msg: PDF generation failed. Make sure wkhtmltopdf is installed and accessible from your path.
|
||||||
|
invalid:
|
||||||
|
msg: Validation failed and the --assert option was specified.
|
||||||
|
invalidFormat:
|
||||||
|
msg: The **%s** theme doesn't support the **%s** format.
|
||||||
|
notOnPath:
|
||||||
|
msg: %s wasn't found on your system path or is inaccessible. PDF not generated.
|
||||||
|
readError:
|
||||||
|
msg: Reading **???** resume: **%s**
|
||||||
|
parseError:
|
||||||
|
msg:
|
||||||
|
- Invalid or corrupt JSON on line %s column %s.
|
||||||
|
- Invalid or corrupt JSON on line %s.
|
||||||
|
- Invalid or corrupt JSON.
|
||||||
|
invalidHelperUse:
|
||||||
|
msg: "**Warning**: Incorrect use of the **%s** theme helper."
|
||||||
|
fileSaveError:
|
||||||
|
msg: An error occurred while writing %s to disk: %s.
|
||||||
|
mixedMerge:
|
||||||
|
msg: "**Warning:** merging mixed resume types. Errors may occur."
|
||||||
|
invokeTemplate:
|
||||||
|
msg: "An error occurred during template invocation."
|
||||||
|
compileTemplate:
|
||||||
|
msg: "An error occurred during template compilation."
|
||||||
|
themeLoad:
|
||||||
|
msg: "Applying **%s** theme (? formats)"
|
||||||
|
invalidParamCount:
|
||||||
|
msg: "Invalid number of parameters. Expected: **%s**."
|
||||||
|
missingParam:
|
||||||
|
msg: The '**%s**' parameter was needed but not supplied.
|
||||||
|
createError:
|
||||||
|
msg: Failed to create **'%s'**.
|
||||||
|
exiting:
|
||||||
|
msg: Exiting with status code **%s**.
|
||||||
|
validateError:
|
||||||
|
msg: "An error occurred during validation:\n%s"
|
||||||
|
invalidOptionsFile:
|
||||||
|
msg:
|
||||||
|
- "The specified options file is invalid:\n"
|
||||||
|
- "\nMake sure the options file contains valid JSON."
|
||||||
|
optionsFileNotFound:
|
||||||
|
msg: "The specified options file is missing or inaccessible."
|
||||||
|
unknownSchema:
|
||||||
|
msg:
|
||||||
|
- "Unknown resume schema. Did you specify a valid FRESH or JRS resume?"
|
||||||
|
- |
|
||||||
|
At a minimum, a FRESH resume must include a "name" field and a "meta"
|
||||||
|
property.
|
||||||
|
|
||||||
|
"name": "John Doe",
|
||||||
|
"meta": {
|
||||||
|
"format": "FRESH@0.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
JRS-format resumes must include a "basics" section with a "name":
|
||||||
|
|
||||||
|
"basics": {
|
||||||
|
"name": "John Doe"
|
||||||
|
}
|
||||||
|
themeHelperLoad:
|
||||||
|
msg: >-
|
||||||
|
An error occurred while attempting to load the '%s' theme helper. Is the
|
||||||
|
theme correctly installed?
|
||||||
|
dummy: dontcare
|
||||||
|
invalidSchemaVersion:
|
||||||
|
msg: "'%s' is not recognized as a valid schema version."
|
204
src/cli/out.js
Normal file
204
src/cli/out.js
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Output routines for HackMyResume.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module cli/out
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const chalk = require('chalk');
|
||||||
|
const HME = require('../core/event-codes');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const M2C = require('../utils/md2chalk.js');
|
||||||
|
const PATH = require('path');
|
||||||
|
const FS = require('fs');
|
||||||
|
const EXTEND = require('extend');
|
||||||
|
const HANDLEBARS = require('handlebars');
|
||||||
|
const YAML = require('yamljs');
|
||||||
|
let printf = require('printf');
|
||||||
|
const pad = require('string-padding');
|
||||||
|
const dbgStyle = 'cyan';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** A stateful output module. All HMR console output handled here. */
|
||||||
|
class OutputHandler {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
constructor( opts ) {
|
||||||
|
this.init(opts);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
init(opts) {
|
||||||
|
this.opts = EXTEND( true, this.opts || { }, opts );
|
||||||
|
this.msgs = YAML.load(PATH.join( __dirname, 'msg.yml' )).events;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
log() {
|
||||||
|
printf = require('printf');
|
||||||
|
const finished = printf.apply( printf, arguments );
|
||||||
|
return this.opts.silent || console.log( finished ); // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
do( evt ) {
|
||||||
|
|
||||||
|
const that = this;
|
||||||
|
const L = function() { return that.log.apply( that, arguments ); };
|
||||||
|
|
||||||
|
switch (evt.sub) {
|
||||||
|
|
||||||
|
case HME.begin:
|
||||||
|
return this.opts.debug &&
|
||||||
|
L( M2C( this.msgs.begin.msg, dbgStyle), evt.cmd.toUpperCase() );
|
||||||
|
|
||||||
|
//when HME.beforeCreate
|
||||||
|
//L( M2C( this.msgs.beforeCreate.msg, 'green' ), evt.fmt, evt.file )
|
||||||
|
//break;
|
||||||
|
|
||||||
|
case HME.afterCreate:
|
||||||
|
L( M2C( this.msgs.beforeCreate.msg, evt.isError ? 'red' : 'green' ), evt.fmt, evt.file );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.beforeTheme:
|
||||||
|
return this.opts.debug &&
|
||||||
|
L( M2C( this.msgs.beforeTheme.msg, dbgStyle), evt.theme.toUpperCase() );
|
||||||
|
|
||||||
|
case HME.afterParse:
|
||||||
|
return L( M2C( this.msgs.afterRead.msg, 'gray', 'white.dim'), evt.fmt.toUpperCase(), evt.file );
|
||||||
|
|
||||||
|
case HME.beforeMerge:
|
||||||
|
var msg = '';
|
||||||
|
evt.f.reverse().forEach(function( a, idx ) {
|
||||||
|
return msg += printf( (idx === 0 ? this.msgs.beforeMerge.msg[0] : this.msgs.beforeMerge.msg[1]), a.file );
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
return L( M2C(msg, (evt.mixed ? 'yellow' : 'gray'), 'white.dim') );
|
||||||
|
|
||||||
|
case HME.applyTheme:
|
||||||
|
this.theme = evt.theme;
|
||||||
|
var numFormats = Object.keys( evt.theme.formats ).length;
|
||||||
|
return L( M2C(this.msgs.applyTheme.msg,
|
||||||
|
evt.status === 'error' ? 'red' : 'gray',
|
||||||
|
evt.status === 'error' ? 'bold' : 'white.dim'),
|
||||||
|
evt.theme.name.toUpperCase(),
|
||||||
|
numFormats, numFormats === 1 ? '' : 's' );
|
||||||
|
|
||||||
|
case HME.end:
|
||||||
|
if (evt.cmd === 'build') {
|
||||||
|
const themeName = this.theme.name.toUpperCase();
|
||||||
|
if (this.opts.tips && (this.theme.message || this.theme.render)) {
|
||||||
|
if (this.theme.message) {
|
||||||
|
L( M2C( this.msgs.afterBuild.msg[0], 'cyan' ), themeName );
|
||||||
|
return L( M2C( this.theme.message, 'white' ));
|
||||||
|
} else if (this.theme.render) {
|
||||||
|
L( M2C( this.msgs.afterBuild.msg[0], 'cyan'), themeName);
|
||||||
|
return L( M2C( this.msgs.afterBuild.msg[1], 'white'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HME.afterGenerate:
|
||||||
|
var suffix = '';
|
||||||
|
if (evt.fmt === 'pdf') {
|
||||||
|
if (this.opts.pdf) {
|
||||||
|
if (this.opts.pdf !== 'none') {
|
||||||
|
suffix = printf( M2C( this.msgs.afterGenerate.msg[0], evt.error ? 'red' : 'green' ), this.opts.pdf );
|
||||||
|
} else {
|
||||||
|
L( M2C( this.msgs.afterGenerate.msg[1], 'gray' ), evt.fmt.toUpperCase(), evt.file );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return L( M2C( this.msgs.afterGenerate.msg[2] + suffix, evt.error ? 'red' : 'green' ),
|
||||||
|
pad( evt.fmt.toUpperCase(),4,null,pad.RIGHT ),
|
||||||
|
PATH.relative( process.cwd(), evt.file ) );
|
||||||
|
|
||||||
|
case HME.beforeAnalyze:
|
||||||
|
return L( M2C( this.msgs.beforeAnalyze.msg, 'green' ), evt.fmt, evt.file);
|
||||||
|
|
||||||
|
case HME.afterAnalyze:
|
||||||
|
var { info } = evt;
|
||||||
|
var rawTpl = FS.readFileSync( PATH.join( __dirname, 'analyze.hbs' ), 'utf8');
|
||||||
|
HANDLEBARS.registerHelper( require('../helpers/console-helpers') );
|
||||||
|
var template = HANDLEBARS.compile(rawTpl, { strict: false, assumeObjects: false });
|
||||||
|
var tot = 0;
|
||||||
|
info.keywords.forEach(g => tot += g.count);
|
||||||
|
info.keywords.totalKeywords = tot;
|
||||||
|
var output = template( info );
|
||||||
|
return this.log( chalk.cyan(output) );
|
||||||
|
|
||||||
|
case HME.beforeConvert:
|
||||||
|
return L( M2C( this.msgs.beforeConvert.msg, evt.error ? 'red' : 'green' ),
|
||||||
|
evt.srcFile, evt.srcFmt, evt.dstFile, evt.dstFmt
|
||||||
|
);
|
||||||
|
|
||||||
|
case HME.afterInlineConvert:
|
||||||
|
return L( M2C( this.msgs.afterInlineConvert.msg, 'gray', 'white.dim' ),
|
||||||
|
evt.file, evt.fmt );
|
||||||
|
|
||||||
|
case HME.afterValidate:
|
||||||
|
var style = 'red';
|
||||||
|
var adj = '';
|
||||||
|
var msgs = this.msgs.afterValidate.msg;
|
||||||
|
switch (evt.status) {
|
||||||
|
case 'valid': style = 'green'; adj = msgs[1]; break;
|
||||||
|
case 'invalid': style = 'yellow'; adj = msgs[2]; break;
|
||||||
|
case 'broken': style = 'red'; adj = msgs[3]; break;
|
||||||
|
case 'missing': style = 'red'; adj = msgs[4]; break;
|
||||||
|
case 'unknown': style = 'red'; adj = msgs[5]; break;
|
||||||
|
}
|
||||||
|
evt.schema = evt.schema.replace('jars','JSON Resume').toUpperCase();
|
||||||
|
L(M2C( msgs[0], 'white' ) + chalk[style].bold(adj), evt.file, evt.schema);
|
||||||
|
|
||||||
|
if (evt.violations) {
|
||||||
|
_.each(evt.violations, function(err) {
|
||||||
|
L( chalk.yellow.bold('--> ') +
|
||||||
|
chalk.yellow(err.field.replace('data.','resume.').toUpperCase() +
|
||||||
|
' ' + err.message));
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
case HME.afterPeek:
|
||||||
|
var sty = evt.error ? 'red' : ( evt.target !== undefined ? 'green' : 'yellow' );
|
||||||
|
|
||||||
|
// "Peeking at 'someKey' in 'someFile'."
|
||||||
|
if (evt.requested) {
|
||||||
|
L(M2C(this.msgs.beforePeek.msg[0], sty), evt.requested, evt.file);
|
||||||
|
} else {
|
||||||
|
L(M2C(this.msgs.beforePeek.msg[1], sty), evt.file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the key was present, print it
|
||||||
|
if ((evt.target !== undefined) && !evt.error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
return console.dir( evt.target, { depth: null, colors: true } );
|
||||||
|
|
||||||
|
// If the key was not present, but no error occurred, print it
|
||||||
|
} else if (!evt.error) {
|
||||||
|
return L(M2C( this.msgs.afterPeek.msg, 'yellow'), evt.requested, evt.file);
|
||||||
|
|
||||||
|
} else if (evt.error) {
|
||||||
|
return L(chalk.red( evt.error.inner.inner ));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = OutputHandler;
|
@ -1,419 +0,0 @@
|
|||||||
/**
|
|
||||||
FRESH to JSON Resume conversion routiens.
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
@module convert.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function(){ // TODO: refactor everything
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert between FRESH and JRS resume/CV formats.
|
|
||||||
@class FRESHConverter
|
|
||||||
*/
|
|
||||||
var FRESHConverter = module.exports = {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert from JSON Resume format to FRESH.
|
|
||||||
@method toFresh
|
|
||||||
@todo Refactor
|
|
||||||
*/
|
|
||||||
toFRESH: function( src, foreign ) {
|
|
||||||
|
|
||||||
foreign = (foreign === undefined || foreign === null) ? true : foreign;
|
|
||||||
|
|
||||||
return {
|
|
||||||
name: src.basics.name,
|
|
||||||
imp: src.basics.imp,
|
|
||||||
info: {
|
|
||||||
label: src.basics.label,
|
|
||||||
class: src.basics.class, // <--> round-trip
|
|
||||||
image: src.basics.picture,
|
|
||||||
brief: src.basics.summary
|
|
||||||
},
|
|
||||||
contact: {
|
|
||||||
email: src.basics.email,
|
|
||||||
phone: src.basics.phone,
|
|
||||||
website: src.basics.website,
|
|
||||||
other: src.basics.other // <--> round-trip
|
|
||||||
},
|
|
||||||
meta: meta( true, src.meta ),
|
|
||||||
location: {
|
|
||||||
city: src.basics.location.city,
|
|
||||||
region: src.basics.location.region,
|
|
||||||
country: src.basics.location.countryCode,
|
|
||||||
code: src.basics.location.postalCode,
|
|
||||||
address: src.basics.location.address
|
|
||||||
},
|
|
||||||
employment: employment( src.work, true ),
|
|
||||||
education: education( src.education, true),
|
|
||||||
service: service( src.volunteer, true),
|
|
||||||
skills: skillsToFRESH( src.skills ),
|
|
||||||
writing: writing( src.publications, true),
|
|
||||||
recognition: recognition( src.awards, true, foreign ),
|
|
||||||
social: social( src.basics.profiles, true ),
|
|
||||||
interests: src.interests,
|
|
||||||
testimonials: references( src.references, true ),
|
|
||||||
languages: src.languages,
|
|
||||||
disposition: src.disposition // <--> round-trip
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert from FRESH format to JSON Resume.
|
|
||||||
@param foreign True if non-JSON-Resume properties should be included in
|
|
||||||
the result, false if those properties should be excluded.
|
|
||||||
@todo Refactor
|
|
||||||
*/
|
|
||||||
toJRS: function( src, foreign ) {
|
|
||||||
|
|
||||||
foreign = (foreign === undefined || foreign === null) ? false : foreign;
|
|
||||||
|
|
||||||
return {
|
|
||||||
basics: {
|
|
||||||
name: src.name,
|
|
||||||
label: src.info.label,
|
|
||||||
class: foreign ? src.info.class : undefined,
|
|
||||||
summary: src.info.brief,
|
|
||||||
website: src.contact.website,
|
|
||||||
phone: src.contact.phone,
|
|
||||||
email: src.contact.email,
|
|
||||||
picture: src.info.image,
|
|
||||||
location: {
|
|
||||||
address: src.location.address,
|
|
||||||
postalCode: src.location.code,
|
|
||||||
city: src.location.city,
|
|
||||||
countryCode: src.location.country,
|
|
||||||
region: src.location.region
|
|
||||||
},
|
|
||||||
profiles: social( src.social, false ),
|
|
||||||
imp: src.imp
|
|
||||||
},
|
|
||||||
work: employment( src.employment, false ),
|
|
||||||
education: education( src.education, false ),
|
|
||||||
skills: skillsToJRS( src.skills, false ),
|
|
||||||
volunteer: service( src.service, false ),
|
|
||||||
awards: recognition( src.recognition, false, foreign ),
|
|
||||||
publications: writing( src.writing, false ),
|
|
||||||
interests: src.interests,
|
|
||||||
references: references( src.testimonials, false ),
|
|
||||||
samples: foreign ? src.samples : undefined,
|
|
||||||
disposition: foreign ? src.disposition : undefined,
|
|
||||||
languages: src.languages
|
|
||||||
};
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
toSTRING: function( src ) {
|
|
||||||
function replacerJRS( key,value ) { // Exclude these keys
|
|
||||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
|
||||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate',
|
|
||||||
'result', 'isModified', 'htmlPreview', 'display_progress_bar'],
|
|
||||||
function( val ) { return key.trim() === val; }
|
|
||||||
) ? undefined : value;
|
|
||||||
}
|
|
||||||
function replacerFRESH( key,value ) { // Exclude these keys
|
|
||||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
|
||||||
'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'],
|
|
||||||
function( val ) { return key.trim() === val; }
|
|
||||||
) ? undefined : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.stringify( src, src.basics ? replacerJRS : replacerFRESH, 2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function meta( direction, obj ) {
|
|
||||||
//if( !obj ) return obj; // preserve null and undefined
|
|
||||||
if( direction ) {
|
|
||||||
obj = obj || { };
|
|
||||||
obj.format = obj.format || "FRESH@0.1.0";
|
|
||||||
obj.version = obj.version || "0.1.0";
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function employment( obj, direction ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( !direction ) {
|
|
||||||
return obj && obj.history ?
|
|
||||||
obj.history.map(function(emp){
|
|
||||||
return {
|
|
||||||
company: emp.employer,
|
|
||||||
website: emp.url,
|
|
||||||
position: emp.position,
|
|
||||||
startDate: emp.start,
|
|
||||||
endDate: emp.end,
|
|
||||||
summary: emp.summary,
|
|
||||||
highlights: emp.highlights
|
|
||||||
};
|
|
||||||
}) : undefined;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return {
|
|
||||||
history: obj && obj.length ?
|
|
||||||
obj.map( function( job ) {
|
|
||||||
return {
|
|
||||||
position: job.position,
|
|
||||||
employer: job.company,
|
|
||||||
summary: job.summary,
|
|
||||||
current: (!job.endDate || !job.endDate.trim() ||
|
|
||||||
job.endDate.trim().toLowerCase() === 'current') || undefined,
|
|
||||||
start: job.startDate,
|
|
||||||
end: job.endDate,
|
|
||||||
url: job.website,
|
|
||||||
keywords: [],
|
|
||||||
highlights: job.highlights
|
|
||||||
};
|
|
||||||
}) : undefined
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function education( obj, direction ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( direction ) {
|
|
||||||
return obj && obj.length ? {
|
|
||||||
level: "",
|
|
||||||
history: obj.map(function(edu){
|
|
||||||
return {
|
|
||||||
institution: edu.institution,
|
|
||||||
start: edu.startDate,
|
|
||||||
end: edu.endDate,
|
|
||||||
grade: edu.gpa,
|
|
||||||
curriculum: edu.courses,
|
|
||||||
url: edu.website || edu.url || undefined,
|
|
||||||
summary: edu.summary || "",
|
|
||||||
area: edu.area,
|
|
||||||
studyType: edu.studyType
|
|
||||||
};
|
|
||||||
})
|
|
||||||
} : undefined;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return obj && obj.history ?
|
|
||||||
obj.history.map(function(edu){
|
|
||||||
return {
|
|
||||||
institution: edu.institution,
|
|
||||||
gpa: edu.grade,
|
|
||||||
courses: edu.curriculum,
|
|
||||||
startDate: edu.start,
|
|
||||||
endDate: edu.end,
|
|
||||||
area: edu.area,
|
|
||||||
studyType: edu.studyType
|
|
||||||
};
|
|
||||||
}) : undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function service( obj, direction, foreign ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( direction ) {
|
|
||||||
return {
|
|
||||||
history: obj && obj.length ? obj.map(function(vol) {
|
|
||||||
return {
|
|
||||||
type: 'volunteer',
|
|
||||||
position: vol.position,
|
|
||||||
organization: vol.organization,
|
|
||||||
start: vol.startDate,
|
|
||||||
end: vol.endDate,
|
|
||||||
url: vol.website,
|
|
||||||
summary: vol.summary,
|
|
||||||
highlights: vol.highlights
|
|
||||||
};
|
|
||||||
}) : undefined
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return obj && obj.history ?
|
|
||||||
obj.history.map(function(srv){
|
|
||||||
return {
|
|
||||||
flavor: foreign ? srv.flavor : undefined,
|
|
||||||
organization: srv.organization,
|
|
||||||
position: srv.position,
|
|
||||||
startDate: srv.start,
|
|
||||||
endDate: srv.end,
|
|
||||||
website: srv.url,
|
|
||||||
summary: srv.summary,
|
|
||||||
highlights: srv.highlights
|
|
||||||
};
|
|
||||||
}) : undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function social( obj, direction ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( direction ) {
|
|
||||||
return obj.map(function(pro){
|
|
||||||
return {
|
|
||||||
label: pro.network,
|
|
||||||
network: pro.network,
|
|
||||||
url: pro.url,
|
|
||||||
user: pro.username
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return obj.map( function( soc ) {
|
|
||||||
return {
|
|
||||||
network: soc.network,
|
|
||||||
username: soc.user,
|
|
||||||
url: soc.url
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function recognition( obj, direction, foreign ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( direction ) {
|
|
||||||
return obj && obj.length ? obj.map(
|
|
||||||
function(awd){
|
|
||||||
return {
|
|
||||||
flavor: foreign ? awd.flavor : undefined,
|
|
||||||
url: foreign ? awd.url: undefined,
|
|
||||||
title: awd.title,
|
|
||||||
date: awd.date,
|
|
||||||
from: awd.awarder,
|
|
||||||
summary: awd.summary
|
|
||||||
};
|
|
||||||
}) : undefined;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return obj && obj.length ? obj.map(function(awd){
|
|
||||||
return {
|
|
||||||
flavor: foreign ? awd.flavor : undefined,
|
|
||||||
url: foreign ? awd.url: undefined,
|
|
||||||
title: awd.title,
|
|
||||||
date: awd.date,
|
|
||||||
awarder: awd.from,
|
|
||||||
summary: awd.summary
|
|
||||||
};
|
|
||||||
}) : undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function references( obj, direction ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( direction ) {
|
|
||||||
return obj && obj.length && obj.map(function(ref){
|
|
||||||
return {
|
|
||||||
name: ref.name,
|
|
||||||
flavor: 'professional',
|
|
||||||
quote: ref.reference,
|
|
||||||
private: false
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return obj && obj.length && obj.map(function(ref){
|
|
||||||
return {
|
|
||||||
name: ref.name,
|
|
||||||
reference: ref.quote
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function writing( obj, direction ) {
|
|
||||||
if( !obj ) return obj;
|
|
||||||
if( direction ) {
|
|
||||||
return obj.map(function( pub ) {
|
|
||||||
return {
|
|
||||||
title: pub.name,
|
|
||||||
flavor: undefined,
|
|
||||||
publisher: pub.publisher,
|
|
||||||
url: pub.website,
|
|
||||||
date: pub.releaseDate,
|
|
||||||
summary: pub.summary
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return obj && obj.length ? obj.map(function(pub){
|
|
||||||
return {
|
|
||||||
name: pub.title,
|
|
||||||
publisher: pub.publisher &&
|
|
||||||
pub.publisher.name ? pub.publisher.name : pub.publisher,
|
|
||||||
releaseDate: pub.date,
|
|
||||||
website: pub.url,
|
|
||||||
summary: pub.summary
|
|
||||||
};
|
|
||||||
}) : undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function skillsToFRESH( skills ) {
|
|
||||||
if( !skills ) return skills;
|
|
||||||
return {
|
|
||||||
sets: skills.map(function( set ) {
|
|
||||||
return {
|
|
||||||
name: set.name,
|
|
||||||
level: set.level,
|
|
||||||
skills: set.keywords
|
|
||||||
};
|
|
||||||
})
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function skillsToJRS( skills ) {
|
|
||||||
if( !skills ) return skills;
|
|
||||||
var ret = [];
|
|
||||||
if( skills.sets && skills.sets.length ) {
|
|
||||||
ret = skills.sets.map(function(set){
|
|
||||||
return {
|
|
||||||
name: set.name,
|
|
||||||
level: set.level,
|
|
||||||
keywords: set.skills
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if( skills.list ) {
|
|
||||||
ret = skills.list.map(function(sk){
|
|
||||||
return {
|
|
||||||
name: sk.name,
|
|
||||||
level: sk.level,
|
|
||||||
keywords: sk.keywords
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
@ -1,21 +1,18 @@
|
|||||||
(function(){
|
/*
|
||||||
|
Event code definitions.
|
||||||
|
@module core/default-formats
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/** Supported resume formats. */
|
||||||
Supported resume formats.
|
module.exports = [
|
||||||
*/
|
{ name: 'html', ext: 'html', gen: new (require('../generators/html-generator'))() },
|
||||||
|
{ name: 'txt', ext: 'txt', gen: new (require('../generators/text-generator'))() },
|
||||||
module.exports = [
|
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new (require('../generators/word-generator'))() },
|
||||||
|
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new (require('../generators/html-pdf-cli-generator'))() },
|
||||||
{ name: 'html', ext: 'html', gen: new (require('../gen/html-generator'))() },
|
{ name: 'png', ext: 'png', fmt: 'html', is: false, gen: new (require('../generators/html-png-generator'))() },
|
||||||
{ name: 'txt', ext: 'txt', gen: new (require('../gen/text-generator'))() },
|
{ name: 'md', ext: 'md', fmt: 'txt', gen: new (require('../generators/markdown-generator'))() },
|
||||||
{ name: 'doc', ext: 'doc', fmt: 'xml', gen: new (require('../gen/word-generator'))() },
|
{ name: 'json', ext: 'json', gen: new (require('../generators/json-generator'))() },
|
||||||
{ name: 'pdf', ext: 'pdf', fmt: 'html', is: false, gen: new (require('../gen/html-pdf-generator'))() },
|
{ name: 'yml', ext: 'yml', fmt: 'yml', gen: new (require('../generators/json-yaml-generator'))() },
|
||||||
{ name: 'png', ext: 'png', fmt: 'html', is: false, gen: new (require('../gen/html-png-generator'))() },
|
{ name: 'latex', ext: 'tex', fmt: 'latex', gen: new (require('../generators/latex-generator'))() }
|
||||||
{ name: 'md', ext: 'md', fmt: 'txt', gen: new (require('../gen/markdown-generator'))() },
|
];
|
||||||
{ name: 'json', ext: 'json', gen: new (require('../gen/json-generator'))() },
|
|
||||||
{ name: 'yml', ext: 'yml', fmt: 'yml', gen: new (require('../gen/json-yaml-generator'))() },
|
|
||||||
{ name: 'latex', ext: 'tex', fmt: 'latex', gen: new (require('../gen/latex-generator'))() }
|
|
||||||
|
|
||||||
];
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
(function(){
|
/*
|
||||||
|
Event code definitions.
|
||||||
|
@module core/default-options
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
theme: 'modern',
|
theme: 'modern',
|
||||||
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'],
|
||||||
max_char: 80, // ← See lib/html.js in above-linked repo
|
max_char: 80
|
||||||
//wrap_line_length: 120, ← Don't use this
|
} // ← See lib/html.js in above-linked repo
|
||||||
}
|
};
|
||||||
};
|
// wrap_line_length: 120, ← Don't use this
|
||||||
|
|
||||||
}());
|
|
||||||
|
@ -1,128 +0,0 @@
|
|||||||
/**
|
|
||||||
Error-handling routines for HackMyResume.
|
|
||||||
@module error-handler.js
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var HACKMYSTATUS = require('./status-codes')
|
|
||||||
, PKG = require('../../package.json')
|
|
||||||
, FS = require('fs')
|
|
||||||
, FCMD = require('../hackmyapi')
|
|
||||||
, PATH = require('path')
|
|
||||||
, chalk = require('chalk');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
An amorphous blob of error handling code for HackMyResume.
|
|
||||||
@class ErrorHandler
|
|
||||||
*/
|
|
||||||
var ErrorHandler = module.exports = {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
err: function( ex, shouldExit ) {
|
|
||||||
var msg = '', exitCode;
|
|
||||||
|
|
||||||
if( ex.handled ) {
|
|
||||||
if( shouldExit )
|
|
||||||
process.exit( exitCode );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if( ex.fluenterror ){
|
|
||||||
|
|
||||||
switch( ex.fluenterror ) {
|
|
||||||
|
|
||||||
case HACKMYSTATUS.themeNotFound:
|
|
||||||
msg = "The specified theme couldn't be found: " + ex.data;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.copyCSS:
|
|
||||||
msg = "Couldn't copy CSS file to destination folder";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.resumeNotFound:
|
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('feed me a resume') +
|
|
||||||
chalk.yellow(' in FRESH or JSON Resume format.');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.missingCommand:
|
|
||||||
msg = chalk.yellow("Please ") + chalk.yellow.bold("give me a command") +
|
|
||||||
chalk.yellow(" (");
|
|
||||||
|
|
||||||
msg += Object.keys( FCMD.verbs ).map( function(v, idx, ar) {
|
|
||||||
return (idx === ar.length - 1 ? chalk.yellow('or ') : '') +
|
|
||||||
chalk.yellow.bold(v.toUpperCase());
|
|
||||||
}).join( chalk.yellow(', ')) + chalk.yellow(").\n\n");
|
|
||||||
|
|
||||||
msg += chalk.gray(FS.readFileSync( PATH.resolve(__dirname, '../use.txt'), 'utf8' ));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.invalidCommand:
|
|
||||||
msg = chalk.yellow('Invalid command: "') + chalk.yellow.bold(ex.attempted) + chalk.yellow('"');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.resumeNotFoundAlt:
|
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('feed me a resume') +
|
|
||||||
chalk.yellow(' in either FRESH or JSON Resume format.');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.inputOutputParity:
|
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('specify an output file name') +
|
|
||||||
chalk.yellow(' for every input file you wish to convert.');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.createNameMissing:
|
|
||||||
msg = chalk.yellow('Please ') + chalk.yellow.bold('specify the filename of the resume') +
|
|
||||||
chalk.yellow(' to create.');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.wkhtmltopdf:
|
|
||||||
msg = chalk.red.bold('ERROR: PDF generation failed. ') + chalk.red('Make sure wkhtmltopdf is ' +
|
|
||||||
'installed and accessible from your path.');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HACKMYSTATUS.invalid:
|
|
||||||
msg = chalk.red.bold('ERROR: Validation failed and the --assert option was specified.');
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
exitCode = ex.fluenterror;
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
msg = ex.toString();
|
|
||||||
exitCode = 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Deal with pesky 'Error:' prefix.
|
|
||||||
var idx = msg.indexOf('Error: ');
|
|
||||||
var trimmed = idx === -1 ? msg : msg.substring( idx + 7 );
|
|
||||||
|
|
||||||
// If this is an unhandled error, or a specific class of handled error,
|
|
||||||
// output the error message and stack.
|
|
||||||
if( !ex.fluenterror || ex.fluenterror < 3 ) { // TODO: magic #s
|
|
||||||
console.log( chalk.red.bold('ERROR: ' + trimmed.toString()) );
|
|
||||||
if( ex.code !== 'ENOENT' ) // Don't emit stack for common stuff
|
|
||||||
console.log( chalk.gray(ex.stack) );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log( trimmed.toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let the error code be the process's return code.
|
|
||||||
if( shouldExit || ex.shouldExit )
|
|
||||||
process.exit( exitCode );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
39
src/core/event-codes.js
Normal file
39
src/core/event-codes.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
Event code definitions.
|
||||||
|
@module core/event-codes
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
error: -1,
|
||||||
|
success: 0,
|
||||||
|
begin: 1,
|
||||||
|
end: 2,
|
||||||
|
beforeRead: 3,
|
||||||
|
afterRead: 4,
|
||||||
|
beforeCreate: 5,
|
||||||
|
afterCreate: 6,
|
||||||
|
beforeTheme: 7,
|
||||||
|
afterTheme: 8,
|
||||||
|
beforeMerge: 9,
|
||||||
|
afterMerge: 10,
|
||||||
|
beforeGenerate: 11,
|
||||||
|
afterGenerate: 12,
|
||||||
|
beforeAnalyze: 13,
|
||||||
|
afterAnalyze: 14,
|
||||||
|
beforeConvert: 15,
|
||||||
|
afterConvert: 16,
|
||||||
|
verifyOutputs: 17,
|
||||||
|
beforeParse: 18,
|
||||||
|
afterParse: 19,
|
||||||
|
beforePeek: 20,
|
||||||
|
afterPeek: 21,
|
||||||
|
beforeInlineConvert: 22,
|
||||||
|
afterInlineConvert: 23,
|
||||||
|
beforeValidate: 24,
|
||||||
|
afterValidate: 25,
|
||||||
|
beforeWrite: 26,
|
||||||
|
afterWrite: 27,
|
||||||
|
applyTheme: 28
|
||||||
|
};
|
@ -1,10 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS104: Avoid inline assignments
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
The HackMyResume date representation.
|
The HackMyResume date representation.
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module fluent-date.js
|
@module core/fluent-date
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var moment = require('moment');
|
|
||||||
|
|
||||||
|
const moment = require('moment');
|
||||||
|
require('../utils/string');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a FluentDate from a string or Moment date object. There are a few date
|
Create a FluentDate from a string or Moment date object. There are a few date
|
||||||
@ -22,63 +32,64 @@ deprecation warnings, it's recommended to either a) explicitly specify the date
|
|||||||
format or b) use an ISO format. For clarity, we handle these cases explicitly.
|
format or b) use an ISO format. For clarity, we handle these cases explicitly.
|
||||||
@class FluentDate
|
@class FluentDate
|
||||||
*/
|
*/
|
||||||
function FluentDate( dt ) {
|
|
||||||
this.rep = this.fmt( dt );
|
class FluentDate {
|
||||||
|
|
||||||
|
constructor(dt) {
|
||||||
|
this.rep = this.fmt(dt);
|
||||||
|
}
|
||||||
|
|
||||||
|
static isCurrent(dt) {
|
||||||
|
return !dt || (String.is(dt) && /^(present|now|current)$/.test(dt));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FluentDate/*.prototype*/.fmt = function( dt ) {
|
const months = {};
|
||||||
if( (typeof dt === 'string' || dt instanceof String) ) {
|
const abbr = {};
|
||||||
|
moment.months().forEach((m,idx) => months[m.toLowerCase()] = idx+1);
|
||||||
|
moment.monthsShort().forEach((m,idx) => abbr[m.toLowerCase()]=idx+1);
|
||||||
|
abbr.sept = 9;
|
||||||
|
module.exports = FluentDate;
|
||||||
|
|
||||||
|
FluentDate.fmt = function( dt, throws ) {
|
||||||
|
|
||||||
|
throws = ((throws === undefined) || (throws === null)) || throws;
|
||||||
|
|
||||||
|
if ((typeof dt === 'string') || dt instanceof String) {
|
||||||
dt = dt.toLowerCase().trim();
|
dt = dt.toLowerCase().trim();
|
||||||
if( /^(present|now|current)$/.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"
|
let left;
|
||||||
var parts = dt.split(' ');
|
const parts = dt.split(' ');
|
||||||
var month = (months[parts[0]] || abbr[parts[0]]);
|
const month = (months[parts[0]] || abbr[parts[0]]);
|
||||||
var temp = parts[1] + '-' + (month < 10 ? '0' + month : month.toString());
|
const temp = parts[1] + '-' + ((left = month < 10) != null ? left : `0${{month : month.toString()}}`);
|
||||||
return moment( temp, 'YYYY-MM' );
|
return moment(temp, 'YYYY-MM');
|
||||||
}
|
} 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}\s*$/.test(dt)) { // "2015"
|
||||||
}
|
return moment(dt, 'YYYY');
|
||||||
else if( /^\s*\d{4}\s*$/.test(dt) ) { // "2015"
|
} else if (/^\s*$/.test(dt)) { // "", " "
|
||||||
return moment( dt, 'YYYY' );
|
return moment();
|
||||||
}
|
} else {
|
||||||
else if( /^\s*$/.test(dt) ) { // "", " "
|
const mt = moment(dt);
|
||||||
var defTime = {
|
if (mt.isValid()) {
|
||||||
isNull: true,
|
|
||||||
isBefore: function( other ) {
|
|
||||||
return( other && !other.isNull ) ? true : false;
|
|
||||||
},
|
|
||||||
isAfter: function( other ) {
|
|
||||||
return( other && !other.isNull ) ? false : false;
|
|
||||||
},
|
|
||||||
unix: function() { return 0; },
|
|
||||||
format: function() { return ''; },
|
|
||||||
diff: function() { return 0; }
|
|
||||||
};
|
|
||||||
return defTime;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var mt = moment( dt );
|
|
||||||
if(mt.isValid())
|
|
||||||
return mt;
|
return mt;
|
||||||
throw 'Invalid date format encountered.';
|
}
|
||||||
|
if (throws) {
|
||||||
|
throw 'Invalid date format encountered.';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
if (!dt) {
|
||||||
if( !dt ) {
|
|
||||||
return moment();
|
return moment();
|
||||||
}
|
} else if (dt.isValid && dt.isValid()) {
|
||||||
else if( dt.isValid && dt.isValid() )
|
|
||||||
return dt;
|
return dt;
|
||||||
throw 'Unknown date object encountered.';
|
}
|
||||||
|
if (throws) {
|
||||||
|
throw 'Unknown date object encountered.';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var months = {}, abbr = {};
|
|
||||||
moment.months().forEach(function(m,idx){months[m.toLowerCase()]=idx+1;});
|
|
||||||
moment.monthsShort().forEach(function(m,idx){abbr[m.toLowerCase()]=idx+1;});
|
|
||||||
abbr.sept = 9;
|
|
||||||
|
|
||||||
module.exports = FluentDate;
|
|
||||||
|
@ -1,148 +1,152 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the FRESHResume class.
|
Definition of the FRESHResume class.
|
||||||
@license MIT. See LICENSE .md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module fresh-resume.js
|
@module core/fresh-resume
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
const FS = require('fs');
|
||||||
|
const extend = require('extend');
|
||||||
|
let validator = require('is-my-json-valid');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const __ = require('lodash');
|
||||||
|
const XML = require('xml-escape');
|
||||||
|
const MD = require('marked');
|
||||||
|
const CONVERTER = require('fresh-jrs-converter');
|
||||||
|
const JRSResume = require('./jrs-resume');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var FS = require('fs')
|
/**
|
||||||
, extend = require('../utils/extend')
|
A FRESH resume or CV. FRESH resumes are backed by JSON, and each FreshResume
|
||||||
, validator = require('is-my-json-valid')
|
object is an instantiation of that JSON decorated with utility methods.
|
||||||
, _ = require('underscore')
|
@constructor
|
||||||
, __ = require('lodash')
|
*/
|
||||||
, PATH = require('path')
|
class FreshResume {// extends AbstractResume
|
||||||
, moment = require('moment')
|
|
||||||
, XML = require('xml-escape')
|
|
||||||
, MD = require('marked')
|
|
||||||
, CONVERTER = require('./convert')
|
|
||||||
, JRSResume = require('./jrs-resume');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Initialize the the FreshResume from JSON string data. */
|
||||||
A FRESH resume or CV. FRESH resumes are backed by JSON, and each FreshResume
|
parse( stringData, opts ) {
|
||||||
object is an instantiation of that JSON decorated with utility methods.
|
this.imp = this.imp != null ? this.imp : {raw: stringData};
|
||||||
@class FreshResume
|
return this.parseJSON(JSON.parse( stringData ), opts);
|
||||||
*/
|
|
||||||
function FreshResume() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the FreshResume from file.
|
|
||||||
*/
|
|
||||||
FreshResume.prototype.open = function( file, title ) {
|
|
||||||
this.imp = { fileName: file };
|
|
||||||
this.imp.raw = FS.readFileSync( file, 'utf8' );
|
|
||||||
return this.parse( this.imp.raw, title );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the the FreshResume from string.
|
|
||||||
*/
|
|
||||||
FreshResume.prototype.parse = function( stringData, opts ) {
|
|
||||||
return this.parseJSON( JSON.parse( stringData ), opts );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the FreshResume from JSON.
|
Initialize the FreshResume from JSON.
|
||||||
Open and parse the specified FRESH resume. Merge the JSON object model onto
|
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 &
|
this Sheet instance with extend() and convert sheet dates to a safe &
|
||||||
consistent format. Then sort each section by startDate descending.
|
consistent format. Then sort each section by startDate descending.
|
||||||
|
@param rep {Object} The raw JSON representation.
|
||||||
|
@param opts {Object} Resume loading and parsing options.
|
||||||
|
{
|
||||||
|
date: Perform safe date conversion.
|
||||||
|
sort: Sort resume items by date.
|
||||||
|
compute: Prepare computed resume totals.
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.parseJSON = function( rep, opts ) {
|
parseJSON( rep, opts ) {
|
||||||
// Convert JSON Resume to FRESH if necessary
|
|
||||||
if( rep.basics ) {
|
let scrubbed;
|
||||||
rep = CONVERTER.toFRESH( rep );
|
if (opts && opts.privatize) {
|
||||||
rep.imp = rep.imp || { };
|
// Ignore any element with the 'ignore: true' or 'private: true' designator.
|
||||||
rep.imp.orgFormat = 'JRS';
|
const scrubber = require('../utils/resume-scrubber');
|
||||||
|
var ret = scrubber.scrubResume(rep, opts);
|
||||||
|
scrubbed = ret.scrubbed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now apply the resume representation onto this object
|
// Now apply the resume representation onto this object
|
||||||
extend( true, this, rep );
|
extend(true, this, opts && opts.privatize ? scrubbed : rep);
|
||||||
|
|
||||||
// Set up metadata
|
// If the resume has already been processed, then we are being called from
|
||||||
opts = opts || { };
|
// the .dupe method, and there's no need to do any post processing
|
||||||
if( opts.imp === undefined || opts.imp ) {
|
if (!(this.imp != null ? this.imp.processed : undefined)) {
|
||||||
this.imp = this.imp || { };
|
// Set up metadata TODO: Clean up metadata on the object model.
|
||||||
this.imp.title = (opts.title || this.imp.title) || this.name;
|
opts = opts || { };
|
||||||
|
if ((opts.imp === undefined) || opts.imp) {
|
||||||
|
this.imp = this.imp || { };
|
||||||
|
this.imp.title = (opts.title || this.imp.title) || this.name;
|
||||||
|
if (!this.imp.raw) {
|
||||||
|
this.imp.raw = JSON.stringify(rep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.imp.processed = true;
|
||||||
|
// Parse dates, sort dates, and calculate computed values
|
||||||
|
((opts.date === undefined) || opts.date) && _parseDates.call( this );
|
||||||
|
((opts.sort === undefined) || opts.sort) && this.sort();
|
||||||
|
((opts.compute === undefined) || opts.compute) && (this.computed = {
|
||||||
|
numYears: this.duration(),
|
||||||
|
keywords: this.keywords()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// Parse dates, sort dates, and calculate computed values
|
|
||||||
(opts.date === undefined || opts.date) && _parseDates.call( this );
|
|
||||||
(opts.sort === undefined || opts.sort) && this.sort();
|
|
||||||
(opts.compute === undefined || opts.compute) && (this.computed = {
|
|
||||||
numYears: this.duration(),
|
|
||||||
keywords: this.keywords()
|
|
||||||
});
|
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Save the sheet to disk (for environments that have disk access). */
|
||||||
Save the sheet to disk (for environments that have disk access).
|
save( filename ) {
|
||||||
*/
|
this.imp.file = filename || this.imp.file;
|
||||||
FreshResume.prototype.save = function( filename ) {
|
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
|
||||||
this.imp.fileName = filename || this.imp.fileName;
|
|
||||||
FS.writeFileSync( this.imp.fileName, this.stringify(), 'utf8' );
|
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Save the sheet to disk in a specific format, either FRESH or JSON Resume.
|
Save the sheet to disk in a specific format, either FRESH or JSON Resume.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.saveAs = function( filename, format ) {
|
saveAs( filename, format ) {
|
||||||
|
|
||||||
if( format !== 'JRS' ) {
|
// If format isn't specified, default to FRESH
|
||||||
this.imp.fileName = filename || this.imp.fileName;
|
const safeFormat = (format && format.trim()) || 'FRESH';
|
||||||
FS.writeFileSync( this.imp.fileName, this.stringify(), 'utf8' );
|
|
||||||
}
|
// Validate against the FRESH version regex
|
||||||
else {
|
// freshVersionReg = require '../utils/fresh-version-regex'
|
||||||
var newRep = CONVERTER.toJRS( this );
|
// if (not freshVersionReg().test( safeFormat ))
|
||||||
FS.writeFileSync( filename, JRSResume.stringify( newRep ), 'utf8' );
|
// throw badVer: safeFormat
|
||||||
|
|
||||||
|
const parts = safeFormat.split('@');
|
||||||
|
|
||||||
|
if (parts[0] === 'FRESH') {
|
||||||
|
this.imp.file = filename || this.imp.file;
|
||||||
|
FS.writeFileSync(this.imp.file, this.stringify(), 'utf8');
|
||||||
|
|
||||||
|
} else if (parts[0] === 'JRS') {
|
||||||
|
const useEdgeSchema = parts.length > 1 ? parts[1] === '1' : false;
|
||||||
|
const newRep = CONVERTER.toJRS(this, {edge: useEdgeSchema});
|
||||||
|
FS.writeFileSync(filename, JRSResume.stringify( newRep ), 'utf8');
|
||||||
|
} else {
|
||||||
|
throw {badVer: safeFormat};
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Duplicate this FreshResume instance.
|
Duplicate this FreshResume instance.
|
||||||
|
This method first extend()s this object onto an empty, creating a deep copy,
|
||||||
|
and then passes the result into a new FreshResume instance via .parseJSON.
|
||||||
|
We do it this way to create a true clone of the object without re-running any
|
||||||
|
of the associated processing.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.dupe = function() {
|
dupe() {
|
||||||
var rnew = new FreshResume();
|
const jso = extend(true, { }, this);
|
||||||
rnew.parse( this.stringify(), { } );
|
const rnew = new FreshResume();
|
||||||
|
rnew.parseJSON(jso, { });
|
||||||
return rnew;
|
return rnew;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
|
|
||||||
along the way.
|
|
||||||
*/
|
|
||||||
FreshResume.stringify = function( obj ) {
|
|
||||||
function replacer( key,value ) { // Exclude these keys from stringification
|
|
||||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
|
||||||
'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'],
|
|
||||||
function( val ) { return key.trim() === val; }
|
|
||||||
) ? undefined : value;
|
|
||||||
}
|
|
||||||
return JSON.stringify( obj, replacer, 2 );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -150,57 +154,20 @@ Definition of the FRESHResume class.
|
|||||||
Convert this object to a JSON string, sanitizing meta-properties along the
|
Convert this object to a JSON string, sanitizing meta-properties along the
|
||||||
way.
|
way.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.stringify = function() {
|
stringify() { return FreshResume.stringify(this); }
|
||||||
return FreshResume.stringify( this );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a copy of this resume in which all string fields have been run through
|
Create a copy of this resume in which all string fields have been run through
|
||||||
a transformation function (such as a Markdown filter or XML encoder).
|
a transformation function (such as a Markdown filter or XML encoder).
|
||||||
|
TODO: Move this out of FRESHResume.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.transformStrings = function( filt, transformer ) {
|
transformStrings( filt, transformer ) {
|
||||||
|
const ret = this.dupe();
|
||||||
var that = this;
|
const trx = require('../utils/string-transformer');
|
||||||
var ret = this.dupe();
|
return trx(ret, filt, transformer);
|
||||||
|
}
|
||||||
// TODO: refactor recursion
|
|
||||||
function transformStringsInObject( obj, filters ) {
|
|
||||||
|
|
||||||
if( !obj ) return;
|
|
||||||
if( moment.isMoment( obj ) ) return;
|
|
||||||
|
|
||||||
if( _.isArray( obj ) ) {
|
|
||||||
obj.forEach( function(elem, idx, ar) {
|
|
||||||
if( typeof elem === 'string' || elem instanceof String )
|
|
||||||
ar[idx] = transformer( null, elem );
|
|
||||||
else if (_.isObject(elem))
|
|
||||||
transformStringsInObject( elem, filters );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (_.isObject( obj )) {
|
|
||||||
Object.keys( obj ).forEach(function(k) {
|
|
||||||
if( filters.length && _.contains(filters, k) )
|
|
||||||
return;
|
|
||||||
var sub = obj[k];
|
|
||||||
if( typeof sub === 'string' || sub instanceof String ) {
|
|
||||||
obj[k] = transformer( k, sub );
|
|
||||||
}
|
|
||||||
else if (_.isObject( sub ))
|
|
||||||
transformStringsInObject( sub, filters );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.keys( ret ).forEach(function(member){
|
|
||||||
if( !filt || !filt.length || !_.contains(filt, member) )
|
|
||||||
transformStringsInObject( ret[ member ], filt || [] );
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -208,21 +175,19 @@ Definition of the FRESHResume class.
|
|||||||
Create a copy of this resume in which all fields have been interpreted as
|
Create a copy of this resume in which all fields have been interpreted as
|
||||||
Markdown.
|
Markdown.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.markdownify = function() {
|
markdownify() {
|
||||||
|
|
||||||
function MDIN( txt ){
|
const MDIN = txt => MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||||
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
function trx(key, val) {
|
const trx = function( key, val ) {
|
||||||
if( key === 'summary' ) {
|
if (key === 'summary') {
|
||||||
return MD(val);
|
return MD(val);
|
||||||
}
|
}
|
||||||
return MDIN(val);
|
return MDIN(val);
|
||||||
}
|
};
|
||||||
|
|
||||||
return this.transformStrings( ['skills','url','start','end','date'], trx );
|
return this.transformStrings(['skills','url','start','end','date'], trx);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -230,62 +195,64 @@ Definition of the FRESHResume class.
|
|||||||
Create a copy of this resume in which all fields have been interpreted as
|
Create a copy of this resume in which all fields have been interpreted as
|
||||||
Markdown.
|
Markdown.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.xmlify = function() {
|
xmlify() {
|
||||||
function trx(key, val) {
|
const trx = (key, val) => XML(val);
|
||||||
return XML(val);
|
return this.transformStrings([], trx);
|
||||||
}
|
}
|
||||||
return this.transformStrings( [], trx );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Return the resume format. */
|
||||||
Return the resume format.
|
format() { return 'FRESH'; }
|
||||||
*/
|
|
||||||
FreshResume.prototype.format = function() {
|
|
||||||
return 'FRESH';
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return internal metadata. Create if it doesn't exist.
|
Return internal metadata. Create if it doesn't exist.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.i = function() {
|
i() { return this.imp = this.imp || { }; }
|
||||||
this.imp = (this.imp || { });
|
|
||||||
return this.imp;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a unique list of all keywords across all skills.
|
Return a unique list of all skills declared in the resume.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.keywords = function() {
|
|
||||||
var flatSkills = [];
|
// TODO: Several problems here:
|
||||||
if( this.skills ) {
|
// 1) Confusing name. Easily confused with the keyword-inspector module, which
|
||||||
if( this.skills.sets ) {
|
// parses resume body text looking for these same keywords. This should probably
|
||||||
flatSkills = this.skills.sets.map(function(sk) { return sk.skills; })
|
// be renamed.
|
||||||
.reduce(function(a,b) { return a.concat(b); });
|
//
|
||||||
|
// 2) Doesn't bother trying to integrate skills.list with skills.sets if they
|
||||||
|
// happen to declare different skills, and if skills.sets declares ONE skill and
|
||||||
|
// skills.list declared 50, only 1 skill will be registered.
|
||||||
|
//
|
||||||
|
// 3) In the future, skill.sets should only be able to use skills declared in
|
||||||
|
// skills.list. That is, skills.list is the official record of a candidate's
|
||||||
|
// declared skills. skills.sets is just a way of grouping those into skillsets
|
||||||
|
// for easier consumption.
|
||||||
|
|
||||||
|
keywords() {
|
||||||
|
let flatSkills = [];
|
||||||
|
if (this.skills) {
|
||||||
|
if (this.skills.sets) {
|
||||||
|
flatSkills = this.skills.sets.map(sk => sk.skills).reduce( (a,b) => a.concat(b));
|
||||||
|
} else if (this.skills.list) {
|
||||||
|
flatSkills = flatSkills.concat( this.skills.list.map(sk => sk.name) );
|
||||||
}
|
}
|
||||||
else if( this.skills.list ) {
|
flatSkills = _.uniq(flatSkills);
|
||||||
flatSkills = flatSkills.concat( this.skills.list.map(function(sk) {
|
|
||||||
return sk.name;
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
flatSkills = _.uniq( flatSkills );
|
|
||||||
}
|
}
|
||||||
return flatSkills;
|
return flatSkills;
|
||||||
},
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Reset the sheet to an empty state. TODO: refactor/review
|
Reset the sheet to an empty state. TODO: refactor/review
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.clear = function( clearMeta ) {
|
clear( clearMeta ) {
|
||||||
clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
||||||
clearMeta && (delete this.imp);
|
if (clearMeta) { delete this.imp; }
|
||||||
delete this.computed; // Don't use Object.keys() here
|
delete this.computed; // Don't use Object.keys() here
|
||||||
delete this.employment;
|
delete this.employment;
|
||||||
delete this.service;
|
delete this.service;
|
||||||
@ -295,75 +262,62 @@ Definition of the FRESHResume class.
|
|||||||
delete this.writing;
|
delete this.writing;
|
||||||
delete this.interests;
|
delete this.interests;
|
||||||
delete this.skills;
|
delete this.skills;
|
||||||
delete this.social;
|
return delete this.social;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get a safe count of the number of things in a section.
|
Get a safe count of the number of things in a section.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.count = function( obj ) {
|
count( obj ) {
|
||||||
if( !obj ) return 0;
|
if (!obj) { return 0; }
|
||||||
if( obj.history ) return obj.history.length;
|
if (obj.history) { return obj.history.length; }
|
||||||
if( obj.sets ) return obj.sets.length;
|
if (obj.sets) { return obj.sets.length; }
|
||||||
return obj.length || 0;
|
return obj.length || 0;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Add work experience to the sheet. */
|
||||||
Get the default (starter) sheet.
|
add( moniker ) {
|
||||||
*/
|
const defSheet = FreshResume.default();
|
||||||
FreshResume.default = function() {
|
const newObject =
|
||||||
return new FreshResume().parseJSON( require('fresh-resume-starter') );
|
defSheet[moniker].history
|
||||||
};
|
? extend( true, {}, defSheet[ moniker ].history[0] )
|
||||||
|
:
|
||||||
|
moniker === 'skills'
|
||||||
|
? extend( true, {}, defSheet.skills.sets[0] )
|
||||||
|
: extend( true, {}, defSheet[ moniker ][0] );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Add work experience to the sheet.
|
|
||||||
*/
|
|
||||||
FreshResume.prototype.add = function( moniker ) {
|
|
||||||
var defSheet = FreshResume.default();
|
|
||||||
var newObject = defSheet[moniker].history ?
|
|
||||||
$.extend( true, {}, defSheet[ moniker ].history[0] ) :
|
|
||||||
(moniker === 'skills' ?
|
|
||||||
$.extend( true, {}, defSheet.skills.sets[0] ) :
|
|
||||||
$.extend( true, {}, defSheet[ moniker ][0] ));
|
|
||||||
this[ moniker ] = this[ moniker ] || [];
|
this[ moniker ] = this[ moniker ] || [];
|
||||||
if( this[ moniker ].history )
|
if (this[ moniker ].history) {
|
||||||
this[ moniker ].history.push( newObject );
|
this[ moniker ].history.push(newObject);
|
||||||
else if( moniker === 'skills' )
|
} else if (moniker === 'skills') {
|
||||||
this.skills.sets.push( newObject );
|
this.skills.sets.push(newObject);
|
||||||
else
|
} else {
|
||||||
this[ moniker ].push( newObject );
|
this[ moniker ].push(newObject);
|
||||||
|
}
|
||||||
return newObject;
|
return newObject;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Determine if the sheet includes a specific social profile (eg, GitHub).
|
Determine if the sheet includes a specific social profile (eg, GitHub).
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.hasProfile = function( socialNetwork ) {
|
hasProfile( socialNetwork ) {
|
||||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||||
return this.social && _.some( this.social, function(p) {
|
return this.social && _.some(this.social, p => p.network.trim().toLowerCase() === socialNetwork);
|
||||||
return p.network.trim().toLowerCase() === socialNetwork;
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Return the specified network profile. */
|
||||||
Return the specified network profile.
|
getProfile( socialNetwork ) {
|
||||||
*/
|
|
||||||
FreshResume.prototype.getProfile = function( socialNetwork ) {
|
|
||||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||||
return this.social && _.find( this.social, function(sn) {
|
return this.social && _.find(this.social, sn => sn.network.trim().toLowerCase() === socialNetwork);
|
||||||
return sn.network.trim().toLowerCase() === socialNetwork;
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -371,72 +325,45 @@ Definition of the FRESHResume class.
|
|||||||
Return an array of profiles for the specified network, for when the user
|
Return an array of profiles for the specified network, for when the user
|
||||||
has multiple eg. GitHub accounts.
|
has multiple eg. GitHub accounts.
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.getProfiles = function( socialNetwork ) {
|
getProfiles( socialNetwork ) {
|
||||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||||
return this.social && _.filter( this.social, function(sn){
|
return this.social && _.filter(this.social, sn => sn.network.trim().toLowerCase() === socialNetwork);
|
||||||
return sn.network.trim().toLowerCase() === socialNetwork;
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Determine if the sheet includes a specific skill. */
|
||||||
Determine if the sheet includes a specific skill.
|
hasSkill( skill ) {
|
||||||
*/
|
|
||||||
FreshResume.prototype.hasSkill = function( skill ) {
|
|
||||||
skill = skill.trim().toLowerCase();
|
skill = skill.trim().toLowerCase();
|
||||||
return this.skills && _.some( this.skills, function(sk) {
|
return this.skills && _.some(this.skills, sk =>
|
||||||
return sk.keywords && _.some( sk.keywords, function(kw) {
|
sk.keywords && _.some(sk.keywords, kw => kw.trim().toLowerCase() === skill)
|
||||||
return kw.trim().toLowerCase() === skill;
|
);
|
||||||
});
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Validate the sheet against the FRESH Resume schema. */
|
||||||
Validate the sheet against the FRESH Resume schema.
|
isValid() {
|
||||||
*/
|
const schemaObj = require('fresh-resume-schema');
|
||||||
FreshResume.prototype.isValid = function( info ) {
|
validator = require('is-my-json-valid');
|
||||||
var schemaObj = require('fresca');
|
const validate = validator( schemaObj, { // See Note [1].
|
||||||
var validator = require('is-my-json-valid');
|
|
||||||
var validate = validator( schemaObj, { // See Note [1].
|
|
||||||
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
|
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
|
||||||
});
|
});
|
||||||
var ret = validate( this );
|
const ret = validate(this);
|
||||||
if( !ret ) {
|
if (!ret) {
|
||||||
this.imp = this.imp || { };
|
this.imp = this.imp || { };
|
||||||
this.imp.validationErrors = validate.errors;
|
this.imp.validationErrors = validate.errors;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
duration(unit) {
|
||||||
Calculate the total duration of the sheet. Assumes this.work has been sorted
|
const inspector = require('../inspectors/duration-inspector');
|
||||||
by start date descending, perhaps via a call to Sheet.sort().
|
return inspector.run(this, 'employment.history', 'start', 'end', unit);
|
||||||
@returns The total duration of the sheet's work history, that is, the number
|
}
|
||||||
of years between the start date of the earliest job on the resume and the
|
|
||||||
*latest end date of all jobs in the work history*. This last condition is for
|
|
||||||
sheets that have overlapping jobs.
|
|
||||||
*/
|
|
||||||
FreshResume.prototype.duration = function(unit) {
|
|
||||||
unit = unit || 'years';
|
|
||||||
var empHist = __.get(this, 'employment.history');
|
|
||||||
if( empHist && empHist.length ) {
|
|
||||||
var firstJob = _.last( empHist );
|
|
||||||
var careerStart = firstJob.start ? firstJob.safe.start : '';
|
|
||||||
if ((typeof careerStart === 'string' || careerStart instanceof String) &&
|
|
||||||
!careerStart.trim())
|
|
||||||
return 0;
|
|
||||||
var careerLast = _.max( empHist, function( w ) {
|
|
||||||
return( w.safe && w.safe.end ) ? w.safe.end.unix() : moment().unix();
|
|
||||||
});
|
|
||||||
return careerLast.safe.end.diff( careerStart, unit );
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -444,93 +371,108 @@ Definition of the FRESHResume class.
|
|||||||
Sort dated things on the sheet by start date descending. Assumes that dates
|
Sort dated things on the sheet by start date descending. Assumes that dates
|
||||||
on the sheet have been processed with _parseDates().
|
on the sheet have been processed with _parseDates().
|
||||||
*/
|
*/
|
||||||
FreshResume.prototype.sort = function( ) {
|
sort() {
|
||||||
|
|
||||||
function byDateDesc(a,b) {
|
const byDateDesc = function(a,b) {
|
||||||
return( a.safe.start.isBefore(b.safe.start) ) ? 1
|
if (a.safe.start.isBefore(b.safe.start)) {
|
||||||
: ( a.safe.start.isAfter(b.safe.start) && -1 ) || 0;
|
return 1;
|
||||||
}
|
} else { if (a.safe.start.isAfter(b.safe.start)) { return -1; } else { return 0; } }
|
||||||
|
};
|
||||||
|
|
||||||
function sortSection( key ) {
|
const sortSection = function( key ) {
|
||||||
var ar = __.get(this, key);
|
const ar = __.get(this, key);
|
||||||
if( ar && ar.length ) {
|
if (ar && ar.length) {
|
||||||
var datedThings = obj.filter( function(o) { return o.start; } );
|
const datedThings = ar.filter(o => o.start);
|
||||||
datedThings.sort( byDateDesc );
|
return datedThings.sort( byDateDesc );
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
sortSection( 'employment.history' );
|
sortSection('employment.history');
|
||||||
sortSection( 'education.history' );
|
sortSection('education.history');
|
||||||
sortSection( 'service.history' );
|
sortSection('service.history');
|
||||||
sortSection( 'projects.history' );
|
sortSection('projects');
|
||||||
|
|
||||||
// this.awards && this.awards.sort( function(a, b) {
|
return this.writing && this.writing.sort(function(a, b) {
|
||||||
// return( a.safeDate.isBefore(b.safeDate) ) ? 1
|
if (a.safe.date.isBefore(b.safe.date)) {
|
||||||
// : ( a.safeDate.isAfter(b.safeDate) && -1 ) || 0;
|
return 1;
|
||||||
// });
|
} else { return ( a.safe.date.isAfter(b.safe.date) && -1 ) || 0; }
|
||||||
this.writing && this.writing.sort( function(a, b) {
|
|
||||||
return( a.safe.date.isBefore(b.safe.date) ) ? 1
|
|
||||||
: ( a.safe.date.isAfter(b.safe.date) && -1 ) || 0;
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert human-friendly dates into formal Moment.js dates for all collections.
|
|
||||||
We don't want to lose the raw textual date as entered by the user, so we store
|
|
||||||
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
|
||||||
job.startDate is the date as entered by the user. job.safeStartDate is the
|
|
||||||
parsed Moment.js date that we actually use in processing.
|
|
||||||
*/
|
|
||||||
function _parseDates() {
|
|
||||||
|
|
||||||
var _fmt = require('./fluent-date').fmt;
|
|
||||||
var that = this;
|
|
||||||
|
|
||||||
// TODO: refactor recursion
|
|
||||||
function replaceDatesInObject( obj ) {
|
|
||||||
|
|
||||||
if( !obj ) return;
|
|
||||||
if( Object.prototype.toString.call( obj ) === '[object Array]' ) {
|
|
||||||
obj.forEach(function(elem){
|
|
||||||
replaceDatesInObject( elem );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (typeof obj === 'object') {
|
|
||||||
if( obj._isAMomentObject || obj.safe )
|
|
||||||
return;
|
|
||||||
Object.keys( obj ).forEach(function(key) {
|
|
||||||
replaceDatesInObject( obj[key] );
|
|
||||||
});
|
|
||||||
['start','end','date'].forEach( function(val) {
|
|
||||||
if( (obj[val] !== undefined) && (!obj.safe || !obj.safe[val] )) {
|
|
||||||
obj.safe = obj.safe || { };
|
|
||||||
obj.safe[ val ] = _fmt( obj[val] );
|
|
||||||
if( obj[val] && (val === 'start') && !obj.end ) {
|
|
||||||
obj.safe.end = _fmt('current');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.keys( this ).forEach(function(member){
|
|
||||||
replaceDatesInObject( that[ member ] );
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Export the Sheet function/ctor.
|
Get the default (starter) sheet.
|
||||||
*/
|
*/
|
||||||
module.exports = FreshResume;
|
FreshResume.default = () => new FreshResume().parseJSON(require('fresh-resume-starter').fresh);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
/**
|
||||||
|
Convert the supplied FreshResume to a JSON string, sanitizing meta-properties
|
||||||
|
along the way.
|
||||||
|
*/
|
||||||
|
FreshResume.stringify = function( obj ) {
|
||||||
|
const replacer = function( key,value ) { // Exclude these keys from stringification
|
||||||
|
const exKeys = ['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||||
|
'safe', 'result', 'isModified', 'htmlPreview', 'display_progress_bar'];
|
||||||
|
if (_.some( exKeys, val => key.trim() === val)) {
|
||||||
|
return undefined; } else { return value; }
|
||||||
|
};
|
||||||
|
return JSON.stringify(obj, replacer, 2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert human-friendly dates into formal Moment.js dates for all collections.
|
||||||
|
We don't want to lose the raw textual date as entered by the user, so we store
|
||||||
|
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
||||||
|
job.startDate is the date as entered by the user. job.safeStartDate is the
|
||||||
|
parsed Moment.js date that we actually use in processing.
|
||||||
|
*/
|
||||||
|
var _parseDates = function() {
|
||||||
|
|
||||||
|
const _fmt = require('./fluent-date').fmt;
|
||||||
|
const that = this;
|
||||||
|
|
||||||
|
// TODO: refactor recursion
|
||||||
|
var replaceDatesInObject = function( obj ) {
|
||||||
|
|
||||||
|
if (!obj) { return; }
|
||||||
|
if (Object.prototype.toString.call( obj ) === '[object Array]') {
|
||||||
|
obj.forEach(elem => replaceDatesInObject( elem ));
|
||||||
|
return;
|
||||||
|
} else if (typeof obj === 'object') {
|
||||||
|
if (obj._isAMomentObject || obj.safe) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Object.keys( obj ).forEach(key => replaceDatesInObject(obj[key]));
|
||||||
|
['start','end','date'].forEach(function(val) {
|
||||||
|
if ((obj[val] !== undefined) && (!obj.safe || !obj.safe[val])) {
|
||||||
|
obj.safe = obj.safe || { };
|
||||||
|
obj.safe[ val ] = _fmt(obj[val]);
|
||||||
|
if (obj[val] && (val === 'start') && !obj.end) {
|
||||||
|
obj.safe.end = _fmt('current');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Object.keys( this ).forEach(function(member) {
|
||||||
|
replaceDatesInObject(that[member]);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Export the Sheet function/ctor. */
|
||||||
|
module.exports = FreshResume;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Note 1: Adjust default date validation to allow YYYY and YYYY-MM formats
|
// Note 1: Adjust default date validation to allow YYYY and YYYY-MM formats
|
||||||
// in addition to YYYY-MM-DD. The original regex:
|
// in addition to YYYY-MM-DD. The original regex:
|
||||||
|
@ -1,336 +1,253 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS103: Rewrite code to no longer use __guard__
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the FRESHTheme class.
|
Definition of the FRESHTheme class.
|
||||||
@module fresh-theme.js
|
@module core/fresh-theme
|
||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
|
const FS = require('fs');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const PATH = require('path');
|
||||||
|
const parsePath = require('parse-filepath');
|
||||||
|
const EXTEND = require('extend');
|
||||||
|
const HMSTATUS = require('./status-codes');
|
||||||
|
const loadSafeJson = require('../utils/safe-json-loader');
|
||||||
|
const READFILES = require('recursive-readdir-sync');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var FS = require('fs')
|
/* A representation of a FRESH theme asset.
|
||||||
, extend = require('../utils/extend')
|
@class FRESHTheme */
|
||||||
, validator = require('is-my-json-valid')
|
class FRESHTheme {
|
||||||
, _ = require('underscore')
|
|
||||||
, PATH = require('path')
|
|
||||||
, parsePath = require('parse-filepath')
|
|
||||||
, pathExists = require('path-exists').sync
|
|
||||||
, EXTEND = require('../utils/extend')
|
|
||||||
, moment = require('moment')
|
|
||||||
, READFILES = require('recursive-readdir-sync');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
The FRESHTheme class is a representation of a FRESH theme
|
|
||||||
asset. See also: JRSTheme.
|
|
||||||
@class FRESHTheme
|
|
||||||
*/
|
|
||||||
function FRESHTheme() {
|
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.baseFolder = 'src';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Open and parse the specified theme. */
|
||||||
|
open( themeFolder ) {
|
||||||
/**
|
|
||||||
Open and parse the specified theme.
|
|
||||||
*/
|
|
||||||
FRESHTheme.prototype.open = function( themeFolder ) {
|
|
||||||
|
|
||||||
this.folder = themeFolder;
|
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
|
// Set up a formats hash for the theme
|
||||||
var formatsHash = { };
|
let formatsHash = { };
|
||||||
|
|
||||||
// Load the theme
|
// Load the theme
|
||||||
var themeFile = PATH.join( themeFolder, 'theme.json' );
|
const themeFile = PATH.join(themeFolder, 'theme.json');
|
||||||
var themeInfo = JSON.parse( FS.readFileSync( themeFile, 'utf8' ) );
|
const themeInfo = loadSafeJson(themeFile);
|
||||||
var that = this;
|
if (themeInfo.ex) {
|
||||||
|
throw{
|
||||||
|
fluenterror:
|
||||||
|
themeInfo.ex.op === 'parse'
|
||||||
|
? HMSTATUS.parseError
|
||||||
|
: HMSTATUS.readError,
|
||||||
|
inner: themeInfo.ex.inner
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Move properties from the theme JSON file to the theme object
|
// Move properties from the theme JSON file to the theme object
|
||||||
EXTEND( true, this, themeInfo );
|
EXTEND(true, this, themeInfo.json);
|
||||||
|
|
||||||
// Check for an "inherits" entry in the theme JSON.
|
// Check for an "inherits" entry in the theme JSON.
|
||||||
if( this.inherits ) {
|
if (this.inherits) {
|
||||||
var cached = { };
|
const cached = { };
|
||||||
_.each( this.inherits, function(th, key) {
|
_.each(this.inherits, function(th, key) {
|
||||||
var themesFolder = require.resolve('fresh-themes');
|
// First, see if this is one of the predefined FRESH themes. There are
|
||||||
var d = parsePath( themeFolder ).dirname;
|
// only a handful of these, but they may change over time, so we need to
|
||||||
var themePath = PATH.join(d, th);
|
// query the official source of truth: the fresh-themes repository, which
|
||||||
|
// mounts the themes conveniently by name to the module object, and which
|
||||||
|
// is embedded locally inside the HackMyResume installation.
|
||||||
|
// TODO: merge this code with
|
||||||
|
let themePath;
|
||||||
|
const themesObj = require('fresh-themes');
|
||||||
|
if (_.has(themesObj.themes, th)) {
|
||||||
|
themePath = PATH.join(
|
||||||
|
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||||
|
'/themes/',
|
||||||
|
th
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
const d = parsePath( th ).dirname;
|
||||||
|
themePath = PATH.join(d, th);
|
||||||
|
}
|
||||||
|
|
||||||
cached[ th ] = cached[th] || new FRESHTheme().open( themePath );
|
cached[ th ] = cached[th] || new FRESHTheme().open( themePath );
|
||||||
formatsHash[ key ] = cached[ th ].getFormat( key );
|
return formatsHash[ key ] = cached[ th ].getFormat( key );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for an explicit "formats" entry in the theme JSON. If it has one,
|
// Load theme files
|
||||||
// then this theme declares its files explicitly.
|
formatsHash = _load.call(this, formatsHash);
|
||||||
if( !!this.formats ) {
|
|
||||||
formatsHash = loadExplicit.call( this, formatsHash );
|
|
||||||
this.explicit = true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
formatsHash = loadImplicit.call( this, formatsHash );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
this.formats = formatsHash;
|
this.formats = formatsHash;
|
||||||
|
|
||||||
// Set the official theme name
|
// Set the official theme name
|
||||||
this.name = parsePath( this.folder ).name;
|
this.name = parsePath( this.folder ).name;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Determine if the theme supports the specified output format.
|
|
||||||
*/
|
|
||||||
FRESHTheme.prototype.hasFormat = function( fmt ) {
|
|
||||||
return _.has( this.formats, fmt );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Determine if the theme supports the specified output format.
|
|
||||||
*/
|
|
||||||
FRESHTheme.prototype.getFormat = function( fmt ) {
|
|
||||||
return this.formats[ fmt ];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Load the theme implicitly, by scanning the theme folder for
|
|
||||||
files. TODO: Refactor duplicated code with loadExplicit.
|
|
||||||
*/
|
|
||||||
function loadImplicit(formatsHash) {
|
|
||||||
|
|
||||||
// Set up a hash of formats supported by this theme.
|
|
||||||
var that = this;
|
|
||||||
var major = false;
|
|
||||||
|
|
||||||
// Establish the base theme folder
|
|
||||||
var tplFolder = PATH.join( this.folder, 'src' );
|
|
||||||
|
|
||||||
// Iterate over all files in the theme folder, producing an array, fmts,
|
|
||||||
// containing info for each file. While we're doing that, also build up
|
|
||||||
// the formatsHash object.
|
|
||||||
var fmts = READFILES(tplFolder).map( function(absPath) {
|
|
||||||
|
|
||||||
// If this file lives in a specific format folder within the theme,
|
|
||||||
// such as "/latex" or "/html", then that format is the output format
|
|
||||||
// for all files within the folder.
|
|
||||||
var pathInfo = parsePath(absPath);
|
|
||||||
var outFmt = '', isMajor = false;
|
|
||||||
var portion = pathInfo.dirname.replace(tplFolder,'');
|
|
||||||
if( portion && portion.trim() ) {
|
|
||||||
if( portion[1] === '_' ) return;
|
|
||||||
var reg = /^(?:\/|\\)(html|latex|doc|pdf|png|partials)(?:\/|\\)?/ig;
|
|
||||||
var res = reg.exec( portion );
|
|
||||||
if( res ) {
|
|
||||||
if( res[1] !== 'partials' ) {
|
|
||||||
outFmt = res[1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
that.partials = that.partials || [];
|
|
||||||
that.partials.push( { name: pathInfo.name, path: absPath } );
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, the output format is inferred from the filename, as in
|
|
||||||
// compact-[outputformat].[extension], for ex, compact-pdf.html.
|
|
||||||
if( !outFmt ) {
|
|
||||||
var idx = pathInfo.name.lastIndexOf('-');
|
|
||||||
outFmt = (idx === -1) ? pathInfo.name : pathInfo.name.substr(idx + 1);
|
|
||||||
isMajor = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We should have a valid output format now.
|
|
||||||
formatsHash[ outFmt ] = formatsHash[outFmt] || {
|
|
||||||
outFormat: outFmt,
|
|
||||||
files: []
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the file representation object.
|
|
||||||
var obj = {
|
|
||||||
action: 'transform',
|
|
||||||
path: absPath,
|
|
||||||
major: isMajor,
|
|
||||||
orgPath: PATH.relative(tplFolder, absPath),
|
|
||||||
ext: pathInfo.extname.slice(1),
|
|
||||||
title: friendlyName( outFmt ),
|
|
||||||
pre: outFmt,
|
|
||||||
// outFormat: outFmt || pathInfo.name,
|
|
||||||
data: FS.readFileSync( absPath, 'utf8' ),
|
|
||||||
css: null
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add this file to the list of files for this format type.
|
|
||||||
formatsHash[ outFmt ].files.push( obj );
|
|
||||||
return obj;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Now, get all the CSS files...
|
|
||||||
(this.cssFiles = fmts.filter(function( fmt ){
|
|
||||||
return fmt && (fmt.ext === 'css');
|
|
||||||
}))
|
|
||||||
|
|
||||||
// For each CSS file, get its corresponding HTML file. It's possible that
|
|
||||||
// a theme can have a CSS file but *no* HTML file, as when a theme author
|
|
||||||
// creates a pure CSS override of an existing theme.
|
|
||||||
.forEach(function( cssf ) {
|
|
||||||
|
|
||||||
var idx = _.findIndex(fmts, function( fmt ) {
|
|
||||||
return fmt && fmt.pre === cssf.pre && fmt.ext === 'html';
|
|
||||||
});
|
|
||||||
cssf.action = null;
|
|
||||||
if( idx > -1) {
|
|
||||||
fmts[ idx ].css = cssf.data;
|
|
||||||
fmts[ idx ].cssPath = cssf.path;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if( that.inherits ) {
|
|
||||||
// Found a CSS file without an HTML file in a theme that inherits
|
|
||||||
// from another theme. This is the override CSS file.
|
|
||||||
that.overrides = { file: cssf.path, data: cssf.data };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Remove CSS files from the formats array
|
|
||||||
fmts = fmts.filter( function( fmt) {
|
|
||||||
return fmt && (fmt.ext !== 'css');
|
|
||||||
});
|
|
||||||
|
|
||||||
return formatsHash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Determine if the theme supports the specified output format. */
|
||||||
|
hasFormat( fmt ) { return _.has(this.formats, fmt); }
|
||||||
|
|
||||||
|
/* Determine if the theme supports the specified output format. */
|
||||||
|
getFormat( fmt ) { return this.formats[ fmt ]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Load the theme explicitly, by following the 'formats' hash
|
|
||||||
in the theme's JSON settings file.
|
|
||||||
*/
|
|
||||||
function loadExplicit(formatsHash) {
|
|
||||||
|
|
||||||
// Housekeeping
|
/* Load and parse theme source files. */
|
||||||
var tplFolder = PATH.join( this.folder, 'src' );
|
var _load = function(formatsHash) {
|
||||||
var act = null;
|
|
||||||
var that = this;
|
|
||||||
|
|
||||||
// Iterate over all files in the theme folder, producing an array, fmts,
|
const that = this;
|
||||||
// containing info for each file. While we're doing that, also build up
|
const tplFolder = PATH.join(this.folder, this.baseFolder);
|
||||||
// the formatsHash object.
|
|
||||||
var fmts = READFILES( tplFolder ).map( function( absPath ) {
|
|
||||||
|
|
||||||
act = null;
|
// Iterate over all files in the theme folder, producing an array, fmts,
|
||||||
// If this file is mentioned in the theme's JSON file under "transforms"
|
// containing info for each file. While we're doing that, also build up
|
||||||
var pathInfo = parsePath(absPath);
|
// the formatsHash object.
|
||||||
var absPathSafe = absPath.trim().toLowerCase();
|
const fmts = READFILES(tplFolder).map(function(absPath) {
|
||||||
var outFmt = _.find(
|
return _loadOne.call(this, absPath, formatsHash, tplFolder);
|
||||||
Object.keys( that.formats ),
|
}
|
||||||
function( fmtKey ) {
|
, this);
|
||||||
var fmtVal = that.formats[ fmtKey ];
|
|
||||||
return _.some( fmtVal.transform, function(fpath) {
|
|
||||||
var absPathB = PATH.join( that.folder, fpath )
|
|
||||||
.trim().toLowerCase();
|
|
||||||
return absPathB === absPathSafe;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
if( outFmt ) {
|
|
||||||
act = 'transform';
|
|
||||||
}
|
|
||||||
|
|
||||||
// If this file lives in a specific format folder within the theme,
|
// Now, get all the CSS files...
|
||||||
// such as "/latex" or "/html", then that format is the output format
|
this.cssFiles = fmts.filter(fmt => fmt && (fmt.ext === 'css'));
|
||||||
// for all files within the folder.
|
|
||||||
if( !outFmt ) {
|
|
||||||
var portion = pathInfo.dirname.replace(tplFolder,'');
|
|
||||||
if( portion && portion.trim() ) {
|
|
||||||
var reg = /^(?:\/|\\)(html|latex|doc|pdf)(?:\/|\\)?/ig;
|
|
||||||
var res = reg.exec( portion );
|
|
||||||
res && (outFmt = res[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, the output format is inferred from the filename, as in
|
// For each CSS file, get its corresponding HTML file. It's possible that
|
||||||
// compact-[outputformat].[extension], for ex, compact-pdf.html.
|
// a theme can have a CSS file but *no* HTML file, as when a theme author
|
||||||
if( !outFmt ) {
|
// creates a pure CSS override of an existing theme.
|
||||||
var idx = pathInfo.name.lastIndexOf('-');
|
this.cssFiles.forEach(function(cssf) {
|
||||||
outFmt = (idx === -1) ? pathInfo.name : pathInfo.name.substr(idx + 1);
|
const idx = _.findIndex(fmts, fmt => fmt && (fmt.pre === cssf.pre) && (fmt.ext === 'html'));
|
||||||
}
|
cssf.major = false;
|
||||||
|
if (idx > -1) {
|
||||||
// We should have a valid output format now.
|
|
||||||
formatsHash[ outFmt ] =
|
|
||||||
formatsHash[ outFmt ] || {
|
|
||||||
outFormat: outFmt,
|
|
||||||
files: [],
|
|
||||||
symLinks: that.formats[ outFmt ].symLinks
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the file representation object.
|
|
||||||
var obj = {
|
|
||||||
action: act,
|
|
||||||
orgPath: PATH.relative(that.folder, absPath),
|
|
||||||
path: absPath,
|
|
||||||
ext: pathInfo.extname.slice(1),
|
|
||||||
title: friendlyName( outFmt ),
|
|
||||||
pre: outFmt,
|
|
||||||
// outFormat: outFmt || pathInfo.name,
|
|
||||||
data: FS.readFileSync( absPath, 'utf8' ),
|
|
||||||
css: null
|
|
||||||
};
|
|
||||||
|
|
||||||
// Add this file to the list of files for this format type.
|
|
||||||
formatsHash[ outFmt ].files.push( obj );
|
|
||||||
return obj;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Now, get all the CSS files...
|
|
||||||
(this.cssFiles = fmts.filter(function( fmt ){
|
|
||||||
return fmt.ext === 'css';
|
|
||||||
}))
|
|
||||||
|
|
||||||
// For each CSS file, get its corresponding HTML file
|
|
||||||
.forEach(function( cssf ) {
|
|
||||||
// For each CSS file, get its corresponding HTML file
|
|
||||||
var idx = _.findIndex(fmts, function( fmt ) {
|
|
||||||
return fmt.pre === cssf.pre && fmt.ext === 'html';
|
|
||||||
});
|
|
||||||
fmts[ idx ].css = cssf.data;
|
fmts[ idx ].css = cssf.data;
|
||||||
fmts[ idx ].cssPath = cssf.path;
|
return fmts[ idx ].cssPath = cssf.path;
|
||||||
});
|
} else {
|
||||||
|
if (that.inherits) {
|
||||||
|
// Found a CSS file without an HTML file in a theme that inherits
|
||||||
|
// from another theme. This is the override CSS file.
|
||||||
|
return that.overrides = { file: cssf.path, data: cssf.data };
|
||||||
|
}
|
||||||
|
}});
|
||||||
|
|
||||||
// Remove CSS files from the formats array
|
// Now, save all the javascript file paths to a theme property.
|
||||||
fmts = fmts.filter( function( fmt) {
|
const jsFiles = fmts.filter(fmt => fmt && (fmt.ext === 'js'));
|
||||||
return fmt.ext !== 'css';
|
this.jsFiles = jsFiles.map(jsf => jsf['path']);
|
||||||
});
|
|
||||||
|
|
||||||
return formatsHash;
|
return formatsHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Load a single theme file. */
|
||||||
|
var _loadOne = function( absPath, formatsHash, tplFolder ) {
|
||||||
|
|
||||||
|
const pathInfo = parsePath(absPath);
|
||||||
|
if (pathInfo.basename.toLowerCase() === 'theme.json') { return; }
|
||||||
|
|
||||||
|
const absPathSafe = absPath.trim().toLowerCase();
|
||||||
|
let outFmt = '';
|
||||||
|
let act = 'copy';
|
||||||
|
let isPrimary = false;
|
||||||
|
|
||||||
|
// If this is an "explicit" theme, all files of importance are specified in
|
||||||
|
// the "transform" section of the theme.json file.
|
||||||
|
if (this.explicit) {
|
||||||
|
|
||||||
|
outFmt = _.find(Object.keys( this.formats ), function( fmtKey ) {
|
||||||
|
const fmtVal = this.formats[ fmtKey ];
|
||||||
|
return _.some(fmtVal.transform, function(fpath) {
|
||||||
|
const absPathB = PATH.join( this.folder, fpath ).trim().toLowerCase();
|
||||||
|
return absPathB === absPathSafe;
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
if (outFmt) { act = 'transform'; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!outFmt) {
|
||||||
|
// If this file lives in a specific format folder within the theme,
|
||||||
/**
|
// such as "/latex" or "/html", then that format is the implicit output
|
||||||
Return a more friendly name for certain formats.
|
// format for all files within the folder
|
||||||
TODO: Refactor
|
const portion = pathInfo.dirname.replace(tplFolder,'');
|
||||||
*/
|
if (portion && portion.trim()) {
|
||||||
function friendlyName( val ) {
|
if (portion[1] === '_') { return; }
|
||||||
val = val.trim().toLowerCase();
|
const reg = /^(?:\/|\\)(html|latex|doc|pdf|png|partials)(?:\/|\\)?/ig;
|
||||||
var friendly = { yml: 'yaml', md: 'markdown', txt: 'text' };
|
const res = reg.exec( portion );
|
||||||
return friendly[val] || val;
|
if (res) {
|
||||||
|
if (res[1] !== 'partials') {
|
||||||
|
outFmt = res[1];
|
||||||
|
if (!this.explicit) { act = 'transform'; }
|
||||||
|
} else {
|
||||||
|
this.partials = this.partials || [];
|
||||||
|
this.partials.push( { name: pathInfo.name, path: absPath } );
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, the output format is inferred from the filename, as in
|
||||||
|
// compact-[outputformat].[extension], for ex, compact-pdf.html
|
||||||
|
if (!outFmt) {
|
||||||
|
const idx = pathInfo.name.lastIndexOf('-');
|
||||||
|
outFmt = idx === -1 ? pathInfo.name : pathInfo.name.substr(idx+1);
|
||||||
|
if (!this.explicit) { act = 'transform'; }
|
||||||
|
const defFormats = require('./default-formats');
|
||||||
|
isPrimary = _.some(defFormats, form => (form.name === outFmt) && (pathInfo.extname !== '.css'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we have a valid formatsHash
|
||||||
|
formatsHash[ outFmt ] = formatsHash[outFmt] || {
|
||||||
|
outFormat: outFmt,
|
||||||
|
files: []
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = FRESHTheme;
|
// Move symlink descriptions from theme.json to the format
|
||||||
|
if (__guard__(this.formats != null ? this.formats[outFmt ] : undefined, x => x.symLinks)) {
|
||||||
|
formatsHash[ outFmt ].symLinks = this.formats[ outFmt ].symLinks;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the file representation object
|
||||||
|
const obj = {
|
||||||
|
action: act,
|
||||||
|
primary: isPrimary,
|
||||||
|
path: absPath,
|
||||||
|
orgPath: PATH.relative(tplFolder, absPath),
|
||||||
|
ext: pathInfo.extname.slice(1),
|
||||||
|
title: friendlyName(outFmt),
|
||||||
|
pre: outFmt,
|
||||||
|
// outFormat: outFmt || pathInfo.name,
|
||||||
|
data: FS.readFileSync(absPath, 'utf8'),
|
||||||
|
css: null
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add this file to the list of files for this format type.
|
||||||
|
formatsHash[ outFmt ].files.push( obj );
|
||||||
|
return obj;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
/* Return a more friendly name for certain formats. */
|
||||||
|
var friendlyName = function( val ) {
|
||||||
|
val = (val && val.trim().toLowerCase()) || '';
|
||||||
|
const friendly = { yml: 'yaml', md: 'markdown', txt: 'text' };
|
||||||
|
return friendly[val] || val;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = FRESHTheme;
|
||||||
|
|
||||||
|
function __guard__(value, transform) {
|
||||||
|
return (typeof value !== 'undefined' && value !== null) ? transform(value) : undefined;
|
||||||
|
}
|
||||||
|
@ -1,167 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS206: Consider reworking classes to avoid initClass
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the JRSResume class.
|
Definition of the JRSResume class.
|
||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module jrs-resume.js
|
@module core/jrs-resume
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
const FS = require('fs');
|
||||||
|
const extend = require('extend');
|
||||||
|
let validator = require('is-my-json-valid');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const PATH = require('path');
|
||||||
|
const CONVERTER = require('fresh-jrs-converter');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
A JRS resume or CV. JRS resumes are backed by JSON, and each JRSResume object
|
||||||
|
is an instantiation of that JSON decorated with utility methods.
|
||||||
|
@class JRSResume
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class JRSResume {
|
||||||
|
|
||||||
|
static initClass() {
|
||||||
|
/** Reset the sheet to an empty state. */
|
||||||
|
// clear = function( clearMeta ) {
|
||||||
|
// clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
||||||
|
// if (clearMeta) { delete this.imp; }
|
||||||
|
// delete this.basics.computed; // Don't use Object.keys() here
|
||||||
|
// delete this.work;
|
||||||
|
// delete this.volunteer;
|
||||||
|
// delete this.education;
|
||||||
|
// delete this.awards;
|
||||||
|
// delete this.publications;
|
||||||
|
// delete this.interests;
|
||||||
|
// delete this.skills;
|
||||||
|
// return delete this.basics.profiles;
|
||||||
|
// };
|
||||||
|
// extends AbstractResume
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var FS = require('fs')
|
/** Initialize the the JSResume from string. */
|
||||||
, extend = require('../utils/extend')
|
parse( stringData, opts ) {
|
||||||
, validator = require('is-my-json-valid')
|
this.imp = this.imp != null ? this.imp : {raw: stringData};
|
||||||
, _ = require('underscore')
|
return this.parseJSON(JSON.parse( stringData ), opts);
|
||||||
, PATH = require('path')
|
|
||||||
, MD = require('marked')
|
|
||||||
, CONVERTER = require('./convert')
|
|
||||||
, moment = require('moment');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
A JRS resume or CV. JRS resumes are backed by JSON, and each JRSResume object
|
|
||||||
is an instantiation of that JSON decorated with utility methods.
|
|
||||||
@class JRSResume
|
|
||||||
*/
|
|
||||||
function JRSResume() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the JSResume from file.
|
Initialize the JRSResume object from JSON.
|
||||||
|
Open and parse the specified JRS 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.
|
||||||
|
@param rep {Object} The raw JSON representation.
|
||||||
|
@param opts {Object} Resume loading and parsing options.
|
||||||
|
{
|
||||||
|
date: Perform safe date conversion.
|
||||||
|
sort: Sort resume items by date.
|
||||||
|
compute: Prepare computed resume totals.
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
JRSResume.prototype.open = function( file, title ) {
|
parseJSON( rep, opts ) {
|
||||||
//this.imp = { fileName: file }; <-- schema violation, tuck it into .basics
|
let scrubbed;
|
||||||
this.basics = {
|
|
||||||
imp: {
|
|
||||||
fileName: file,
|
|
||||||
raw: FS.readFileSync( file, 'utf8' )
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return this.parse( this.basics.imp.raw, title );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the the JSResume from string.
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.parse = function( stringData, opts ) {
|
|
||||||
opts = opts || { };
|
opts = opts || { };
|
||||||
var rep = JSON.parse( stringData );
|
if (opts.privatize) {
|
||||||
return this.parseJSON( rep, opts );
|
const scrubber = require('../utils/resume-scrubber');
|
||||||
};
|
// Ignore any element with the 'ignore: true' or 'private: true' designator.
|
||||||
|
var ret = scrubber.scrubResume(rep, opts);
|
||||||
|
scrubbed = ret.scrubbed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extend resume properties onto ourself.
|
||||||
|
extend(true, this, opts.privatize ? scrubbed : rep);
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize the JRSResume from JSON.
|
|
||||||
Open and parse the specified JRS 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.
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.parseJSON = function( rep, opts ) {
|
|
||||||
opts = opts || { };
|
|
||||||
extend( true, this, rep );
|
|
||||||
// Set up metadata
|
// Set up metadata
|
||||||
if( opts.imp === undefined || opts.imp ) {
|
if (!(this.imp != null ? this.imp.processed : undefined)) {
|
||||||
this.basics.imp = this.basics.imp || { };
|
// Set up metadata TODO: Clean up metadata on the object model.
|
||||||
this.basics.imp.title =
|
opts = opts || { };
|
||||||
(opts.title || this.basics.imp.title) || this.basics.name;
|
if ((opts.imp === undefined) || opts.imp) {
|
||||||
this.basics.imp.orgFormat = 'JRS';
|
this.imp = this.imp || { };
|
||||||
|
this.imp.title = (opts.title || this.imp.title) || this.basics.name;
|
||||||
|
if (!this.imp.raw) {
|
||||||
|
this.imp.raw = JSON.stringify(rep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.imp.processed = true;
|
||||||
}
|
}
|
||||||
// Parse dates, sort dates, and calculate computed values
|
// Parse dates, sort dates, and calculate computed values
|
||||||
(opts.date === undefined || opts.date) && _parseDates.call( this );
|
((opts.date === undefined) || opts.date) && _parseDates.call( this );
|
||||||
(opts.sort === undefined || opts.sort) && this.sort();
|
((opts.sort === undefined) || opts.sort) && this.sort();
|
||||||
(opts.compute === undefined || opts.compute) && (this.basics.computed = {
|
if ((opts.compute === undefined) || opts.compute) {
|
||||||
numYears: this.duration(),
|
this.basics.computed = {
|
||||||
keywords: this.keywords()
|
numYears: this.duration(),
|
||||||
});
|
keywords: this.keywords()
|
||||||
return this;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Save the sheet to disk (for environments that have disk access).
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.save = function( filename ) {
|
|
||||||
this.basics.imp.fileName = filename || this.basics.imp.fileName;
|
|
||||||
FS.writeFileSync(this.basics.imp.fileName, this.stringify( this ), 'utf8');
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Save the sheet to disk in a specific format, either FRESH or JRS.
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.saveAs = function( filename, format ) {
|
|
||||||
|
|
||||||
if( format === 'JRS' ) {
|
|
||||||
this.basics.imp.fileName = filename || this.imp.fileName;
|
|
||||||
FS.writeFileSync( this.basics.imp.fileName, this.stringify(), 'utf8' );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var newRep = CONVERTER.toFRESH( this );
|
|
||||||
var stringRep = CONVERTER.toSTRING( newRep );
|
|
||||||
FS.writeFileSync( filename, stringRep, 'utf8' );
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Save the sheet to disk (for environments that have disk access). */
|
||||||
Return the resume format.
|
save( filename ) {
|
||||||
*/
|
this.imp.file = filename || this.imp.file;
|
||||||
JRSResume.prototype.format = function() {
|
FS.writeFileSync(this.imp.file, this.stringify( this ), 'utf8');
|
||||||
return 'JRS';
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Save the sheet to disk in a specific format, either FRESH or JRS. */
|
||||||
Convert this object to a JSON string, sanitizing meta-properties along the
|
saveAs( filename, format ) {
|
||||||
way. Don't override .toString().
|
if (format === 'JRS') {
|
||||||
*/
|
this.imp.file = filename || this.imp.file;
|
||||||
JRSResume.stringify = function( obj ) {
|
FS.writeFileSync( this.imp.file, this.stringify(), 'utf8' );
|
||||||
function replacer( key,value ) { // Exclude these keys from stringification
|
} else {
|
||||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
const newRep = CONVERTER.toFRESH(this);
|
||||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
const stringRep = CONVERTER.toSTRING(newRep);
|
||||||
'isModified', 'htmlPreview', 'display_progress_bar'],
|
FS.writeFileSync(filename, stringRep, 'utf8');
|
||||||
function( val ) { return key.trim() === val; }
|
|
||||||
) ? undefined : value;
|
|
||||||
}
|
}
|
||||||
return JSON.stringify( obj, replacer, 2 );
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JRSResume.prototype.stringify = function() {
|
/** Return the resume format. */
|
||||||
return JRSResume.stringify( this );
|
format() { return 'JRS'; }
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
stringify() { return JRSResume.stringify( this ); }
|
||||||
Return a unique list of all keywords across all skills.
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.keywords = function() {
|
|
||||||
var flatSkills = [];
|
/** Return a unique list of all keywords across all skills. */
|
||||||
if( this.skills && this.skills.length ) {
|
keywords() {
|
||||||
this.skills.forEach( function( s ) {
|
let flatSkills = [];
|
||||||
flatSkills = _.union( flatSkills, s.keywords );
|
if (this.skills && this.skills.length) {
|
||||||
});
|
this.skills.forEach( s => flatSkills = _.union(flatSkills, s.keywords));
|
||||||
}
|
}
|
||||||
return flatSkills;
|
return flatSkills;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -170,123 +160,66 @@ Definition of the JRSResume class.
|
|||||||
JSON Resume v0.0.0 doesn't allow additional properties at the root level,
|
JSON Resume v0.0.0 doesn't allow additional properties at the root level,
|
||||||
so tuck this into the .basic sub-object.
|
so tuck this into the .basic sub-object.
|
||||||
*/
|
*/
|
||||||
JRSResume.prototype.i = function() {
|
i() {
|
||||||
this.basics = this.basics || { imp: { } };
|
return this.imp = this.imp != null ? this.imp : { };
|
||||||
return this.basics;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Add work experience to the sheet. */
|
||||||
Reset the sheet to an empty state.
|
add( moniker ) {
|
||||||
*/
|
const defSheet = JRSResume.default();
|
||||||
JRSResume.prototype.clear = function( clearMeta ) {
|
const newObject = extend( true, {}, defSheet[ moniker ][0] );
|
||||||
clearMeta = ((clearMeta === undefined) && true) || clearMeta;
|
|
||||||
clearMeta && (delete this.imp);
|
|
||||||
delete this.basics.computed; // Don't use Object.keys() here
|
|
||||||
delete this.work;
|
|
||||||
delete this.volunteer;
|
|
||||||
delete this.education;
|
|
||||||
delete this.awards;
|
|
||||||
delete this.publications;
|
|
||||||
delete this.interests;
|
|
||||||
delete this.skills;
|
|
||||||
delete this.basics.profiles;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the default (empty) sheet.
|
|
||||||
*/
|
|
||||||
JRSResume.default = function() {
|
|
||||||
return new JRSResume().open(
|
|
||||||
PATH.join( __dirname, 'empty-jrs.json'), 'Empty'
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Add work experience to the sheet.
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.add = function( moniker ) {
|
|
||||||
var defSheet = JRSResume.default();
|
|
||||||
var newObject = $.extend( true, {}, defSheet[ moniker ][0] );
|
|
||||||
this[ moniker ] = this[ moniker ] || [];
|
this[ moniker ] = this[ moniker ] || [];
|
||||||
this[ moniker ].push( newObject );
|
this[ moniker ].push( newObject );
|
||||||
return newObject;
|
return newObject;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Determine if the sheet includes a specific social profile (eg, GitHub). */
|
||||||
Determine if the sheet includes a specific social profile (eg, GitHub).
|
hasProfile( socialNetwork ) {
|
||||||
*/
|
|
||||||
JRSResume.prototype.hasProfile = function( socialNetwork ) {
|
|
||||||
socialNetwork = socialNetwork.trim().toLowerCase();
|
socialNetwork = socialNetwork.trim().toLowerCase();
|
||||||
return this.basics.profiles && _.some( this.basics.profiles, function(p) {
|
return this.basics.profiles && _.some(this.basics.profiles, p => p.network.trim().toLowerCase() === socialNetwork);
|
||||||
return p.network.trim().toLowerCase() === socialNetwork;
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Determine if the sheet includes a specific skill. */
|
||||||
Determine if the sheet includes a specific skill.
|
hasSkill( skill ) {
|
||||||
*/
|
|
||||||
JRSResume.prototype.hasSkill = function( skill ) {
|
|
||||||
skill = skill.trim().toLowerCase();
|
skill = skill.trim().toLowerCase();
|
||||||
return this.skills && _.some( this.skills, function(sk) {
|
return this.skills && _.some(this.skills, sk =>
|
||||||
return sk.keywords && _.some( sk.keywords, function(kw) {
|
sk.keywords && _.some(sk.keywords, kw => kw.trim().toLowerCase() === skill)
|
||||||
return kw.trim().toLowerCase() === skill;
|
);
|
||||||
});
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/** Validate the sheet against the JSON Resume schema. */
|
||||||
Validate the sheet against the JSON Resume schema.
|
isValid( ) { // TODO: ↓ fix this path ↓
|
||||||
*/
|
const schema = FS.readFileSync(PATH.join( __dirname, 'resume.json' ), 'utf8');
|
||||||
JRSResume.prototype.isValid = function( ) { // TODO: ↓ fix this path ↓
|
const schemaObj = JSON.parse(schema);
|
||||||
var schema = FS.readFileSync( PATH.join( __dirname, 'resume.json' ),'utf8');
|
validator = require('is-my-json-valid');
|
||||||
var schemaObj = JSON.parse( schema );
|
const validate = validator( schemaObj, { // Note [1]
|
||||||
var validator = require('is-my-json-valid');
|
|
||||||
var validate = validator( schemaObj, { // Note [1]
|
|
||||||
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
|
formats: { date: /^\d{4}(?:-(?:0[0-9]{1}|1[0-2]{1})(?:-[0-9]{2})?)?$/ }
|
||||||
});
|
});
|
||||||
var ret = validate( this );
|
const temp = this.imp;
|
||||||
if( !ret ) {
|
delete this.imp;
|
||||||
this.basics.imp = this.basics.imp || { };
|
const ret = validate(this);
|
||||||
this.basics.imp.validationErrors = validate.errors;
|
this.imp = temp;
|
||||||
|
if (!ret) {
|
||||||
|
this.imp = this.imp || { };
|
||||||
|
this.imp.validationErrors = validate.errors;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
duration(unit) {
|
||||||
Calculate the total duration of the sheet. Assumes this.work has been sorted
|
const inspector = require('../inspectors/duration-inspector');
|
||||||
by start date descending, perhaps via a call to Sheet.sort().
|
return inspector.run(this, 'work', 'startDate', 'endDate', unit);
|
||||||
@returns The total duration of the sheet's work history, that is, the number
|
}
|
||||||
of years between the start date of the earliest job on the resume and the
|
|
||||||
*latest end date of all jobs in the work history*. This last condition is for
|
|
||||||
sheets that have overlapping jobs.
|
|
||||||
*/
|
|
||||||
JRSResume.prototype.duration = function() {
|
|
||||||
if( this.work && this.work.length ) {
|
|
||||||
var careerStart = this.work[ this.work.length - 1].safeStartDate;
|
|
||||||
if ((typeof careerStart === 'string' || careerStart instanceof String) &&
|
|
||||||
!careerStart.trim())
|
|
||||||
return 0;
|
|
||||||
var careerLast = _.max( this.work, function( w ) {
|
|
||||||
return w.safeEndDate.unix();
|
|
||||||
}).safeEndDate;
|
|
||||||
return careerLast.diff( careerStart, 'years' );
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -294,35 +227,38 @@ Definition of the JRSResume class.
|
|||||||
Sort dated things on the sheet by start date descending. Assumes that dates
|
Sort dated things on the sheet by start date descending. Assumes that dates
|
||||||
on the sheet have been processed with _parseDates().
|
on the sheet have been processed with _parseDates().
|
||||||
*/
|
*/
|
||||||
JRSResume.prototype.sort = function( ) {
|
sort( ) {
|
||||||
|
|
||||||
this.work && this.work.sort( byDateDesc );
|
const byDateDesc = function(a,b) {
|
||||||
this.education && this.education.sort( byDateDesc );
|
if (a.safeStartDate.isBefore(b.safeStartDate)) {
|
||||||
this.volunteer && this.volunteer.sort( byDateDesc );
|
return 1;
|
||||||
|
} else { return ( a.safeStartDate.isAfter(b.safeStartDate) && -1 ) || 0; }
|
||||||
|
};
|
||||||
|
|
||||||
this.awards && this.awards.sort( function(a, b) {
|
this.work && this.work.sort(byDateDesc);
|
||||||
return( a.safeDate.isBefore(b.safeDate) ) ? 1
|
this.education && this.education.sort(byDateDesc);
|
||||||
: ( a.safeDate.isAfter(b.safeDate) && -1 ) || 0;
|
this.volunteer && this.volunteer.sort(byDateDesc);
|
||||||
});
|
|
||||||
this.publications && this.publications.sort( function(a, b) {
|
this.awards && this.awards.sort(function(a, b) {
|
||||||
return( a.safeReleaseDate.isBefore(b.safeReleaseDate) ) ? 1
|
if (a.safeDate.isBefore(b.safeDate)) {
|
||||||
: ( a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1 ) || 0;
|
return 1;
|
||||||
|
} else { return (a.safeDate.isAfter(b.safeDate) && -1 ) || 0; }
|
||||||
});
|
});
|
||||||
|
|
||||||
function byDateDesc(a,b) {
|
return this.publications && this.publications.sort(function(a, b) {
|
||||||
return( a.safeStartDate.isBefore(b.safeStartDate) ) ? 1
|
if ( a.safeReleaseDate.isBefore(b.safeReleaseDate) ) {
|
||||||
: ( a.safeStartDate.isAfter(b.safeStartDate) && -1 ) || 0;
|
return 1;
|
||||||
}
|
} else { return ( a.safeReleaseDate.isAfter(b.safeReleaseDate) && -1 ) || 0; }
|
||||||
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
JRSResume.prototype.dupe = function() {
|
dupe() {
|
||||||
var rnew = new JRSResume();
|
const rnew = new JRSResume();
|
||||||
rnew.parse( this.stringify(), { } );
|
rnew.parse(this.stringify(), { });
|
||||||
return rnew;
|
return rnew;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -330,102 +266,83 @@ Definition of the JRSResume class.
|
|||||||
Create a copy of this resume in which all fields have been interpreted as
|
Create a copy of this resume in which all fields have been interpreted as
|
||||||
Markdown.
|
Markdown.
|
||||||
*/
|
*/
|
||||||
JRSResume.prototype.harden = function() {
|
harden() {
|
||||||
|
|
||||||
var that = this;
|
const ret = this.dupe();
|
||||||
var ret = this.dupe();
|
|
||||||
|
|
||||||
function HD(txt) {
|
const HD = txt => `@@@@~${txt}~@@@@`;
|
||||||
return '@@@@~' + txt + '~@@@@';
|
|
||||||
}
|
|
||||||
|
|
||||||
function HDIN(txt){
|
// const HDIN = txt =>
|
||||||
//return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
// //return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
||||||
return HD(txt);
|
// HD(txt)
|
||||||
}
|
// ;
|
||||||
|
|
||||||
// TODO: refactor recursion
|
const transformer = require('../utils/string-transformer');
|
||||||
function hardenStringsInObject( obj, inline ) {
|
return transformer(ret,
|
||||||
|
[ 'skills','url','website','startDate','endDate', 'releaseDate', 'date',
|
||||||
if( !obj ) return;
|
'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(function(elem, idx, ar){
|
|
||||||
if( typeof elem === 'string' || elem instanceof String )
|
|
||||||
ar[idx] = inline ? HDIN(elem) : HD( elem );
|
|
||||||
else
|
|
||||||
hardenStringsInObject( elem );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else if (typeof obj === 'object') {
|
|
||||||
Object.keys( obj ).forEach(function(key) {
|
|
||||||
var 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] = inline ? HDIN( obj[key] ) : HD( obj[key] );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
hardenStringsInObject( sub );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.keys( ret ).forEach(function(member){
|
|
||||||
hardenStringsInObject( ret[ member ] );
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert human-friendly dates into formal Moment.js dates for all collections.
|
|
||||||
We don't want to lose the raw textual date as entered by the user, so we store
|
|
||||||
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
|
||||||
job.startDate is the date as entered by the user. job.safeStartDate is the
|
|
||||||
parsed Moment.js date that we actually use in processing.
|
|
||||||
*/
|
|
||||||
function _parseDates() {
|
|
||||||
|
|
||||||
var _fmt = require('./fluent-date').fmt;
|
|
||||||
|
|
||||||
this.work && this.work.forEach( function(job) {
|
|
||||||
job.safeStartDate = _fmt( job.startDate );
|
|
||||||
job.safeEndDate = _fmt( job.endDate );
|
|
||||||
});
|
|
||||||
this.education && this.education.forEach( function(edu) {
|
|
||||||
edu.safeStartDate = _fmt( edu.startDate );
|
|
||||||
edu.safeEndDate = _fmt( edu.endDate );
|
|
||||||
});
|
|
||||||
this.volunteer && this.volunteer.forEach( function(vol) {
|
|
||||||
vol.safeStartDate = _fmt( vol.startDate );
|
|
||||||
vol.safeEndDate = _fmt( vol.endDate );
|
|
||||||
});
|
|
||||||
this.awards && this.awards.forEach( function(awd) {
|
|
||||||
awd.safeDate = _fmt( awd.date );
|
|
||||||
});
|
|
||||||
this.publications && this.publications.forEach( function(pub) {
|
|
||||||
pub.safeReleaseDate = _fmt( pub.releaseDate );
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JRSResume.initClass();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Export the JRSResume function/ctor.
|
/** Get the default (empty) sheet. */
|
||||||
*/
|
JRSResume.default = () => new JRSResume().parseJSON(require('fresh-resume-starter').jrs);
|
||||||
module.exports = JRSResume;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
/**
|
||||||
|
Convert this object to a JSON string, sanitizing meta-properties along the
|
||||||
|
way. Don't override .toString().
|
||||||
|
*/
|
||||||
|
JRSResume.stringify = function( obj ) {
|
||||||
|
const replacer = function( key,value ) { // Exclude these keys from stringification
|
||||||
|
const temp = _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
||||||
|
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
||||||
|
'isModified', 'htmlPreview', 'display_progress_bar'],
|
||||||
|
val => key.trim() === val);
|
||||||
|
if (temp) { return undefined; } else { return value; }
|
||||||
|
};
|
||||||
|
return JSON.stringify(obj, replacer, 2);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert human-friendly dates into formal Moment.js dates for all collections.
|
||||||
|
We don't want to lose the raw textual date as entered by the user, so we store
|
||||||
|
the Moment-ified date as a separate property with a prefix of .safe. For ex:
|
||||||
|
job.startDate is the date as entered by the user. job.safeStartDate is the
|
||||||
|
parsed Moment.js date that we actually use in processing.
|
||||||
|
*/
|
||||||
|
var _parseDates = function() {
|
||||||
|
|
||||||
|
const _fmt = require('./fluent-date').fmt;
|
||||||
|
|
||||||
|
this.work && this.work.forEach(function(job) {
|
||||||
|
job.safeStartDate = _fmt( job.startDate );
|
||||||
|
return job.safeEndDate = _fmt( job.endDate );
|
||||||
|
});
|
||||||
|
this.education && this.education.forEach(function(edu) {
|
||||||
|
edu.safeStartDate = _fmt( edu.startDate );
|
||||||
|
return edu.safeEndDate = _fmt( edu.endDate );
|
||||||
|
});
|
||||||
|
this.volunteer && this.volunteer.forEach(function(vol) {
|
||||||
|
vol.safeStartDate = _fmt( vol.startDate );
|
||||||
|
return vol.safeEndDate = _fmt( vol.endDate );
|
||||||
|
});
|
||||||
|
this.awards && this.awards.forEach(awd => awd.safeDate = _fmt( awd.date ));
|
||||||
|
return this.publications && this.publications.forEach(pub => pub.safeReleaseDate = _fmt( pub.releaseDate ));
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Export the JRSResume class.
|
||||||
|
*/
|
||||||
|
module.exports = JRSResume;
|
||||||
|
@ -1,60 +1,79 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the JRSTheme class.
|
Definition of the JRSTheme class.
|
||||||
@module jrs-theme.js
|
@module core/jrs-theme
|
||||||
@license MIT. See LICENSE.MD for details.
|
@license MIT. See LICENSE.MD for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
|
const _ = require('underscore');
|
||||||
|
const PATH = require('path');
|
||||||
|
const pathExists = require('path-exists').sync;
|
||||||
|
const errors = require('./status-codes');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore')
|
/**
|
||||||
, PATH = require('path')
|
The JRSTheme class is a representation of a JSON Resume theme asset.
|
||||||
, parsePath = require('parse-filepath')
|
@class JRSTheme
|
||||||
, pathExists = require('path-exists').sync;
|
*/
|
||||||
|
class JRSTheme {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The JRSTheme class is a representation of a JSON Resume
|
Open and parse the specified JRS theme.
|
||||||
theme asset. See also: FRESHTheme.
|
|
||||||
@class JRSTheme
|
|
||||||
*/
|
|
||||||
function JRSTheme() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Open and parse the specified theme.
|
|
||||||
@method open
|
@method open
|
||||||
*/
|
*/
|
||||||
JRSTheme.prototype.open = function( thFolder ) {
|
open( thFolder ) {
|
||||||
|
|
||||||
this.folder = thFolder;
|
this.folder = thFolder;
|
||||||
|
//const pathInfo = parsePath(thFolder);
|
||||||
|
|
||||||
// Open the [theme-name].json file; should have the same
|
// Open and parse the theme's package.json file
|
||||||
// name as folder
|
const pkgJsonPath = PATH.join(thFolder, 'package.json');
|
||||||
var pathInfo = parsePath( thFolder );
|
if (pathExists(pkgJsonPath)) {
|
||||||
|
const thApi = require(thFolder); // Requiring the folder yields whatever the package.json's "main" is set to
|
||||||
// Open and parse the theme's package.json file.
|
const thPkg = require(pkgJsonPath); // Get the package.json as JSON
|
||||||
var pkgJsonPath = PATH.join( thFolder, 'package.json' );
|
|
||||||
if( pathExists( pkgJsonPath )) {
|
|
||||||
var thApi = require( thFolder )
|
|
||||||
, thPkg = require( pkgJsonPath );
|
|
||||||
this.name = thPkg.name;
|
this.name = thPkg.name;
|
||||||
this.render = (thApi && thApi.render) || undefined;
|
this.render = (thApi && thApi.render) || undefined;
|
||||||
this.formats = {
|
this.engine = 'jrs';
|
||||||
html: { title:'html', outFormat:'html', ext:'html' }
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw { fluenterror: 10 };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Create theme formats (HTML and PDF). Just add the bare minimum mix of
|
||||||
|
// properties necessary to allow JSON Resume themes to share a rendering
|
||||||
|
// path with FRESH themes.
|
||||||
|
this.formats = {
|
||||||
|
html: {
|
||||||
|
outFormat: 'html',
|
||||||
|
files: [{
|
||||||
|
action: 'transform',
|
||||||
|
render: this.render,
|
||||||
|
primary: true,
|
||||||
|
ext: 'html',
|
||||||
|
css: null
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
pdf: {
|
||||||
|
outFormat: 'pdf',
|
||||||
|
files: [{
|
||||||
|
action: 'transform',
|
||||||
|
render: this.render,
|
||||||
|
primary: true,
|
||||||
|
ext: 'pdf',
|
||||||
|
css: null
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
throw {fluenterror: errors.missingPackageJSON};
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -62,9 +81,7 @@ Definition of the JRSTheme class.
|
|||||||
Determine if the theme supports the output format.
|
Determine if the theme supports the output format.
|
||||||
@method hasFormat
|
@method hasFormat
|
||||||
*/
|
*/
|
||||||
JRSTheme.prototype.hasFormat = function( fmt ) {
|
hasFormat( fmt ) { return _.has(this.formats, fmt); }
|
||||||
return _.has( this.formats, fmt );
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -72,14 +89,8 @@ Definition of the JRSTheme class.
|
|||||||
Return the requested output format.
|
Return the requested output format.
|
||||||
@method getFormat
|
@method getFormat
|
||||||
*/
|
*/
|
||||||
JRSTheme.prototype.getFormat = function( fmt ) {
|
getFormat( fmt ) { return this.formats[ fmt ]; }
|
||||||
return this.formats[ fmt ];
|
}
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = JRSTheme;
|
||||||
module.exports = JRSTheme;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
@ -1,131 +1,127 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the ResumeFactory class.
|
Definition of the ResumeFactory class.
|
||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module resume-factory.js
|
@module core/resume-factory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function(){
|
const FS = require('fs');
|
||||||
|
const HMS = require('./status-codes');
|
||||||
|
const HME = require('./event-codes');
|
||||||
|
const ResumeConverter = require('fresh-jrs-converter');
|
||||||
|
const resumeDetect = require('../utils/resume-detector');
|
||||||
|
require('string.prototype.startswith');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
require('string.prototype.startswith');
|
/**
|
||||||
var FS = require('fs');
|
A simple factory class for FRESH and JSON Resumes.
|
||||||
var ResumeConverter = require('./convert');
|
@class ResumeFactory
|
||||||
var chalk = require('chalk');
|
*/
|
||||||
var SyntaxErrorEx = require('../utils/syntax-error-ex');
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A simple factory class for FRESH and JSON Resumes.
|
Load one or more resumes from disk.
|
||||||
@class ResumeFactory
|
|
||||||
|
@param {Object} opts An options object with settings for the factory as well
|
||||||
|
as passthrough settings for FRESHResume or JRSResume. Structure:
|
||||||
|
|
||||||
|
{
|
||||||
|
format: 'FRESH', // Format to open as. ('FRESH', 'JRS', null)
|
||||||
|
objectify: true, // FRESH/JRSResume or raw JSON?
|
||||||
|
inner: { // Passthru options for FRESH/JRSResume
|
||||||
|
sort: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
*/
|
*/
|
||||||
var ResumeFactory = module.exports = {
|
load( sources, opts, emitter ) {
|
||||||
|
return sources.map( function(src) {
|
||||||
|
return this.loadOne( src, opts, emitter );
|
||||||
|
|
||||||
/**
|
|
||||||
Load one or more resumes from disk.
|
|
||||||
*/
|
|
||||||
load: function ( sources, opts ) {
|
|
||||||
|
|
||||||
// Loop over all inputs, parsing each to JSON and then to a FRESHResume
|
|
||||||
// or JRSResume object.
|
|
||||||
var that = this;
|
|
||||||
return sources.map( function( src ) {
|
|
||||||
return that.loadOne( src, opts );
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Load a single resume from disk.
|
|
||||||
*/
|
|
||||||
loadOne: function( src, opts ) {
|
|
||||||
|
|
||||||
var log = opts.log;
|
|
||||||
var toFormat = opts.format;
|
|
||||||
var objectify = opts.objectify;
|
|
||||||
|
|
||||||
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
|
||||||
toFormat && (toFormat = toFormat.toLowerCase().trim());
|
|
||||||
|
|
||||||
// Load and parse the resume JSON
|
|
||||||
var info = _parse( src, opts );
|
|
||||||
if( info.error ) return info;
|
|
||||||
|
|
||||||
// Determine the resume format: FRESH or JRS
|
|
||||||
var json = info.json;
|
|
||||||
var orgFormat = ( json.meta && json.meta.format &&
|
|
||||||
json.meta.format.startsWith('FRESH@') ) ?
|
|
||||||
'fresh' : 'jrs';
|
|
||||||
|
|
||||||
// Convert between formats if necessary
|
|
||||||
if( toFormat && (orgFormat !== toFormat) ) {
|
|
||||||
json = ResumeConverter[ 'to' + toFormat.toUpperCase() ]( json );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Objectify the resume, that is, convert it from JSON to a FRESHResume
|
|
||||||
// or JRSResume object.
|
|
||||||
var rez;
|
|
||||||
if( objectify ) {
|
|
||||||
var ResumeClass = require('../core/' + (toFormat || orgFormat) + '-resume');
|
|
||||||
rez = new ResumeClass().parseJSON( json );
|
|
||||||
rez.i().file = src;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
file: src,
|
|
||||||
json: info.json,
|
|
||||||
rez: rez
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
};
|
, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/** Load a single resume from disk. */
|
||||||
|
loadOne( src, opts, emitter ) {
|
||||||
|
|
||||||
function _parse( fileName, opts ) {
|
let toFormat = opts.format; // Can be null
|
||||||
var rawData;
|
|
||||||
try {
|
|
||||||
|
|
||||||
// TODO: Core should not log
|
// Get the destination format. Can be 'fresh', 'jrs', or null/undefined.
|
||||||
opts.log( chalk.cyan('Reading resume: ') + chalk.cyan.bold(fileName) );
|
toFormat && (toFormat = toFormat.toLowerCase().trim());
|
||||||
|
|
||||||
// Read the file
|
// Load and parse the resume JSON
|
||||||
rawData = FS.readFileSync( fileName, 'utf8' );
|
const info = _parse(src, opts, emitter);
|
||||||
|
if (info.fluenterror) { return info; }
|
||||||
// Parse it to JSON
|
|
||||||
return {
|
|
||||||
json: JSON.parse( rawData )
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Determine the resume format: FRESH or JRS
|
||||||
|
let { json } = info;
|
||||||
|
const orgFormat = resumeDetect(json);
|
||||||
|
if (orgFormat === 'unk') {
|
||||||
|
info.fluenterror = HMS.unknownSchema;
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
catch( ex ) {
|
|
||||||
|
|
||||||
// JSON.parse failed due to invalid JSON
|
|
||||||
if ( !opts.muffle && ex instanceof SyntaxError) {
|
|
||||||
var info = new SyntaxErrorEx( ex, rawData );
|
|
||||||
opts.log( chalk.red.bold(fileName.toUpperCase() + ' contains invalid JSON on line ' +
|
|
||||||
info.line + ' column ' + info.col + '.' +
|
|
||||||
chalk.red(' Unable to validate.')));
|
|
||||||
opts.log( chalk.red.bold('INTERNAL: ' + ex) );
|
|
||||||
ex.handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( opts.throw ) throw ex;
|
|
||||||
else return {
|
|
||||||
error: ex,
|
|
||||||
raw: rawData,
|
|
||||||
file: fileName
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// Convert between formats if necessary
|
||||||
|
if (toFormat && ( orgFormat !== toFormat )) {
|
||||||
|
json = ResumeConverter[ `to${toFormat.toUpperCase()}` ](json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Objectify the resume, that is, convert it from JSON to a FRESHResume
|
||||||
|
// or JRSResume object.
|
||||||
|
let rez = null;
|
||||||
|
if (opts.objectify) {
|
||||||
|
const reqLib = `../core/${toFormat || orgFormat}-resume`;
|
||||||
|
const ResumeClass = require(reqLib);
|
||||||
|
rez = new ResumeClass().parseJSON( json, opts.inner );
|
||||||
|
rez.i().file = src;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
file: src,
|
||||||
|
json: info.json,
|
||||||
|
rez
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var _parse = function( fileName, opts, eve ) {
|
||||||
|
|
||||||
}());
|
let rawData = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Read the file
|
||||||
|
eve && eve.stat( HME.beforeRead, { file: fileName });
|
||||||
|
rawData = FS.readFileSync( fileName, 'utf8' );
|
||||||
|
eve && eve.stat( HME.afterRead, { file: fileName, data: rawData });
|
||||||
|
|
||||||
|
// Parse the file
|
||||||
|
eve && eve.stat(HME.beforeParse, { data: rawData });
|
||||||
|
const ret = { json: JSON.parse( rawData ) };
|
||||||
|
const orgFormat =
|
||||||
|
ret.json.meta && ret.json.meta.format && ret.json.meta.format.startsWith('FRESH@')
|
||||||
|
? 'fresh' : 'jrs';
|
||||||
|
|
||||||
|
eve && eve.stat(HME.afterParse, { file: fileName, data: ret.json, fmt: orgFormat });
|
||||||
|
return ret;
|
||||||
|
} catch (err) {
|
||||||
|
// Can be ENOENT, EACCES, SyntaxError, etc.
|
||||||
|
return {
|
||||||
|
fluenterror: rawData ? HMS.parseError : HMS.readError,
|
||||||
|
inner: err,
|
||||||
|
raw: rawData,
|
||||||
|
file: fileName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/**
|
|
||||||
@module spawn-watch.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
// Catch various out-of-band child process errors such as ENOENT for PDFs
|
|
||||||
// http://stackoverflow.com/q/27688804
|
|
||||||
var SpawnWatcher = module.exports = function() {
|
|
||||||
var childProcess = require("child_process");
|
|
||||||
var oldSpawn = childProcess.spawn;
|
|
||||||
childProcess.spawn = function() {
|
|
||||||
return oldSpawn.apply(this, arguments)
|
|
||||||
.on('error', function(err) {
|
|
||||||
require('./error-handler').err( err, false );
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}();
|
|
||||||
|
|
||||||
//SpawnWatcher();
|
|
||||||
|
|
||||||
}());
|
|
@ -1,24 +1,41 @@
|
|||||||
/**
|
/**
|
||||||
Status codes for HackMyResume.
|
Status codes for HackMyResume.
|
||||||
@module status-codes.js
|
@module core/status-codes
|
||||||
@license MIT. See LICENSE.MD for details.
|
@license MIT. See LICENSE.MD for details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
success: 0,
|
success: 0,
|
||||||
themeNotFound: 1,
|
themeNotFound: 1,
|
||||||
copyCss: 2,
|
copyCss: 2,
|
||||||
resumeNotFound: 3,
|
resumeNotFound: 3,
|
||||||
missingCommand: 4,
|
missingCommand: 4,
|
||||||
invalidCommand: 5,
|
invalidCommand: 5,
|
||||||
resumeNotFoundAlt: 6,
|
resumeNotFoundAlt: 6,
|
||||||
inputOutputParity: 7,
|
inputOutputParity: 7,
|
||||||
createNameMissing: 8,
|
createNameMissing: 8,
|
||||||
wkhtmltopdf: 9,
|
pdfGeneration: 9,
|
||||||
missingPackageJSON: 10,
|
missingPackageJSON: 10,
|
||||||
invalid: 11
|
invalid: 11,
|
||||||
};
|
invalidFormat: 12,
|
||||||
|
notOnPath: 13,
|
||||||
}());
|
readError: 14,
|
||||||
|
parseError: 15,
|
||||||
|
fileSaveError: 16,
|
||||||
|
generateError: 17,
|
||||||
|
invalidHelperUse: 18,
|
||||||
|
mixedMerge: 19,
|
||||||
|
invokeTemplate: 20,
|
||||||
|
compileTemplate: 21,
|
||||||
|
themeLoad: 22,
|
||||||
|
invalidParamCount: 23,
|
||||||
|
missingParam: 24,
|
||||||
|
createError: 25,
|
||||||
|
validateError: 26,
|
||||||
|
invalidOptionsFile: 27,
|
||||||
|
optionsFileNotFound: 28,
|
||||||
|
unknownSchema: 29,
|
||||||
|
themeHelperLoad: 30,
|
||||||
|
invalidSchemaVersion: 31
|
||||||
|
};
|
||||||
|
@ -1,290 +0,0 @@
|
|||||||
/**
|
|
||||||
Generic template helper definitions for HackMyResume / FluentCV.
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
@module generic-helpers.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var MD = require('marked')
|
|
||||||
, H2W = require('../utils/html-to-wpml')
|
|
||||||
, XML = require('xml-escape')
|
|
||||||
, moment = require('moment')
|
|
||||||
, LO = require('lodash')
|
|
||||||
, _ = require('underscore')
|
|
||||||
, unused = require('../utils/string');
|
|
||||||
|
|
||||||
/**
|
|
||||||
Generic template helper function definitions.
|
|
||||||
@class GenericHelpers
|
|
||||||
*/
|
|
||||||
var GenericHelpers = module.exports = {
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert the input date to a specified format through Moment.js.
|
|
||||||
If date is invalid, will return the time provided by the user,
|
|
||||||
or default to the fallback param or 'Present' if that is set to true
|
|
||||||
@method formatDate
|
|
||||||
*/
|
|
||||||
formatDate: function(datetime, format, fallback) {
|
|
||||||
if (moment) {
|
|
||||||
var momentDate = moment( datetime );
|
|
||||||
if (momentDate.isValid()) return momentDate.format(format);
|
|
||||||
}
|
|
||||||
|
|
||||||
return datetime || (typeof fallback == 'string' ? fallback : (fallback === true ? 'Present' : null));
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Format a from/to date range.
|
|
||||||
@method dateRange
|
|
||||||
*/
|
|
||||||
dateRange: function( obj, fmt, sep, options ) {
|
|
||||||
fmt = (fmt && String.is(fmt) && fmt) || 'YYYY-MM';
|
|
||||||
sep = (sep && String.is(sep) && sep) || ' — ';
|
|
||||||
if( obj.safe ) {
|
|
||||||
var dateA = (obj.safe.start && obj.safe.start.format(fmt)) || '';
|
|
||||||
var dateB = (obj.safe.end && obj.safe.end.format(fmt)) || '';
|
|
||||||
if( obj.safe.start && obj.safe.end ) {
|
|
||||||
return dateA + sep + dateB ;
|
|
||||||
}
|
|
||||||
else if( obj.safe.start || obj.safe.end ) {
|
|
||||||
return dateA || dateB;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return true if the section is present on the resume and has at least one
|
|
||||||
element.
|
|
||||||
@method section
|
|
||||||
*/
|
|
||||||
section: function( title, options ) {
|
|
||||||
title = title.trim().toLowerCase();
|
|
||||||
var obj = LO.get( this.r, title );
|
|
||||||
if( _.isArray( obj ) ) {
|
|
||||||
return obj.length ? options.fn(this) : undefined;
|
|
||||||
}
|
|
||||||
else if( _.isObject( obj )) {
|
|
||||||
return ( (obj.history && obj.history.length) ||
|
|
||||||
( obj.sets && obj.sets.length ) ) ?
|
|
||||||
options.fn(this) : undefined;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Capitalize the first letter of the word.
|
|
||||||
@method section
|
|
||||||
*/
|
|
||||||
camelCase: function(val) {
|
|
||||||
val = (val && val.trim()) || '';
|
|
||||||
return val ? (val.charAt(0).toUpperCase() + val.slice(1)) : val;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return true if the context has the property or subpropery.
|
|
||||||
@method has
|
|
||||||
*/
|
|
||||||
has: function( title, options ) {
|
|
||||||
title = title && title.trim().toLowerCase();
|
|
||||||
if( LO.get( this.r, title ) ) {
|
|
||||||
return options.fn(this);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Generic template helper function to display a user-overridable section
|
|
||||||
title for a FRESH resume theme. Use this in lieue of hard-coding section
|
|
||||||
titles.
|
|
||||||
|
|
||||||
Usage:
|
|
||||||
|
|
||||||
{{sectionTitle "sectionName"}}
|
|
||||||
{{sectionTitle "sectionName" "sectionTitle"}}
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
{{sectionTitle "Education"}}
|
|
||||||
{{sectionTitle "Employment" "Project History"}}
|
|
||||||
|
|
||||||
@param sect_name The name of the section being title. Must be one of the
|
|
||||||
top-level FRESH resume sections ("info", "education", "employment", etc.).
|
|
||||||
@param sect_title The theme-specified section title. May be replaced by the
|
|
||||||
user.
|
|
||||||
@method sectionTitle
|
|
||||||
*/
|
|
||||||
sectionTitle: function( sname, stitle ) {
|
|
||||||
|
|
||||||
// If not provided by the user, stitle should default to sname. ps.
|
|
||||||
// Handlebars silently passes in the options object to the last param,
|
|
||||||
// where in Underscore stitle will be null/undefined, so we check both.
|
|
||||||
stitle = (stitle && String.is(stitle) && stitle) || sname;
|
|
||||||
|
|
||||||
// If there's a section title override, use it.
|
|
||||||
return ( this.opts.stitles &&
|
|
||||||
this.opts.stitles[ sname.toLowerCase().trim() ] ) ||
|
|
||||||
stitle;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert inline Markdown to inline WordProcessingML.
|
|
||||||
@method wpml
|
|
||||||
*/
|
|
||||||
wpml: function( txt, inline ) {
|
|
||||||
if(!txt) return '';
|
|
||||||
inline = (inline && !inline.hash) || false;
|
|
||||||
txt = XML(txt.trim());
|
|
||||||
txt = inline ?
|
|
||||||
MD(txt).replace(/^\s*<p>|<\/p>\s*$/gi, '') :
|
|
||||||
MD(txt);
|
|
||||||
txt = H2W( txt );
|
|
||||||
return txt;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Emit a conditional link.
|
|
||||||
@method link
|
|
||||||
*/
|
|
||||||
link: function( text, url ) {
|
|
||||||
return url && url.trim() ?
|
|
||||||
('<a href="' + url + '">' + text + '</a>') : text;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return the last word of the specified text.
|
|
||||||
@method lastWord
|
|
||||||
*/
|
|
||||||
lastWord: function( txt ) {
|
|
||||||
return txt && txt.trim() ? _.last( txt.split(' ') ) : '';
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert a skill level to an RGB color triplet. TODO: refactor
|
|
||||||
@method skillColor
|
|
||||||
@param lvl Input skill level. Skill level can be expressed as a string
|
|
||||||
("beginner", "intermediate", etc.), as an integer (1,5,etc), as a string
|
|
||||||
integer ("1", "5", etc.), or as an RRGGBB color triplet ('#C00000',
|
|
||||||
'#FFFFAA').
|
|
||||||
*/
|
|
||||||
skillColor: function( lvl ) {
|
|
||||||
var idx = skillLevelToIndex( lvl );
|
|
||||||
var skillColors = (this.theme && this.theme.palette &&
|
|
||||||
this.theme.palette.skillLevels) ||
|
|
||||||
[ '#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000' ];
|
|
||||||
return skillColors[idx];
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return an appropriate height. TODO: refactor
|
|
||||||
@method lastWord
|
|
||||||
*/
|
|
||||||
skillHeight: function( lvl ) {
|
|
||||||
var idx = skillLevelToIndex( lvl );
|
|
||||||
return ['38.25', '30', '16', '8', '0'][idx];
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return all but the last word of the input text.
|
|
||||||
@method initialWords
|
|
||||||
*/
|
|
||||||
initialWords: function( txt ) {
|
|
||||||
return txt && txt.trim() ? _.initial( txt.split(' ') ).join(' ') : '';
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Trim the protocol (http or https) from a URL/
|
|
||||||
@method trimURL
|
|
||||||
*/
|
|
||||||
trimURL: function( url ) {
|
|
||||||
return url && url.trim() ? url.trim().replace(/^https?:\/\//i, '') : '';
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Convert text to lowercase.
|
|
||||||
@method toLower
|
|
||||||
*/
|
|
||||||
toLower: function( txt ) {
|
|
||||||
return txt && txt.trim() ? txt.toLowerCase() : '';
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Return true if either value is truthy.
|
|
||||||
@method either
|
|
||||||
*/
|
|
||||||
either: function( lhs, rhs, options ) {
|
|
||||||
if (lhs || rhs) return options.fn(this);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Conditional stylesheet link. Either display the link or embed the stylesheet
|
|
||||||
via <style></style> tag.
|
|
||||||
*/
|
|
||||||
styleSheet: function( file, options ) {
|
|
||||||
var styles = ( this.opts.css === 'link') ?
|
|
||||||
'<link href="' + file + '" rel="stylesheet" type="text/css">' :
|
|
||||||
'<style>' + this.cssInfo.data + '</style>';
|
|
||||||
if( this.opts.themeObj.inherits &&
|
|
||||||
this.opts.themeObj.inherits.html &&
|
|
||||||
this.format === 'html' ) {
|
|
||||||
styles += (this.opts.css === 'link') ?
|
|
||||||
'<link href="' + this.opts.themeObj.overrides.path + '" rel="stylesheet" type="text/css">' :
|
|
||||||
'<style>' + this.opts.themeObj.overrides.data + '</style>';
|
|
||||||
}
|
|
||||||
return styles;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Perform a generic comparison.
|
|
||||||
See: http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates
|
|
||||||
@method compare
|
|
||||||
*/
|
|
||||||
compare: function(lvalue, rvalue, options) {
|
|
||||||
if (arguments.length < 3)
|
|
||||||
throw new Error("Handlerbars Helper 'compare' needs 2 parameters");
|
|
||||||
var operator = options.hash.operator || "==";
|
|
||||||
var operators = {
|
|
||||||
'==': function(l,r) { return l == r; },
|
|
||||||
'===': function(l,r) { return l === r; },
|
|
||||||
'!=': function(l,r) { return l != r; },
|
|
||||||
'<': function(l,r) { return l < r; },
|
|
||||||
'>': function(l,r) { return l > r; },
|
|
||||||
'<=': function(l,r) { return l <= r; },
|
|
||||||
'>=': function(l,r) { return l >= r; },
|
|
||||||
'typeof': function(l,r) { return typeof l == r; }
|
|
||||||
};
|
|
||||||
if (!operators[operator])
|
|
||||||
throw new Error("Handlerbars Helper 'compare' doesn't know the operator "+operator);
|
|
||||||
var result = operators[operator](lvalue,rvalue);
|
|
||||||
return result ? options.fn(this) : options.inverse(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
function skillLevelToIndex( lvl ) {
|
|
||||||
var idx = 0;
|
|
||||||
if( String.is( lvl ) ) {
|
|
||||||
lvl = lvl.trim().toLowerCase();
|
|
||||||
var intVal = parseInt( lvl );
|
|
||||||
if( isNaN( intVal ) ) {
|
|
||||||
switch( lvl ) {
|
|
||||||
case 'beginner': idx = 1; break;
|
|
||||||
case 'intermediate': idx = 2; break;
|
|
||||||
case 'advanced': idx = 3; break;
|
|
||||||
case 'master': idx = 4; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idx = Math.min( intVal / 2, 4 );
|
|
||||||
idx = Math.max( 0, idx );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
idx = Math.min( lvl / 2, 4 );
|
|
||||||
idx = Math.max( 0, idx );
|
|
||||||
}
|
|
||||||
return idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
}());
|
|
@ -1,99 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the HandlebarsGenerator class.
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
@module handlebars-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore')
|
|
||||||
, HANDLEBARS = require('handlebars')
|
|
||||||
, FS = require('fs')
|
|
||||||
, registerHelpers = require('./handlebars-helpers')
|
|
||||||
, PATH = require('path')
|
|
||||||
, parsePath = require('parse-filepath')
|
|
||||||
, READFILES = require('recursive-readdir-sync')
|
|
||||||
, SLASH = require('slash');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Perform template-based resume generation using Handlebars.js.
|
|
||||||
@class HandlebarsGenerator
|
|
||||||
*/
|
|
||||||
var HandlebarsGenerator = module.exports = {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
generate: function( json, jst, format, cssInfo, opts, theme ) {
|
|
||||||
|
|
||||||
registerPartials( format, theme );
|
|
||||||
registerHelpers( theme );
|
|
||||||
|
|
||||||
// Preprocess text
|
|
||||||
var encData = json;
|
|
||||||
( format === 'html' || format === 'pdf' ) && (encData = json.markdownify());
|
|
||||||
( format === 'doc' ) && (encData = json.xmlify());
|
|
||||||
|
|
||||||
// Compile and run the Handlebars template.
|
|
||||||
var template = HANDLEBARS.compile(jst);
|
|
||||||
return template({
|
|
||||||
r: encData,
|
|
||||||
RAW: json,
|
|
||||||
filt: opts.filters,
|
|
||||||
cssInfo: cssInfo,
|
|
||||||
format: format,
|
|
||||||
opts: opts,
|
|
||||||
headFragment: opts.headFragment || ''
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function registerPartials(format, theme) {
|
|
||||||
if( format !== 'html' && format != 'doc' )
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Locate the global partials folder
|
|
||||||
var partialsFolder = PATH.join(
|
|
||||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
|
||||||
'/partials/',
|
|
||||||
format
|
|
||||||
);
|
|
||||||
|
|
||||||
// Register global partials in the /partials folder
|
|
||||||
// TODO: Only do this once per HMR invocation.
|
|
||||||
_.each( READFILES( partialsFolder, function(error){ }), function( el ) {
|
|
||||||
var pathInfo = parsePath( el );
|
|
||||||
var name = SLASH( PATH.relative( partialsFolder, el )
|
|
||||||
.replace(/\.html$|\.xml$/, '') );
|
|
||||||
if( pathInfo.dirname.endsWith('section') ) {
|
|
||||||
name = SLASH(name.replace(/\.html$|\.xml$/, ''));
|
|
||||||
}
|
|
||||||
var tplData = FS.readFileSync( el, 'utf8' );
|
|
||||||
var compiledTemplate = HANDLEBARS.compile( tplData );
|
|
||||||
HANDLEBARS.registerPartial( name, compiledTemplate );
|
|
||||||
theme.partialsInitialized = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register theme-specific partials
|
|
||||||
_.each( theme.partials, function( el ) {
|
|
||||||
var tplData = FS.readFileSync( el.path, 'utf8' );
|
|
||||||
var compiledTemplate = HANDLEBARS.compile( tplData );
|
|
||||||
HANDLEBARS.registerPartial( el.name, compiledTemplate );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
Template helper definitions for Handlebars.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module handlebars-helpers.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var HANDLEBARS = require('handlebars')
|
|
||||||
, _ = require('underscore')
|
|
||||||
, helpers = require('./generic-helpers');
|
|
||||||
|
|
||||||
/**
|
|
||||||
Register useful Handlebars helpers.
|
|
||||||
@method registerHelpers
|
|
||||||
*/
|
|
||||||
module.exports = function( theme ) {
|
|
||||||
|
|
||||||
helpers.theme = theme;
|
|
||||||
HANDLEBARS.registerHelper( helpers );
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the UnderscoreGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module underscore-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Perform template-based resume generation using Underscore.js.
|
|
||||||
@class UnderscoreGenerator
|
|
||||||
*/
|
|
||||||
var UnderscoreGenerator = module.exports = {
|
|
||||||
|
|
||||||
generate: function( json, jst, format, cssInfo, opts, theme ) {
|
|
||||||
|
|
||||||
// Tweak underscore's default template delimeters
|
|
||||||
var delims = (opts.themeObj && opts.themeObj.delimeters) || opts.template;
|
|
||||||
if( opts.themeObj && opts.themeObj.delimeters ) {
|
|
||||||
delims = _.mapObject( delims, function(val,key) {
|
|
||||||
return new RegExp( val, "ig");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
_.templateSettings = delims;
|
|
||||||
|
|
||||||
// Strip {# comments #}
|
|
||||||
jst = jst.replace( delims.comment, '');
|
|
||||||
|
|
||||||
var helpers = require('./generic-helpers');
|
|
||||||
helpers.opts = opts;
|
|
||||||
helpers.cssInfo = cssInfo;
|
|
||||||
|
|
||||||
// Compile and run the template. TODO: avoid unnecessary recompiles.
|
|
||||||
var compiled = _.template(jst);
|
|
||||||
var ret = compiled({
|
|
||||||
r: format === 'html' || format === 'pdf' || format === 'png' ? json.markdownify() : json,
|
|
||||||
filt: opts.filters,
|
|
||||||
XML: require('xml-escape'),
|
|
||||||
RAW: json,
|
|
||||||
cssInfo: cssInfo,
|
|
||||||
headFragment: opts.headFragment || '',
|
|
||||||
opts: opts,
|
|
||||||
h: helpers
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the BaseGenerator class.
|
|
||||||
@module base-generator.js
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
// Use J. Resig's nifty class implementation
|
|
||||||
var Class = require( '../utils/class' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
The BaseGenerator class is the root of the generator hierarchy. Functionality
|
|
||||||
common to ALL generators lives here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var BaseGenerator = module.exports = Class.extend({
|
|
||||||
|
|
||||||
/**
|
|
||||||
Base-class initialize.
|
|
||||||
*/
|
|
||||||
init: function( outputFormat ) {
|
|
||||||
this.format = outputFormat;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Status codes.
|
|
||||||
*/
|
|
||||||
codes: require('../core/status-codes'),
|
|
||||||
|
|
||||||
/**
|
|
||||||
Generator options.
|
|
||||||
*/
|
|
||||||
opts: {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}());
|
|
@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the HTMLGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module html-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator')
|
|
||||||
, FS = require('fs-extra')
|
|
||||||
, HTML = require( 'html' )
|
|
||||||
, PATH = require('path');
|
|
||||||
|
|
||||||
var HtmlGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this._super( 'html' );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Copy satellite CSS files to the destination and optionally pretty-print
|
|
||||||
the HTML resume prior to saving.
|
|
||||||
*/
|
|
||||||
onBeforeSave: function( info ) {
|
|
||||||
return this.opts.prettify ?
|
|
||||||
HTML.prettyPrint( info.mk, this.opts.prettify ) : info.mk;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
|
@ -1,81 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the HtmlPdfGenerator class.
|
|
||||||
@module html-pdf-generator.js
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator')
|
|
||||||
, FS = require('fs-extra')
|
|
||||||
, HTML = require( 'html' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
An HTML-driven PDF resume generator for HackMyResume.
|
|
||||||
*/
|
|
||||||
var HtmlPdfGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this._super( 'pdf', 'html' );
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Generate the binary PDF.
|
|
||||||
*/
|
|
||||||
onBeforeSave: function( info ) {
|
|
||||||
engines[ info.opts.pdf || 'wkhtmltopdf' ]
|
|
||||||
.call( this, info.mk, info.outputFile );
|
|
||||||
return null; // halt further processing
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var engines = {
|
|
||||||
/**
|
|
||||||
Generate a PDF from HTML using wkhtmltopdf.
|
|
||||||
*/
|
|
||||||
wkhtmltopdf: function(markup, fOut) {
|
|
||||||
var wk;
|
|
||||||
try {
|
|
||||||
wk = require('wkhtmltopdf');
|
|
||||||
wk( markup, { pageSize: 'letter' } )
|
|
||||||
.pipe( FS.createWriteStream( fOut ) );
|
|
||||||
}
|
|
||||||
catch(ex) {
|
|
||||||
// { [Error: write EPIPE] code: 'EPIPE', errno: 'EPIPE', ... }
|
|
||||||
// { [Error: ENOENT] }
|
|
||||||
throw { fluenterror: this.codes.wkhtmltopdf };
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
Generate a PDF from HTML using Phantom.
|
|
||||||
*/
|
|
||||||
phantom: function( markup, fOut ) {
|
|
||||||
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 );
|
|
||||||
ph.exit();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{ dnodeOpts: { weak: false } } );
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
@ -1,47 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the HtmlPngGenerator class.
|
|
||||||
@license MIT. See LICENSE.MD for details.
|
|
||||||
@module html-png-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator')
|
|
||||||
, FS = require('fs-extra')
|
|
||||||
, HTML = require( 'html' );
|
|
||||||
|
|
||||||
/**
|
|
||||||
An HTML-based PNG resume generator for HackMyResume.
|
|
||||||
*/
|
|
||||||
var HtmlPngGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this._super( 'png', 'html' );
|
|
||||||
},
|
|
||||||
|
|
||||||
invoke: function( rez, themeMarkup, cssInfo, opts ) {
|
|
||||||
//return YAML.stringify( JSON.parse( rez.stringify() ), Infinity, 2 );
|
|
||||||
},
|
|
||||||
|
|
||||||
generate: function( rez, f, opts ) {
|
|
||||||
var htmlResults = opts.targets.filter(function(t){
|
|
||||||
return t.fmt.outFormat === 'html';
|
|
||||||
});
|
|
||||||
var htmlFile = htmlResults[0].final.files.filter(function(fl){
|
|
||||||
return fl.info.ext === 'html';
|
|
||||||
});
|
|
||||||
png(htmlFile[0].data, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
Generate a PNG from HTML.
|
|
||||||
*/
|
|
||||||
function png( markup, fOut ) {
|
|
||||||
// require('webshot')( markup , { encoding: 'binary', siteType: 'html' } )
|
|
||||||
// .pipe( FS.createWriteStream( fOut ) );
|
|
||||||
require('webshot')( markup , fOut, { siteType: 'html' }, function(err) { } );
|
|
||||||
}
|
|
||||||
|
|
||||||
}());
|
|
@ -1,36 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the JsonGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module json-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
var BaseGenerator = require('./base-generator');
|
|
||||||
var FS = require('fs');
|
|
||||||
var _ = require('underscore');
|
|
||||||
|
|
||||||
/**
|
|
||||||
The JsonGenerator generates a JSON resume directly.
|
|
||||||
*/
|
|
||||||
var JsonGenerator = module.exports = BaseGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'json' );
|
|
||||||
},
|
|
||||||
|
|
||||||
invoke: function( rez ) {
|
|
||||||
// TODO: merge with FCVD
|
|
||||||
function replacer( key,value ) { // Exclude these keys from stringification
|
|
||||||
return _.some(['imp', 'warnings', 'computed', 'filt', 'ctrl', 'index',
|
|
||||||
'safeStartDate', 'safeEndDate', 'safeDate', 'safeReleaseDate', 'result',
|
|
||||||
'isModified', 'htmlPreview', 'safe' ],
|
|
||||||
function( val ) { return key.trim() === val; }
|
|
||||||
) ? undefined : value;
|
|
||||||
}
|
|
||||||
return JSON.stringify( rez, replacer, 2 );
|
|
||||||
},
|
|
||||||
|
|
||||||
generate: function( rez, f ) {
|
|
||||||
FS.writeFileSync( f, this.invoke(rez), 'utf8' );
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the JsonYamlGenerator class.
|
|
||||||
@module json-yaml-generator.js
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var BaseGenerator = require('./base-generator');
|
|
||||||
var FS = require('fs');
|
|
||||||
var YAML = require('yamljs');
|
|
||||||
|
|
||||||
/**
|
|
||||||
JsonYamlGenerator takes a JSON resume object and translates it directly to
|
|
||||||
JSON without a template, producing an equivalent YAML-formatted resume. See
|
|
||||||
also YamlGenerator (yaml-generator.js).
|
|
||||||
*/
|
|
||||||
|
|
||||||
var JsonYamlGenerator = module.exports = BaseGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'yml' );
|
|
||||||
},
|
|
||||||
|
|
||||||
invoke: function( rez, themeMarkup, cssInfo, opts ) {
|
|
||||||
return YAML.stringify( JSON.parse( rez.stringify() ), Infinity, 2 );
|
|
||||||
},
|
|
||||||
|
|
||||||
generate: function( rez, f, opts ) {
|
|
||||||
var data = YAML.stringify( JSON.parse( rez.stringify() ), Infinity, 2 );
|
|
||||||
FS.writeFileSync( f, data, 'utf8' );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
|
@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the LaTeXGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module latex-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
|
||||||
|
|
||||||
/**
|
|
||||||
LaTeXGenerator generates a LaTeX resume via TemplateGenerator.
|
|
||||||
*/
|
|
||||||
var LaTeXGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'latex', 'tex' );
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the MarkdownGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module markdown-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
|
||||||
|
|
||||||
/**
|
|
||||||
MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator.
|
|
||||||
*/
|
|
||||||
var MarkdownGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'md', 'txt' );
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
@ -1,318 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the TemplateGenerator class.
|
|
||||||
@license MIT. See LICENSE.md for details.
|
|
||||||
@module template-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var FS = require( 'fs-extra' )
|
|
||||||
, _ = require( 'underscore' )
|
|
||||||
, MD = require( 'marked' )
|
|
||||||
, XML = require( 'xml-escape' )
|
|
||||||
, PATH = require('path')
|
|
||||||
, parsePath = require('parse-filepath')
|
|
||||||
, MKDIRP = require('mkdirp')
|
|
||||||
, BaseGenerator = require( './base-generator' )
|
|
||||||
, EXTEND = require('../utils/extend')
|
|
||||||
, FRESHTheme = require('../core/fresh-theme')
|
|
||||||
, JRSTheme = require('../core/jrs-theme');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Default options.
|
|
||||||
var _defaultOpts = {
|
|
||||||
engine: 'underscore',
|
|
||||||
keepBreaks: true,
|
|
||||||
freezeBreaks: false,
|
|
||||||
nSym: '&newl;', // newline entity
|
|
||||||
rSym: '&retn;', // return entity
|
|
||||||
template: {
|
|
||||||
interpolate: /\{\{(.+?)\}\}/g,
|
|
||||||
escape: /\{\{\=(.+?)\}\}/g,
|
|
||||||
evaluate: /\{\%(.+?)\%\}/g,
|
|
||||||
comment: /\{\#(.+?)\#\}/g
|
|
||||||
},
|
|
||||||
filters: {
|
|
||||||
out: function( txt ) { return txt; },
|
|
||||||
raw: function( txt ) { return txt; },
|
|
||||||
xml: function( txt ) { return XML(txt); },
|
|
||||||
md: function( txt ) { return MD( txt || '' ); },
|
|
||||||
mdin: function( txt ) {
|
|
||||||
return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '');
|
|
||||||
},
|
|
||||||
lower: function( txt ) { return txt.toLowerCase(); },
|
|
||||||
link: function( name, url ) { return url ?
|
|
||||||
'<a href="' + url + '">' + name + '</a>' : name; }
|
|
||||||
},
|
|
||||||
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
|
||||||
indent_size: 2,
|
|
||||||
unformatted: ['em','strong','a'],
|
|
||||||
max_char: 80, // ← See lib/html.js in above-linked repo
|
|
||||||
//wrap_line_length: 120, <-- Don't use this
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
TemplateGenerator performs resume generation via local Handlebar or Underscore
|
|
||||||
style template expansion and is appropriate for text-based formats like HTML,
|
|
||||||
plain text, and XML versions of Microsoft Word, Excel, and OpenOffice.
|
|
||||||
@class TemplateGenerator
|
|
||||||
*/
|
|
||||||
var TemplateGenerator = module.exports = BaseGenerator.extend({
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
init: function( outputFormat, templateFormat, cssFile ){
|
|
||||||
this._super( outputFormat );
|
|
||||||
this.tplFormat = templateFormat || outputFormat;
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
String-based template generation method.
|
|
||||||
@method invoke
|
|
||||||
@param rez A FreshResume object.
|
|
||||||
@param opts Generator options.
|
|
||||||
@returns An array of objects representing the generated output files. Each
|
|
||||||
object has this format:
|
|
||||||
|
|
||||||
{
|
|
||||||
files: [ { info: { }, data: [ ] }, { ... } ],
|
|
||||||
themeInfo: { }
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
invoke: function( rez, opts ) {
|
|
||||||
|
|
||||||
// Carry over options
|
|
||||||
this.opts = EXTEND( true, { }, _defaultOpts, opts );
|
|
||||||
|
|
||||||
// Load the theme
|
|
||||||
var themeInfo = themeFromMoniker.call( this );
|
|
||||||
var theme = themeInfo.theme;
|
|
||||||
var tFolder = themeInfo.folder;
|
|
||||||
var tplFolder = PATH.join( tFolder, 'src' );
|
|
||||||
var curFmt = theme.getFormat( this.format );
|
|
||||||
var that = this;
|
|
||||||
|
|
||||||
// "Generate": process individual files within the theme
|
|
||||||
return {
|
|
||||||
files: curFmt.files.map( function( tplInfo ) {
|
|
||||||
return {
|
|
||||||
info: tplInfo,
|
|
||||||
data: tplInfo.action === 'transform' ?
|
|
||||||
transform.call( that, rez, tplInfo, theme ) : undefined
|
|
||||||
};
|
|
||||||
}).filter(function(item){ return item !== null; }),
|
|
||||||
themeInfo: themeInfo
|
|
||||||
};
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
File-based template generation method.
|
|
||||||
@method generate
|
|
||||||
@param rez A FreshResume object.
|
|
||||||
@param f Full path to the output resume file to generate.
|
|
||||||
@param opts Generator options.
|
|
||||||
*/
|
|
||||||
generate: function( rez, f, opts ) {
|
|
||||||
|
|
||||||
// Call the generation method
|
|
||||||
var genInfo = this.invoke( rez, opts );
|
|
||||||
|
|
||||||
// Carry over options
|
|
||||||
this.opts = EXTEND( true, { }, _defaultOpts, opts );
|
|
||||||
|
|
||||||
// Load the theme
|
|
||||||
var themeInfo = genInfo.themeInfo;
|
|
||||||
var theme = themeInfo.theme;
|
|
||||||
var tFolder = themeInfo.folder;
|
|
||||||
var tplFolder = PATH.join( tFolder, 'src' );
|
|
||||||
var outFolder = parsePath(f).dirname;
|
|
||||||
var curFmt = theme.getFormat( this.format );
|
|
||||||
var that = this;
|
|
||||||
|
|
||||||
// "Generate": process individual files within the theme
|
|
||||||
genInfo.files.forEach(function( file ){
|
|
||||||
|
|
||||||
var thisFilePath;
|
|
||||||
|
|
||||||
if( file.info.action === 'transform' ) {
|
|
||||||
thisFilePath = PATH.join( outFolder, file.info.orgPath );
|
|
||||||
try {
|
|
||||||
if( that.onBeforeSave ) {
|
|
||||||
file.data = that.onBeforeSave({
|
|
||||||
theme: theme,
|
|
||||||
outputFile: (file.info.major ? f : thisFilePath),
|
|
||||||
mk: file.data,
|
|
||||||
opts: that.opts
|
|
||||||
});
|
|
||||||
if( !file.data ) return; // PDF etc
|
|
||||||
}
|
|
||||||
var fileName = file.info.major ? f : thisFilePath;
|
|
||||||
MKDIRP.sync( PATH.dirname( fileName ) );
|
|
||||||
FS.writeFileSync( fileName, file.data,
|
|
||||||
{ encoding: 'utf8', flags: 'w' } );
|
|
||||||
that.onAfterSave && that.onAfterSave(
|
|
||||||
{ outputFile: fileName, mk: file.data, opts: that.opts } );
|
|
||||||
}
|
|
||||||
catch(ex) {
|
|
||||||
require('../core/error-handler').err(ex, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( file.info.action === null/* && theme.explicit*/ ) {
|
|
||||||
thisFilePath = PATH.join( outFolder, file.info.orgPath );
|
|
||||||
try {
|
|
||||||
MKDIRP.sync( PATH.dirname(thisFilePath) );
|
|
||||||
FS.copySync( file.info.path, thisFilePath );
|
|
||||||
}
|
|
||||||
catch(ex) {
|
|
||||||
console.log(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Some themes require a symlink structure. If so, create it.
|
|
||||||
if( curFmt.symLinks ) {
|
|
||||||
Object.keys( curFmt.symLinks ).forEach( function(loc) {
|
|
||||||
var absLoc = PATH.join(outFolder, loc);
|
|
||||||
var absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
|
|
||||||
// 'file', 'dir', or 'junction' (Windows only)
|
|
||||||
var type = parsePath( absLoc ).extname ? 'file' : 'junction';
|
|
||||||
FS.symlinkSync( absTarg, absLoc, type);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return genInfo;
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Perform a single resume JSON-to-DEST resume transformation.
|
|
||||||
@param json A FRESH or JRS resume object.
|
|
||||||
@param jst The stringified template data
|
|
||||||
@param format The format name, such as "html" or "latex"
|
|
||||||
@param cssInfo Needs to be refactored.
|
|
||||||
@param opts Options and passthrough data.
|
|
||||||
*/
|
|
||||||
single: function( json, jst, format, cssInfo, opts, theme ) {
|
|
||||||
this.opts.freezeBreaks && ( jst = freeze(jst) );
|
|
||||||
|
|
||||||
var eng = require( '../eng/' + theme.engine + '-generator' );
|
|
||||||
var result = eng.generate( json, jst, format, cssInfo, opts, theme );
|
|
||||||
|
|
||||||
this.opts.freezeBreaks && ( result = unfreeze(result) );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Export the TemplateGenerator function/ctor.
|
|
||||||
*/
|
|
||||||
module.exports = TemplateGenerator;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Given a theme title, load the corresponding theme.
|
|
||||||
*/
|
|
||||||
function themeFromMoniker() {
|
|
||||||
|
|
||||||
// Verify the specified theme name/path
|
|
||||||
var tFolder = PATH.join(
|
|
||||||
parsePath( require.resolve('fresh-themes') ).dirname,
|
|
||||||
'/themes/',
|
|
||||||
this.opts.theme
|
|
||||||
);
|
|
||||||
|
|
||||||
var t;
|
|
||||||
if( this.opts.theme.startsWith('jsonresume-theme-') ) {
|
|
||||||
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 {
|
|
||||||
theme: t,
|
|
||||||
folder: tFolder
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function transform( rez, tplInfo, theme ) {
|
|
||||||
try {
|
|
||||||
var cssInfo = {
|
|
||||||
file: tplInfo.css ? tplInfo.cssPath : null,
|
|
||||||
data: tplInfo.css || null
|
|
||||||
};
|
|
||||||
|
|
||||||
return this.single( rez, tplInfo.data, this.format, cssInfo, this.opts,
|
|
||||||
theme );
|
|
||||||
}
|
|
||||||
catch(ex) {
|
|
||||||
console.log(ex);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Freeze newlines for protection against errant JST parsers.
|
|
||||||
*/
|
|
||||||
function freeze( markup ) {
|
|
||||||
return markup
|
|
||||||
.replace( _reg.regN, _defaultOpts.nSym )
|
|
||||||
.replace( _reg.regR, _defaultOpts.rSym );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Unfreeze newlines when the coast is clear.
|
|
||||||
*/
|
|
||||||
function unfreeze( markup ) {
|
|
||||||
return markup
|
|
||||||
.replace( _reg.regSymR, '\r' )
|
|
||||||
.replace( _reg.regSymN, '\n' );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Regexes for linebreak preservation.
|
|
||||||
*/
|
|
||||||
var _reg = {
|
|
||||||
regN: new RegExp( '\n', 'g' ),
|
|
||||||
regR: new RegExp( '\r', 'g' ),
|
|
||||||
regSymN: new RegExp( _defaultOpts.nSym, 'g' ),
|
|
||||||
regSymR: new RegExp( _defaultOpts.rSym, 'g' )
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the TextGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module text-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
|
||||||
|
|
||||||
/**
|
|
||||||
The TextGenerator generates a plain-text resume via the TemplateGenerator.
|
|
||||||
*/
|
|
||||||
var TextGenerator = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'txt' );
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = TextGenerator;
|
|
@ -1,19 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the WordGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module word-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
|
||||||
var WordGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'doc', 'xml' );
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the XMLGenerator class.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module xml-generator.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
var BaseGenerator = require('./base-generator');
|
|
||||||
|
|
||||||
/**
|
|
||||||
The XmlGenerator generates an XML resume via the TemplateGenerator.
|
|
||||||
*/
|
|
||||||
var XMLGenerator = module.exports = BaseGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'xml' );
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
|
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the YAMLGenerator class.
|
|
||||||
@module yaml-generator.js
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var TemplateGenerator = require('./template-generator');
|
|
||||||
|
|
||||||
/**
|
|
||||||
YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var YAMLGenerator = module.exports = TemplateGenerator.extend({
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
this._super( 'yml', 'yml' );
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}());
|
|
37
src/generators/base-generator.js
Normal file
37
src/generators/base-generator.js
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS206: Consider reworking classes to avoid initClass
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the BaseGenerator class.
|
||||||
|
@module generators/base-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
The BaseGenerator class is the root of the generator hierarchy. Functionality
|
||||||
|
common to ALL generators lives here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
let BaseGenerator;
|
||||||
|
module.exports = (BaseGenerator = (function() {
|
||||||
|
BaseGenerator = class BaseGenerator {
|
||||||
|
static initClass() {
|
||||||
|
|
||||||
|
/** Status codes. */
|
||||||
|
this.prototype.codes = require('../core/status-codes');
|
||||||
|
|
||||||
|
/** Generator options. */
|
||||||
|
this.prototype.opts = { };
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Base-class initialize. */
|
||||||
|
constructor( format ) {
|
||||||
|
this.format = format;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
BaseGenerator.initClass();
|
||||||
|
return BaseGenerator;
|
||||||
|
})());
|
39
src/generators/html-generator.js
Normal file
39
src/generators/html-generator.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the HTMLGenerator class.
|
||||||
|
@module generators/html-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
const HTML = require('html');
|
||||||
|
require('string.prototype.endswith');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class HtmlGenerator extends TemplateGenerator {
|
||||||
|
|
||||||
|
constructor() { super('html'); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy satellite CSS files to the destination and optionally pretty-print
|
||||||
|
the HTML resume prior to saving.
|
||||||
|
*/
|
||||||
|
onBeforeSave( info ) {
|
||||||
|
if (info.outputFile.endsWith('.css')) {
|
||||||
|
return info.mk;
|
||||||
|
}
|
||||||
|
if (this.opts.prettify) {
|
||||||
|
return HTML.prettyPrint(info.mk, this.opts.prettify);
|
||||||
|
} else { return info.mk; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = HtmlGenerator;
|
129
src/generators/html-pdf-cli-generator.js
Normal file
129
src/generators/html-pdf-cli-generator.js
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS103: Rewrite code to no longer use __guard__
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the HtmlPdfCLIGenerator class.
|
||||||
|
@module generators/html-pdf-generator.js
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
const FS = require('fs-extra');
|
||||||
|
const PATH = require('path');
|
||||||
|
const SLASH = require('slash');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const HMSTATUS = require('../core/status-codes');
|
||||||
|
const SPAWN = require('../utils/safe-spawn');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
An HTML-driven PDF resume generator for HackMyResume. Talks to Phantom,
|
||||||
|
wkhtmltopdf, and other PDF engines over a CLI (command-line interface).
|
||||||
|
If an engine isn't installed for a particular platform, error out gracefully.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class HtmlPdfCLIGenerator extends TemplateGenerator {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
constructor() { super('pdf', 'html'); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Generate the binary PDF. */
|
||||||
|
onBeforeSave( info ) {
|
||||||
|
//console.dir _.omit( info, 'mk' ), depth: null, colors: true
|
||||||
|
if ((info.ext !== 'html') && (info.ext !== 'pdf')) { return info.mk; }
|
||||||
|
let safe_eng = info.opts.pdf || 'wkhtmltopdf';
|
||||||
|
if (safe_eng === 'phantom') { safe_eng = 'phantomjs'; }
|
||||||
|
if (_.has(engines, safe_eng)) {
|
||||||
|
this.errHandler = info.opts.errHandler;
|
||||||
|
engines[ safe_eng ].call(this, info.mk, info.outputFile, info.opts, this.onError);
|
||||||
|
return null; // halt further processing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Low-level error callback for spawn(). May be called after HMR process
|
||||||
|
termination, so object references may not be valid here. That's okay; if
|
||||||
|
the references are invalid, the error was already logged. We could use
|
||||||
|
spawn-watch here but that causes issues on legacy Node.js. */
|
||||||
|
onError(ex, param) {
|
||||||
|
__guardMethod__(param.errHandler, 'err', o => o.err(HMSTATUS.pdfGeneration, ex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = HtmlPdfCLIGenerator;
|
||||||
|
|
||||||
|
// TODO: Move each engine to a separate module
|
||||||
|
var engines = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generate a PDF from HTML using wkhtmltopdf's CLI interface.
|
||||||
|
Spawns a child process with `wkhtmltopdf <source> <target>`. wkhtmltopdf
|
||||||
|
must be installed and path-accessible.
|
||||||
|
TODO: If HTML generation has run, reuse that output
|
||||||
|
TODO: Local web server to ease wkhtmltopdf rendering
|
||||||
|
*/
|
||||||
|
wkhtmltopdf(markup, fOut, opts, on_error) {
|
||||||
|
// Save the markup to a temporary file
|
||||||
|
const tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||||
|
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||||
|
|
||||||
|
// Prepare wkhtmltopdf arguments.
|
||||||
|
let wkopts = _.extend({'margin-top': '10mm', 'margin-bottom': '10mm'}, opts.wkhtmltopdf);
|
||||||
|
wkopts = _.flatten(_.map(wkopts, (v, k) => [`--${k}`, v]));
|
||||||
|
const wkargs = wkopts.concat([ tempFile, fOut ]);
|
||||||
|
|
||||||
|
SPAWN('wkhtmltopdf', wkargs , false, on_error, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generate a PDF from HTML using Phantom's CLI interface.
|
||||||
|
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||||
|
must be installed and path-accessible.
|
||||||
|
TODO: If HTML generation has run, reuse that output
|
||||||
|
TODO: Local web server to ease Phantom rendering
|
||||||
|
*/
|
||||||
|
phantomjs( markup, fOut, opts, on_error ) {
|
||||||
|
// Save the markup to a temporary file
|
||||||
|
const tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||||
|
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||||
|
let scriptPath = PATH.relative(process.cwd(), PATH.resolve( __dirname, '../utils/rasterize.js' ));
|
||||||
|
scriptPath = SLASH(scriptPath);
|
||||||
|
const sourcePath = SLASH(PATH.relative( process.cwd(), tempFile));
|
||||||
|
const destPath = SLASH(PATH.relative( process.cwd(), fOut));
|
||||||
|
SPAWN('phantomjs', [ scriptPath, sourcePath, destPath ], false, on_error, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generate a PDF from HTML using WeasyPrint's CLI interface.
|
||||||
|
Spawns a child process with `weasyprint <source> <target>`. Weasy Print
|
||||||
|
must be installed and path-accessible.
|
||||||
|
TODO: If HTML generation has run, reuse that output
|
||||||
|
*/
|
||||||
|
weasyprint( markup, fOut, opts, on_error ) {
|
||||||
|
// Save the markup to a temporary file
|
||||||
|
const tempFile = fOut.replace(/\.pdf$/i, '.pdf.html');
|
||||||
|
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||||
|
|
||||||
|
SPAWN('weasyprint', [tempFile, fOut], false, on_error, this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function __guardMethod__(obj, methodName, transform) {
|
||||||
|
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
|
||||||
|
return transform(obj, methodName);
|
||||||
|
} else {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
}
|
58
src/generators/html-png-generator.js
Normal file
58
src/generators/html-png-generator.js
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the HtmlPngGenerator class.
|
||||||
|
@module generators/html-png-generator
|
||||||
|
@license MIT. See LICENSE.MD for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
const FS = require('fs-extra');
|
||||||
|
const SLASH = require('slash');
|
||||||
|
const SPAWN = require('../utils/safe-spawn');
|
||||||
|
const PATH = require('path');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
An HTML-based PNG resume generator for HackMyResume.
|
||||||
|
*/
|
||||||
|
class HtmlPngGenerator extends TemplateGenerator {
|
||||||
|
|
||||||
|
constructor() { super('png', 'html'); }
|
||||||
|
|
||||||
|
invoke( /*rez, themeMarkup, cssInfo, opts*/ ) {}
|
||||||
|
// TODO: Not currently called or callable.
|
||||||
|
|
||||||
|
generate( rez, f, opts ) {
|
||||||
|
const htmlResults = opts.targets.filter(t => t.fmt.outFormat === 'html');
|
||||||
|
const htmlFile = htmlResults[0].final.files.filter(fl => fl.info.ext === 'html');
|
||||||
|
phantom(htmlFile[0].data, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = HtmlPngGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generate a PDF from HTML using Phantom's CLI interface.
|
||||||
|
Spawns a child process with `phantomjs <script> <source> <target>`. Phantom
|
||||||
|
must be installed and path-accessible.
|
||||||
|
TODO: If HTML generation has run, reuse that output
|
||||||
|
TODO: Local web server to ease Phantom rendering
|
||||||
|
*/
|
||||||
|
|
||||||
|
var phantom = function( markup, fOut ) {
|
||||||
|
|
||||||
|
// Save the markup to a temporary file
|
||||||
|
const tempFile = fOut.replace(/\.png$/i, '.png.html');
|
||||||
|
FS.writeFileSync(tempFile, markup, 'utf8');
|
||||||
|
const scriptPath = SLASH( PATH.relative( process.cwd(),
|
||||||
|
PATH.resolve( __dirname, '../utils/rasterize.js' ) ) );
|
||||||
|
const sourcePath = SLASH( PATH.relative( process.cwd(), tempFile) );
|
||||||
|
const destPath = SLASH( PATH.relative( process.cwd(), fOut) );
|
||||||
|
SPAWN('phantomjs', [ scriptPath, sourcePath, destPath ]);
|
||||||
|
};
|
33
src/generators/json-generator.js
Normal file
33
src/generators/json-generator.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the JsonGenerator class.
|
||||||
|
@module generators/json-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const BaseGenerator = require('./base-generator');
|
||||||
|
const FS = require('fs');
|
||||||
|
const FJCV = require('fresh-jrs-converter');
|
||||||
|
|
||||||
|
/** The JsonGenerator generates a FRESH or JRS resume as an output. */
|
||||||
|
|
||||||
|
class JsonGenerator extends BaseGenerator {
|
||||||
|
|
||||||
|
constructor() { super('json'); }
|
||||||
|
|
||||||
|
invoke( rez ) {
|
||||||
|
let altRez = FJCV[ `to${rez.format() === 'FRESH' ? 'JRS' : 'FRESH'}` ](rez);
|
||||||
|
return altRez = FJCV.toSTRING( altRez );
|
||||||
|
}
|
||||||
|
//altRez.stringify()
|
||||||
|
|
||||||
|
generate( rez, f ) {
|
||||||
|
FS.writeFileSync(f, this.invoke(rez), 'utf8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = JsonGenerator;
|
41
src/generators/json-yaml-generator.js
Normal file
41
src/generators/json-yaml-generator.js
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the JsonYamlGenerator class.
|
||||||
|
@module generators/json-yaml-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const BaseGenerator = require('./base-generator');
|
||||||
|
const FS = require('fs');
|
||||||
|
const YAML = require('yamljs');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
JsonYamlGenerator takes a JSON resume object and translates it directly to
|
||||||
|
JSON without a template, producing an equivalent YAML-formatted resume. See
|
||||||
|
also YamlGenerator (yaml-generator.js).
|
||||||
|
*/
|
||||||
|
|
||||||
|
class JsonYamlGenerator extends BaseGenerator {
|
||||||
|
|
||||||
|
constructor() { super('yml'); }
|
||||||
|
|
||||||
|
invoke( rez/*, themeMarkup, cssInfo, opts*/ ) {
|
||||||
|
return YAML.stringify(JSON.parse( rez.stringify() ), Infinity, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
generate( rez, f/*, opts */) {
|
||||||
|
const data = YAML.stringify(JSON.parse( rez.stringify() ), Infinity, 2);
|
||||||
|
FS.writeFileSync(f, data, 'utf8');
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = JsonYamlGenerator;
|
17
src/generators/latex-generator.js
Normal file
17
src/generators/latex-generator.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
Definition of the LaTeXGenerator class.
|
||||||
|
@module generators/latex-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
|
||||||
|
/**
|
||||||
|
LaTeXGenerator generates a LaTeX resume via TemplateGenerator.
|
||||||
|
*/
|
||||||
|
class LaTeXGenerator extends TemplateGenerator {
|
||||||
|
|
||||||
|
constructor() { super('latex', 'tex'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = LaTeXGenerator;
|
17
src/generators/markdown-generator.js
Normal file
17
src/generators/markdown-generator.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
Definition of the MarkdownGenerator class.
|
||||||
|
@module generators/markdown-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
|
||||||
|
/**
|
||||||
|
MarkdownGenerator generates a Markdown-formatted resume via TemplateGenerator.
|
||||||
|
*/
|
||||||
|
class MarkdownGenerator extends TemplateGenerator {
|
||||||
|
|
||||||
|
constructor() { super('md', 'txt'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = MarkdownGenerator;
|
283
src/generators/template-generator.js
Normal file
283
src/generators/template-generator.js
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the TemplateGenerator class. TODO: Refactor
|
||||||
|
@module generators/template-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const FS = require('fs-extra');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const MD = require('marked');
|
||||||
|
const XML = require('xml-escape');
|
||||||
|
const PATH = require('path');
|
||||||
|
const parsePath = require('parse-filepath');
|
||||||
|
const MKDIRP = require('mkdirp');
|
||||||
|
const BaseGenerator = require('./base-generator');
|
||||||
|
const EXTEND = require('extend');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
TemplateGenerator performs resume generation via local Handlebar or Underscore
|
||||||
|
style template expansion and is appropriate for text-based formats like HTML,
|
||||||
|
plain text, and XML versions of Microsoft Word, Excel, and OpenOffice.
|
||||||
|
@class TemplateGenerator
|
||||||
|
*/
|
||||||
|
|
||||||
|
class TemplateGenerator extends BaseGenerator {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Constructor. Set the output format and template format for this
|
||||||
|
generator. Will usually be called by a derived generator such as
|
||||||
|
HTMLGenerator or MarkdownGenerator. */
|
||||||
|
|
||||||
|
constructor( outputFormat, templateFormat/*, cssFile */) {
|
||||||
|
super(outputFormat);
|
||||||
|
this.tplFormat = templateFormat || outputFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Generate a resume using string-based inputs and outputs without touching
|
||||||
|
the filesystem.
|
||||||
|
@method invoke
|
||||||
|
@param rez A FreshResume object.
|
||||||
|
@param opts Generator options.
|
||||||
|
@returns {Array} An array of objects representing the generated output
|
||||||
|
files. */
|
||||||
|
|
||||||
|
invoke( rez, opts ) {
|
||||||
|
|
||||||
|
opts =
|
||||||
|
opts
|
||||||
|
? (this.opts = EXTEND( true, { }, _defaultOpts, opts ))
|
||||||
|
: this.opts;
|
||||||
|
|
||||||
|
// Sort such that CSS files are processed before others
|
||||||
|
const curFmt = opts.themeObj.getFormat( this.format );
|
||||||
|
curFmt.files = _.sortBy(curFmt.files, fi => fi.ext !== 'css');
|
||||||
|
|
||||||
|
// Run the transformation!
|
||||||
|
const results = curFmt.files.map(function( tplInfo, idx ) {
|
||||||
|
let trx;
|
||||||
|
if (tplInfo.action === 'transform') {
|
||||||
|
trx = this.transform(rez, tplInfo.data, this.format, opts, opts.themeObj, curFmt);
|
||||||
|
if (tplInfo.ext === 'css') {
|
||||||
|
curFmt.files[idx].data = trx;
|
||||||
|
} else { tplInfo.ext === 'html'; }
|
||||||
|
}
|
||||||
|
//tplInfo.css contains the CSS data loaded by theme
|
||||||
|
//tplInfo.cssPath contains the absolute path to the source CSS File
|
||||||
|
//else {}
|
||||||
|
// Images and non-transformable binary files
|
||||||
|
if (typeof opts.onTransform === 'function') {
|
||||||
|
opts.onTransform(tplInfo);
|
||||||
|
}
|
||||||
|
return {info: tplInfo, data: trx};
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
|
||||||
|
return {files: results};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Generate a resume using file-based inputs and outputs. Requires access
|
||||||
|
to the local filesystem.
|
||||||
|
@method generate
|
||||||
|
@param rez A FreshResume object.
|
||||||
|
@param f Full path to the output resume file to generate.
|
||||||
|
@param opts Generator options. */
|
||||||
|
|
||||||
|
generate( rez, f, opts ) {
|
||||||
|
|
||||||
|
// Prepare
|
||||||
|
this.opts = EXTEND(true, { }, _defaultOpts, opts);
|
||||||
|
|
||||||
|
// Call the string-based generation method
|
||||||
|
const genInfo = this.invoke(rez, null);
|
||||||
|
const outFolder = parsePath( f ).dirname;
|
||||||
|
const curFmt = opts.themeObj.getFormat(this.format);
|
||||||
|
|
||||||
|
// Process individual files within this format. For example, the HTML
|
||||||
|
// output format for a theme may have multiple HTML files, CSS files,
|
||||||
|
// etc. Process them here.
|
||||||
|
genInfo.files.forEach(function( file ) {
|
||||||
|
|
||||||
|
// console.dir _.omit(file.info,'cssData','data','css' )
|
||||||
|
|
||||||
|
// Pre-processing
|
||||||
|
file.info.orgPath = file.info.orgPath || '';
|
||||||
|
const thisFilePath =
|
||||||
|
file.info.primary
|
||||||
|
? f
|
||||||
|
: PATH.join(outFolder, file.info.orgPath);
|
||||||
|
|
||||||
|
if ((file.info.action !== 'copy') && this.onBeforeSave) {
|
||||||
|
file.data = this.onBeforeSave({
|
||||||
|
theme: opts.themeObj,
|
||||||
|
outputFile: thisFilePath,
|
||||||
|
mk: file.data,
|
||||||
|
opts: this.opts,
|
||||||
|
ext: file.info.ext
|
||||||
|
});
|
||||||
|
if (!file.data) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the file
|
||||||
|
if (typeof opts.beforeWrite === 'function') {
|
||||||
|
opts.beforeWrite({data: thisFilePath});
|
||||||
|
}
|
||||||
|
MKDIRP.sync(PATH.dirname( thisFilePath ));
|
||||||
|
|
||||||
|
if (file.info.action !== 'copy') {
|
||||||
|
FS.writeFileSync(thisFilePath, file.data, {encoding: 'utf8', flags: 'w'});
|
||||||
|
} else {
|
||||||
|
FS.copySync(file.info.path, thisFilePath);
|
||||||
|
}
|
||||||
|
if (typeof opts.afterWrite === 'function') {
|
||||||
|
opts.afterWrite({data: thisFilePath});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Post-processing
|
||||||
|
if (this.onAfterSave) {
|
||||||
|
return this.onAfterSave({outputFile: thisFilePath, mk: file.data, opts: this.opts});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
, this);
|
||||||
|
|
||||||
|
// Some themes require a symlink structure. If so, create it.
|
||||||
|
createSymLinks(curFmt, outFolder);
|
||||||
|
|
||||||
|
return genInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Perform a single resume resume transformation using string-based inputs
|
||||||
|
and outputs without touching the local file system.
|
||||||
|
@param json A FRESH or JRS resume object.
|
||||||
|
@param jst The stringified template data
|
||||||
|
@param format The format name, such as "html" or "latex"
|
||||||
|
@param cssInfo Needs to be refactored.
|
||||||
|
@param opts Options and passthrough data. */
|
||||||
|
|
||||||
|
transform( json, jst, format, opts, theme, curFmt ) {
|
||||||
|
if (this.opts.freezeBreaks) {
|
||||||
|
jst = freeze(jst);
|
||||||
|
}
|
||||||
|
const eng = require(`../renderers/${theme.engine}-generator`);
|
||||||
|
let result = eng.generate(json, jst, format, curFmt, opts, theme);
|
||||||
|
if (this.opts.freezeBreaks) {
|
||||||
|
result = unfreeze(result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = TemplateGenerator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var createSymLinks = function( curFmt, outFolder ) {
|
||||||
|
// Some themes require a symlink structure. If so, create it.
|
||||||
|
if (curFmt.symLinks) {
|
||||||
|
Object.keys( curFmt.symLinks ).forEach(function(loc) {
|
||||||
|
const absLoc = PATH.join(outFolder, loc);
|
||||||
|
const absTarg = PATH.join(PATH.dirname(absLoc), curFmt.symLinks[loc]);
|
||||||
|
// Set type to 'file', 'dir', or 'junction' (Windows only)
|
||||||
|
const type = parsePath( absLoc ).extname ? 'file' : 'junction';
|
||||||
|
|
||||||
|
try {
|
||||||
|
return FS.symlinkSync(absTarg, absLoc, type);
|
||||||
|
} catch (err) {
|
||||||
|
let succeeded = false;
|
||||||
|
if (err.code === 'EEXIST') {
|
||||||
|
FS.unlinkSync(absLoc);
|
||||||
|
try {
|
||||||
|
FS.symlinkSync(absTarg, absLoc, type);
|
||||||
|
succeeded = true;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!succeeded) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/** Freeze newlines for protection against errant JST parsers. */
|
||||||
|
var freeze = function( markup ) {
|
||||||
|
markup.replace( _reg.regN, _defaultOpts.nSym );
|
||||||
|
return markup.replace( _reg.regR, _defaultOpts.rSym );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Unfreeze newlines when the coast is clear. */
|
||||||
|
var unfreeze = function( markup ) {
|
||||||
|
markup.replace(_reg.regSymR, '\r');
|
||||||
|
return markup.replace(_reg.regSymN, '\n');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Default template generator options. */
|
||||||
|
var _defaultOpts = {
|
||||||
|
engine: 'underscore',
|
||||||
|
keepBreaks: true,
|
||||||
|
freezeBreaks: false,
|
||||||
|
nSym: '&newl;', // newline entity
|
||||||
|
rSym: '&retn;', // return entity
|
||||||
|
template: {
|
||||||
|
interpolate: /\{\{(.+?)\}\}/g,
|
||||||
|
escape: /\{\{=(.+?)\}\}/g,
|
||||||
|
evaluate: /\{%(.+?)%\}/g,
|
||||||
|
comment: /\{#(.+?)#\}/g
|
||||||
|
},
|
||||||
|
filters: {
|
||||||
|
out( txt ) { return txt; },
|
||||||
|
raw( txt ) { return txt; },
|
||||||
|
xml( txt ) { return XML(txt); },
|
||||||
|
md( txt ) { return MD( txt || '' ); },
|
||||||
|
mdin( txt ) { return MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, ''); },
|
||||||
|
lower( txt ) { return txt.toLowerCase(); },
|
||||||
|
link( name, url ) {
|
||||||
|
if (url) { return `<a href="${url}">${name}</a>`; } else { return name; }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
prettify: { // ← See https://github.com/beautify-web/js-beautify#options
|
||||||
|
indent_size: 2,
|
||||||
|
unformatted: ['em','strong','a'],
|
||||||
|
max_char: 80
|
||||||
|
} // ← See lib/html.js in above-linked repo
|
||||||
|
};
|
||||||
|
//wrap_line_length: 120, <-- Don't use this
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Regexes for linebreak preservation. */
|
||||||
|
/* eslint-disable no-control-regex */
|
||||||
|
var _reg = {
|
||||||
|
regN: new RegExp( '\n', 'g' ),
|
||||||
|
regR: new RegExp( '\r', 'g' ),
|
||||||
|
regSymN: new RegExp( _defaultOpts.nSym, 'g' ),
|
||||||
|
regSymR: new RegExp( _defaultOpts.rSym, 'g' )
|
||||||
|
};
|
||||||
|
/* eslint-enable no-control-regex */
|
16
src/generators/text-generator.js
Normal file
16
src/generators/text-generator.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
/**
|
||||||
|
Definition of the TextGenerator class.
|
||||||
|
@module generators/text-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
|
||||||
|
/**
|
||||||
|
The TextGenerator generates a plain-text resume via the TemplateGenerator.
|
||||||
|
*/
|
||||||
|
class TextGenerator extends TemplateGenerator {
|
||||||
|
constructor() { super('txt'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = TextGenerator;
|
14
src/generators/word-generator.js
Normal file
14
src/generators/word-generator.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/*
|
||||||
|
Definition of the WordGenerator class.
|
||||||
|
@module generators/word-generator
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
|
||||||
|
class WordGenerator extends TemplateGenerator {
|
||||||
|
constructor() { super('doc', 'xml'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = WordGenerator;
|
14
src/generators/xml-generator.js
Normal file
14
src/generators/xml-generator.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
Definition of the XMLGenerator class.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module generatprs/xml-generator
|
||||||
|
*/
|
||||||
|
|
||||||
|
const BaseGenerator = require('./base-generator');
|
||||||
|
|
||||||
|
/** The XmlGenerator generates an XML resume via the TemplateGenerator. */
|
||||||
|
class XMLGenerator extends BaseGenerator {
|
||||||
|
constructor() { super('xml'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = XMLGenerator;
|
19
src/generators/yaml-generator.js
Normal file
19
src/generators/yaml-generator.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
Definition of the YAMLGenerator class.
|
||||||
|
@module yaml-generator.js
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const TemplateGenerator = require('./template-generator');
|
||||||
|
|
||||||
|
/**
|
||||||
|
YamlGenerator generates a YAML-formatted resume via TemplateGenerator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class YAMLGenerator extends TemplateGenerator {
|
||||||
|
constructor() { super('yml', 'yml'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = YAMLGenerator;
|
@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
External API surface for HackMyResume.
|
|
||||||
@license MIT. Copyright (c) 2015 James M. Devlin / FluentDesk.
|
|
||||||
@module hackmyapi.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
|
|
||||||
var v = {
|
|
||||||
build: require('./verbs/generate'),
|
|
||||||
analyze: require('./verbs/analyze'),
|
|
||||||
validate: require('./verbs/validate'),
|
|
||||||
convert: require('./verbs/convert'),
|
|
||||||
new: require('./verbs/create')
|
|
||||||
};
|
|
||||||
|
|
||||||
var HackMyAPI = module.exports = {
|
|
||||||
verbs: v,
|
|
||||||
alias: {
|
|
||||||
generate: v.build,
|
|
||||||
create: v.new
|
|
||||||
},
|
|
||||||
options: require('./core/default-options'),
|
|
||||||
formats: require('./core/default-formats'),
|
|
||||||
Sheet: require('./core/fresh-resume'),
|
|
||||||
FRESHResume: require('./core/fresh-resume'),
|
|
||||||
JRSResume: require('./core/jrs-resume'),
|
|
||||||
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'),
|
|
||||||
HtmlPdfGenerator: require('./gen/html-pdf-generator'),
|
|
||||||
WordGenerator: require('./gen/word-generator'),
|
|
||||||
MarkdownGenerator: require('./gen/markdown-generator'),
|
|
||||||
JsonGenerator: require('./gen/json-generator'),
|
|
||||||
YamlGenerator: require('./gen/yaml-generator'),
|
|
||||||
JsonYamlGenerator: require('./gen/json-yaml-generator'),
|
|
||||||
LaTeXGenerator: require('./gen/latex-generator'),
|
|
||||||
HtmlPngGenerator: require('./gen/html-png-generator')
|
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
77
src/helpers/block-helpers.js
Normal file
77
src/helpers/block-helpers.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Block helper definitions for HackMyResume / FluentCV.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module helpers/generic-helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const LO = require('lodash');
|
||||||
|
const _ = require('underscore');
|
||||||
|
require('../utils/string');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Block helper function definitions. */
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit the enclosed content if the resume has a section with
|
||||||
|
the specified name. Otherwise, emit an empty string ''.
|
||||||
|
*/
|
||||||
|
|
||||||
|
section( title, options ) {
|
||||||
|
title = title.trim().toLowerCase();
|
||||||
|
const obj = LO.get(this.r, title);
|
||||||
|
let ret = '';
|
||||||
|
if (obj) {
|
||||||
|
if (_.isArray(obj)) {
|
||||||
|
if (obj.length) {
|
||||||
|
ret = options.fn(this);
|
||||||
|
}
|
||||||
|
} else if (_.isObject(obj)) {
|
||||||
|
if ((obj.history && obj.history.length) || (obj.sets && obj.sets.length)) {
|
||||||
|
ret = options.fn(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifHasSkill( rez, skill, options ) {
|
||||||
|
const skUp = skill.toUpperCase();
|
||||||
|
const ret = _.some(rez.skills.list, sk => (skUp.toUpperCase() === sk.name.toUpperCase()) && sk.years
|
||||||
|
, this);
|
||||||
|
if (ret) { return options.fn(this); }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit the enclosed content if the resume has the named
|
||||||
|
property or subproperty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
has( title, options ) {
|
||||||
|
title = title && title.trim().toLowerCase();
|
||||||
|
if (LO.get(this.r, title)) {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return true if either value is truthy.
|
||||||
|
@method either
|
||||||
|
*/
|
||||||
|
either( lhs, rhs, options ) { if (lhs || rhs) { return options.fn(this); } }
|
||||||
|
};
|
67
src/helpers/console-helpers.js
Normal file
67
src/helpers/console-helpers.js
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Generic template helper definitions for command-line output.
|
||||||
|
@module console-helpers.js
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const PAD = require('string-padding');
|
||||||
|
const LO = require('lodash');
|
||||||
|
const CHALK = require('chalk');
|
||||||
|
const _ = require('underscore');
|
||||||
|
require('../utils/string');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
v( val, defaultVal, padding, style ) {
|
||||||
|
let retVal = ( (val === null) || (val === undefined) ) ? defaultVal : val;
|
||||||
|
let spaces = 0;
|
||||||
|
if (String.is(padding)) {
|
||||||
|
spaces = parseInt(padding, 10);
|
||||||
|
if (isNaN(spaces)) { spaces = 0; }
|
||||||
|
} else if (_.isNumber(padding)) {
|
||||||
|
spaces = padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (spaces !== 0) {
|
||||||
|
retVal = PAD(retVal, Math.abs(spaces), null, spaces > 0 ? PAD.LEFT : PAD.RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (style && String.is( style )) {
|
||||||
|
retVal = LO.get( CHALK, style )( retVal );
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
},
|
||||||
|
|
||||||
|
gapLength(val) {
|
||||||
|
if (val < 35) {
|
||||||
|
return CHALK.green.bold(val);
|
||||||
|
} else if (val < 95) {
|
||||||
|
return CHALK.yellow.bold(val);
|
||||||
|
} else {
|
||||||
|
return CHALK.red.bold(val);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
style( val, style ) {
|
||||||
|
return LO.get( CHALK, style )( val );
|
||||||
|
},
|
||||||
|
|
||||||
|
isPlural( val, options ) {
|
||||||
|
if (val > 1) {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
pad( val, spaces ) {
|
||||||
|
return PAD(val, Math.abs(spaces), null, spaces > 0 ? PAD.LEFT : PAD.RIGHT);
|
||||||
|
}
|
||||||
|
};
|
703
src/helpers/generic-helpers.js
Normal file
703
src/helpers/generic-helpers.js
Normal file
@ -0,0 +1,703 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* DS207: Consider shorter variations of null checks
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Generic template helper definitions for HackMyResume / FluentCV.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module helpers/generic-helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const MD = require('marked');
|
||||||
|
const H2W = require('../utils/html-to-wpml');
|
||||||
|
const XML = require('xml-escape');
|
||||||
|
const FluentDate = require('../core/fluent-date');
|
||||||
|
const HMSTATUS = require('../core/status-codes');
|
||||||
|
const moment = require('moment');
|
||||||
|
const FS = require('fs');
|
||||||
|
const LO = require('lodash');
|
||||||
|
const PATH = require('path');
|
||||||
|
const printf = require('printf');
|
||||||
|
const _ = require('underscore');
|
||||||
|
require('../utils/string');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Generic template helper function definitions. */
|
||||||
|
var GenericHelpers = (module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit a formatted string representing the specified datetime.
|
||||||
|
Convert the input date to the specified format through Moment.js. If date is
|
||||||
|
valid, return the formatted date string. If date is null, undefined, or other
|
||||||
|
falsy value, return the value of the 'fallback' parameter, if specified, or
|
||||||
|
null if no fallback was specified. If date is invalid, but not null/undefined/
|
||||||
|
falsy, return it as-is.
|
||||||
|
@param {string|Moment} datetime A date value.
|
||||||
|
@param {string} [dtFormat='YYYY-MM'] The desired datetime format. Must be a
|
||||||
|
Moment.js-compatible datetime format.
|
||||||
|
@param {string|Moment} fallback A fallback value to use if the specified date
|
||||||
|
is null, undefined, or falsy.
|
||||||
|
*/
|
||||||
|
formatDate(datetime, dtFormat, fallback) {
|
||||||
|
|
||||||
|
if (datetime == null) { datetime = undefined; }
|
||||||
|
if (dtFormat == null) { dtFormat = 'YYYY-MM'; }
|
||||||
|
|
||||||
|
// If a Moment.js object was passed in, just call format on it
|
||||||
|
if (datetime && moment.isMoment(datetime)) {
|
||||||
|
return datetime.format(dtFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (String.is(datetime)) {
|
||||||
|
// If a string was passed in, convert to Moment using the 2-paramter
|
||||||
|
// constructor with an explicit format string.
|
||||||
|
let momentDate = moment(datetime, dtFormat);
|
||||||
|
if (momentDate.isValid()) { return momentDate.format(dtFormat); }
|
||||||
|
|
||||||
|
// If that didn't work, try again with the single-parameter constructor
|
||||||
|
// but this may throw a deprecation warning
|
||||||
|
momentDate = moment(datetime);
|
||||||
|
if (momentDate.isValid()) { return momentDate.format(dtFormat); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// We weren't able to format the provided datetime. Now do one of three
|
||||||
|
// things.
|
||||||
|
// 1. If datetime is non-null/non-falsy, return it. For this helper,
|
||||||
|
// string date values that we can't parse are assumed to be display dates.
|
||||||
|
// 2. If datetime IS null or falsy, use the value from the fallback.
|
||||||
|
// 3. If the fallback value is specifically 'true', emit 'Present'.
|
||||||
|
return datetime ||
|
||||||
|
(typeof fallback === 'string'
|
||||||
|
? fallback
|
||||||
|
: (fallback === true ? 'Present' : ''));
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit a formatted string representing the specified datetime.
|
||||||
|
@param {string} dateValue A raw date value from the FRESH or JRS resume.
|
||||||
|
@param {string} [dateFormat='YYYY-MM'] The desired datetime format. Must be
|
||||||
|
compatible with Moment.js datetime formats.
|
||||||
|
@param {string} [dateDefault=null] The default date value to use if the dateValue
|
||||||
|
parameter is null, undefined, or falsy.
|
||||||
|
*/
|
||||||
|
date(dateValue, dateFormat, dateDefault) {
|
||||||
|
|
||||||
|
if (!dateDefault || !String.is(dateDefault)) { dateDefault = 'Current'; }
|
||||||
|
if (!dateFormat || !String.is(dateFormat)) { dateFormat = 'YYYY-MM'; }
|
||||||
|
if (!dateValue || !String.is(dateValue)) { dateValue = null; }
|
||||||
|
if (!dateValue) { return dateDefault; }
|
||||||
|
|
||||||
|
const reserved = ['current', 'present', 'now'];
|
||||||
|
const dateValueSafe = dateValue.trim().toLowerCase();
|
||||||
|
if (_.contains(reserved, dateValueSafe)) { return dateValue; }
|
||||||
|
|
||||||
|
const dateValueMoment = moment(dateValue, dateFormat);
|
||||||
|
if (dateValueMoment.isValid()) { return dateValueMoment.format(dateFormat); }
|
||||||
|
return dateValue;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Given a resume sub-object with a start/end date, format a representation of
|
||||||
|
the date range.
|
||||||
|
*/
|
||||||
|
dateRange( obj, fmt, sep, fallback ) {
|
||||||
|
if (!obj) { return ''; }
|
||||||
|
return _fromTo(obj.start, obj.end, fmt, sep, fallback);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Format a from/to date range for display.
|
||||||
|
@method toFrom
|
||||||
|
*/
|
||||||
|
fromTo() { return _fromTo.apply(this, arguments); },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return a named color value as an RRGGBB string.
|
||||||
|
@method toFrom
|
||||||
|
*/
|
||||||
|
color( colorName, colorDefault ) {
|
||||||
|
// Key must be specified
|
||||||
|
if (!(colorName && colorName.trim())) {
|
||||||
|
return _reportError(HMSTATUS.invalidHelperUse,
|
||||||
|
{helper: 'fontList', error: HMSTATUS.missingParam, expected: 'name'});
|
||||||
|
} else {
|
||||||
|
if (!GenericHelpers.theme.colors) { return colorDefault; }
|
||||||
|
const ret = GenericHelpers.theme.colors[ colorName ];
|
||||||
|
if (!(ret && ret.trim())) {
|
||||||
|
return colorDefault;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit the size of the specified named font.
|
||||||
|
@param key {String} A named style from the "fonts" section of the theme's
|
||||||
|
theme.json file. For example: 'default' or 'heading1'.
|
||||||
|
*/
|
||||||
|
fontSize( key, defSize/*, units*/ ) {
|
||||||
|
|
||||||
|
let ret = '';
|
||||||
|
const hasDef = defSize && ( String.is( defSize ) || _.isNumber( defSize ));
|
||||||
|
|
||||||
|
// Key must be specified
|
||||||
|
if (!(key && key.trim())) {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, {
|
||||||
|
helper: 'fontSize', error: HMSTATUS.missingParam, expected: 'key'
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
} else if (GenericHelpers.theme.fonts) {
|
||||||
|
let fontSpec = LO.get( GenericHelpers.theme.fonts, this.format + '.' + key );
|
||||||
|
if (!fontSpec) {
|
||||||
|
// Check for an "all" format
|
||||||
|
if (GenericHelpers.theme.fonts.all) {
|
||||||
|
fontSpec = GenericHelpers.theme.fonts.all[ key ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( fontSpec ) {
|
||||||
|
// fontSpec can be a string, an array, or an object
|
||||||
|
if( String.is( fontSpec )) {
|
||||||
|
// No font size was specified, only a font family.
|
||||||
|
} else if( _.isArray( fontSpec )) {
|
||||||
|
// An array of fonts were specified. Each one could be a string
|
||||||
|
// or an object
|
||||||
|
if( !String.is( fontSpec[0] )) {
|
||||||
|
ret = fontSpec[0].size;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// A font description object.
|
||||||
|
ret = fontSpec.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We weren't able to lookup the specified key. Default to defFont.
|
||||||
|
if (!ret) {
|
||||||
|
if (hasDef) {
|
||||||
|
ret = defSize;
|
||||||
|
} else {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, {
|
||||||
|
helper: 'fontSize', error: HMSTATUS.missingParam,
|
||||||
|
expected: 'defSize'});
|
||||||
|
ret = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit the font face (such as 'Helvetica' or 'Calibri') associated with the
|
||||||
|
provided key.
|
||||||
|
@param key {String} A named style from the "fonts" section of the theme's
|
||||||
|
theme.json file. For example: 'default' or 'heading1'.
|
||||||
|
@param defFont {String} The font to use if the specified key isn't present.
|
||||||
|
Can be any valid font-face name such as 'Helvetica Neue' or 'Calibri'.
|
||||||
|
*/
|
||||||
|
fontFace( key, defFont ) {
|
||||||
|
|
||||||
|
let ret = '';
|
||||||
|
const hasDef = defFont && String.is( defFont );
|
||||||
|
|
||||||
|
// Key must be specified
|
||||||
|
if (!( key && key.trim())) {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, {
|
||||||
|
helper: 'fontFace', error: HMSTATUS.missingParam, expected: 'key'
|
||||||
|
});
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
// If the theme has a "fonts" section, lookup the font face.
|
||||||
|
} else if( GenericHelpers.theme.fonts ) {
|
||||||
|
let fontSpec = LO.get( GenericHelpers.theme.fonts, this.format + '.' + key);
|
||||||
|
if (!fontSpec) {
|
||||||
|
// Check for an "all" format
|
||||||
|
if (GenericHelpers.theme.fonts.all) {
|
||||||
|
fontSpec = GenericHelpers.theme.fonts.all[ key ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fontSpec) {
|
||||||
|
// fontSpec can be a string, an array, or an object
|
||||||
|
if (String.is(fontSpec)) {
|
||||||
|
ret = fontSpec;
|
||||||
|
} else if (_.isArray(fontSpec)) {
|
||||||
|
// An array of fonts were specified. Each one could be a string
|
||||||
|
// or an object
|
||||||
|
ret = String.is( fontSpec[0] ) ? fontSpec[0] : fontSpec[0].name;
|
||||||
|
} else {
|
||||||
|
// A font description object.
|
||||||
|
ret = fontSpec.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// We weren't able to lookup the specified key. Default to defFont.
|
||||||
|
if (!(ret && ret.trim())) {
|
||||||
|
ret = defFont;
|
||||||
|
if (!hasDef) {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, {
|
||||||
|
helper: 'fontFace', error: HMSTATUS.missingParam,
|
||||||
|
expected: 'defFont'});
|
||||||
|
ret = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit a comma-delimited list of font names suitable associated with the
|
||||||
|
provided key.
|
||||||
|
@param key {String} A named style from the "fonts" section of the theme's
|
||||||
|
theme.json file. For example: 'default' or 'heading1'.
|
||||||
|
@param defFontList {Array} The font list to use if the specified key isn't
|
||||||
|
present. Can be an array of valid font-face name such as 'Helvetica Neue'
|
||||||
|
or 'Calibri'.
|
||||||
|
@param sep {String} The default separator to use in the rendered output.
|
||||||
|
Defaults to ", " (comma with a space).
|
||||||
|
*/
|
||||||
|
fontList( key, defFontList, sep ) {
|
||||||
|
|
||||||
|
let ret = '';
|
||||||
|
const hasDef = defFontList && String.is( defFontList );
|
||||||
|
|
||||||
|
// Key must be specified
|
||||||
|
if (!( key && key.trim())) {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, {
|
||||||
|
helper: 'fontList', error: HMSTATUS.missingParam, expected: 'key'
|
||||||
|
});
|
||||||
|
|
||||||
|
// If the theme has a "fonts" section, lookup the font list.
|
||||||
|
} else if (GenericHelpers.theme.fonts) {
|
||||||
|
let fontSpec = LO.get(GenericHelpers.theme.fonts, this.format + '.' + key);
|
||||||
|
if (!fontSpec) {
|
||||||
|
if (GenericHelpers.theme.fonts.all) {
|
||||||
|
fontSpec = GenericHelpers.theme.fonts.all[ key ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fontSpec) {
|
||||||
|
// fontSpec can be a string, an array, or an object
|
||||||
|
if (String.is(fontSpec)) {
|
||||||
|
ret = fontSpec;
|
||||||
|
} else if (_.isArray(fontSpec)) {
|
||||||
|
// An array of fonts were specified. Each one could be a string
|
||||||
|
// or an object
|
||||||
|
fontSpec = fontSpec.map( ff => `'${String.is( ff ) ? ff : ff.name}'`);
|
||||||
|
ret = fontSpec.join( sep === undefined ? ', ' : (sep || '') );
|
||||||
|
} else {
|
||||||
|
// A font description object.
|
||||||
|
ret = fontSpec.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The key wasn't found in the "fonts" section. Default to defFont.
|
||||||
|
if (!(ret && ret.trim())) {
|
||||||
|
if (!hasDef) {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, {
|
||||||
|
helper: 'fontList', error: HMSTATUS.missingParam,
|
||||||
|
expected: 'defFontList'});
|
||||||
|
ret = '';
|
||||||
|
} else {
|
||||||
|
ret = defFontList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Capitalize the first letter of the word. TODO: Rename
|
||||||
|
@method section
|
||||||
|
*/
|
||||||
|
camelCase(val) {
|
||||||
|
val = (val && val.trim()) || '';
|
||||||
|
if (val) { return (val.charAt(0).toUpperCase() + val.slice(1)); } else { return val; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Display a user-overridable section title for a FRESH resume theme. Use this in
|
||||||
|
lieue of hard-coding section titles.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
|
||||||
|
{{sectionTitle "sectionName"}}
|
||||||
|
{{sectionTitle "sectionName" "sectionTitle"}}
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
{{sectionTitle "Education"}}
|
||||||
|
{{sectionTitle "Employment" "Project History"}}
|
||||||
|
|
||||||
|
@param sect_name The name of the section being title. Must be one of the
|
||||||
|
top-level FRESH resume sections ("info", "education", "employment", etc.).
|
||||||
|
@param sect_title The theme-specified section title. May be replaced by the
|
||||||
|
user.
|
||||||
|
@method sectionTitle
|
||||||
|
*/
|
||||||
|
sectionTitle( sname, stitle ) {
|
||||||
|
|
||||||
|
// If not provided by the user, stitle should default to sname. ps.
|
||||||
|
// Handlebars silently passes in the options object to the last param,
|
||||||
|
// where in Underscore stitle will be null/undefined, so we check both.
|
||||||
|
// TODO: not actually sure that's true, given that we _.wrap these functions
|
||||||
|
stitle = (stitle && String.is(stitle) && stitle) || sname;
|
||||||
|
|
||||||
|
// If there's a section title override, use it.
|
||||||
|
return ( this.opts.stitles &&
|
||||||
|
this.opts.stitles[ sname.toLowerCase().trim() ] ) ||
|
||||||
|
stitle;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** Convert inline Markdown to inline WordProcessingML. */
|
||||||
|
wpml( txt, inline ) {
|
||||||
|
if (!txt) { return ''; }
|
||||||
|
inline = (inline && !inline.hash) || false;
|
||||||
|
txt = XML(txt.trim());
|
||||||
|
txt = inline ? MD(txt).replace(/^\s*<p>|<\/p>\s*$/gi, '') : MD(txt);
|
||||||
|
txt = H2W( txt );
|
||||||
|
return txt;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit a conditional link.
|
||||||
|
@method link
|
||||||
|
*/
|
||||||
|
link( text, url ) {
|
||||||
|
if (url && url.trim()) { return (`<a href="${url}">${text}</a>`); } else { return text; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit a conditional Markdown link.
|
||||||
|
@method link
|
||||||
|
*/
|
||||||
|
linkMD( text, url ) {
|
||||||
|
if (url && url.trim()) { return (`[${text}](${url})`); } else { return text; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return the last word of the specified text.
|
||||||
|
@method lastWord
|
||||||
|
*/
|
||||||
|
lastWord( txt ) {
|
||||||
|
if (txt && txt.trim()) { return _.last( txt.split(' ') ); } else { return ''; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert a skill level to an RGB color triplet. TODO: refactor
|
||||||
|
@method skillColor
|
||||||
|
@param lvl Input skill level. Skill level can be expressed as a string
|
||||||
|
("beginner", "intermediate", etc.), as an integer (1,5,etc), as a string
|
||||||
|
integer ("1", "5", etc.), or as an RRGGBB color triplet ('#C00000',
|
||||||
|
'#FFFFAA').
|
||||||
|
*/
|
||||||
|
skillColor( lvl ) {
|
||||||
|
const idx = _skillLevelToIndex(lvl);
|
||||||
|
const skillColors = (this.theme && this.theme.palette &&
|
||||||
|
this.theme.palette.skillLevels) ||
|
||||||
|
[ '#FFFFFF', '#5CB85C', '#F1C40F', '#428BCA', '#C00000' ];
|
||||||
|
return skillColors[idx];
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return an appropriate height. TODO: refactor
|
||||||
|
@method lastWord
|
||||||
|
*/
|
||||||
|
skillHeight( lvl ) {
|
||||||
|
const idx = _skillLevelToIndex(lvl);
|
||||||
|
return ['38.25', '30', '16', '8', '0'][idx];
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Return all but the last word of the input text.
|
||||||
|
@method initialWords
|
||||||
|
*/
|
||||||
|
initialWords( txt ) {
|
||||||
|
if (txt && txt.trim()) { return _.initial( txt.split(' ') ).join(' '); } else { return ''; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Trim the protocol (http or https) from a URL/
|
||||||
|
@method trimURL
|
||||||
|
*/
|
||||||
|
trimURL( url ) {
|
||||||
|
if (url && url.trim()) { return url.trim().replace(/^https?:\/\//i, ''); } else { return ''; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert text to lowercase.
|
||||||
|
@method toLower
|
||||||
|
*/
|
||||||
|
toLower( txt ) { if (txt && txt.trim()) { return txt.toLowerCase(); } else { return ''; } },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Convert text to lowercase.
|
||||||
|
@method toLower
|
||||||
|
*/
|
||||||
|
toUpper( txt ) { if (txt && txt.trim()) { return txt.toUpperCase(); } else { return ''; } },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Conditional stylesheet link. Creates a link to the specified stylesheet with
|
||||||
|
<link> or embeds the styles inline with <style></style>, depending on the
|
||||||
|
theme author's and user's preferences.
|
||||||
|
@param url {String} The path to the CSS file.
|
||||||
|
@param linkage {String} The default link method. Can be either `embed` or
|
||||||
|
`link`. If omitted, defaults to `embed`. Can be overridden by the `--css`
|
||||||
|
command-line switch.
|
||||||
|
*/
|
||||||
|
styleSheet( url, linkage ) {
|
||||||
|
|
||||||
|
// Establish the linkage style
|
||||||
|
linkage = this.opts.css || linkage || 'embed';
|
||||||
|
|
||||||
|
// Create the <link> or <style> tag
|
||||||
|
let ret = '';
|
||||||
|
if (linkage === 'link') {
|
||||||
|
ret = printf('<link href="%s" rel="stylesheet" type="text/css">', url);
|
||||||
|
} else {
|
||||||
|
const rawCss = FS.readFileSync(
|
||||||
|
PATH.join( this.opts.themeObj.folder, '/src/', url ), 'utf8' );
|
||||||
|
const renderedCss = this.engine.generateSimple( this, rawCss );
|
||||||
|
ret = printf('<style>%s</style>', renderedCss );
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the currently-executing template is inherited, append styles
|
||||||
|
if (this.opts.themeObj.inherits && this.opts.themeObj.inherits.html && (this.format === 'html')) {
|
||||||
|
ret +=
|
||||||
|
(linkage === 'link')
|
||||||
|
? `<link href="${this.opts.themeObj.overrides.path}" rel="stylesheet" type="text/css">`
|
||||||
|
: `<style>${this.opts.themeObj.overrides.data}</style>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: It would be nice to use Handlebar.SafeString here, but these
|
||||||
|
// are supposed to be generic helpers. Provide an equivalent, or expose
|
||||||
|
// it when Handlebars is the chosen engine, which is most of the time.
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform a generic comparison.
|
||||||
|
See: http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates
|
||||||
|
@method compare
|
||||||
|
*/
|
||||||
|
compare(lvalue, rvalue, options) {
|
||||||
|
if (arguments.length < 3) {
|
||||||
|
throw new Error('Template helper \'compare\' needs 2 parameters');
|
||||||
|
}
|
||||||
|
const operator = options.hash.operator || '==';
|
||||||
|
const operators = {
|
||||||
|
'=='(l,r) { return l === r; },
|
||||||
|
'==='(l,r) { return l === r; },
|
||||||
|
'!='(l,r) { return l !== r; },
|
||||||
|
'<'(l,r) { return l < r; },
|
||||||
|
'>'(l,r) { return l > r; },
|
||||||
|
'<='(l,r) { return l <= r; },
|
||||||
|
'>='(l,r) { return l >= r; },
|
||||||
|
'typeof'(l,r) { return typeof l === r; }
|
||||||
|
};
|
||||||
|
if (!operators[operator]) {
|
||||||
|
throw new Error(`Helper 'compare' doesn't know the operator ${operator}`);
|
||||||
|
}
|
||||||
|
const result = operators[operator]( lvalue, rvalue );
|
||||||
|
if (result) { return options.fn(this); } else { return options.inverse(this); }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Emit padded text.
|
||||||
|
*/
|
||||||
|
pad(stringOrArray, padAmount/*, unused*/ ) {
|
||||||
|
stringOrArray = stringOrArray || '';
|
||||||
|
padAmount = padAmount || 0;
|
||||||
|
let ret = '';
|
||||||
|
const PAD = require('string-padding');
|
||||||
|
if (!String.is(stringOrArray)) {
|
||||||
|
ret = stringOrArray
|
||||||
|
.map(line => PAD(line, line.length + Math.abs(padAmount), null, padAmount < 0 ? PAD.LEFT : PAD.RIGHT))
|
||||||
|
.join('\n');
|
||||||
|
} else {
|
||||||
|
ret = PAD(stringOrArray, stringOrArray.length + Math.abs(padAmount), null, padAmount < 0 ? PAD.LEFT : PAD.RIGHT);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Given the name of a skill ("JavaScript" or "HVAC repair"), return the number
|
||||||
|
of years assigned to that skill in the resume.skills.list collection.
|
||||||
|
*/
|
||||||
|
skillYears( skill, rez ) {
|
||||||
|
const sk = _.find(rez.skills.list, sk => sk.name.toUpperCase() === skill.toUpperCase());
|
||||||
|
if (sk) { return sk.years; } else { return '?'; }
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Given an object that may be a string or an object, return it as-is if it's a
|
||||||
|
string, otherwise return the value at obj[objPath].
|
||||||
|
*/
|
||||||
|
stringOrObject( obj, objPath/*, rez */) {
|
||||||
|
if (_.isString(obj)) { return obj; } else { return LO.get(obj, objPath); }
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Report an error to the outside world without throwing an exception. Currently
|
||||||
|
relies on kludging the running verb into. opts.
|
||||||
|
*/
|
||||||
|
var _reportError = ( code, params ) => GenericHelpers.opts.errHandler.err( code, params );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Format a from/to date range for display.
|
||||||
|
*/
|
||||||
|
var _fromTo = function( dateA, dateB, fmt, sep, fallback ) {
|
||||||
|
// Prevent accidental use of safe.start, safe.end, safe.date
|
||||||
|
// The dateRange helper is for raw dates only
|
||||||
|
if (moment.isMoment( dateA ) || moment.isMoment( dateB )) {
|
||||||
|
_reportError( HMSTATUS.invalidHelperUse, { helper: 'dateRange' } );
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
let dateFrom = null;
|
||||||
|
let dateTo = null;
|
||||||
|
let dateTemp = null;
|
||||||
|
|
||||||
|
// Check for 'current', 'present', 'now', '', null, and undefined
|
||||||
|
dateA = dateA || '';
|
||||||
|
dateB = dateB || '';
|
||||||
|
const dateATrim = dateA.trim().toLowerCase();
|
||||||
|
const dateBTrim = dateB.trim().toLowerCase();
|
||||||
|
const reserved = ['current','present','now', ''];
|
||||||
|
|
||||||
|
fmt = (fmt && String.is(fmt) && fmt) || 'YYYY-MM';
|
||||||
|
sep = (sep && String.is(sep) && sep) || ' — ';
|
||||||
|
|
||||||
|
if (_.contains( reserved, dateATrim )) {
|
||||||
|
dateFrom = fallback || '???';
|
||||||
|
} else {
|
||||||
|
dateTemp = FluentDate.fmt( dateA );
|
||||||
|
dateFrom = dateTemp.format( fmt );
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_.contains( reserved, dateBTrim )) {
|
||||||
|
dateTo = fallback || 'Present';
|
||||||
|
} else {
|
||||||
|
dateTemp = FluentDate.fmt( dateB );
|
||||||
|
dateTo = dateTemp.format( fmt );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (dateFrom === dateTo) {
|
||||||
|
return dateFrom;
|
||||||
|
} else if (dateFrom && dateTo) {
|
||||||
|
return dateFrom + sep + dateTo;
|
||||||
|
} else if (dateFrom || dateTo) {
|
||||||
|
return dateFrom || dateTo;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var _skillLevelToIndex = function( lvl ) {
|
||||||
|
let idx = 0;
|
||||||
|
if (String.is( lvl )) {
|
||||||
|
lvl = lvl.trim().toLowerCase();
|
||||||
|
const intVal = parseInt( lvl );
|
||||||
|
if (isNaN(intVal)) {
|
||||||
|
switch (lvl) {
|
||||||
|
case 'beginner': idx = 1; break;
|
||||||
|
case 'intermediate': idx = 2; break;
|
||||||
|
case 'advanced': idx = 3; break;
|
||||||
|
case 'master': idx = 4; break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
idx = Math.min( intVal / 2, 4 );
|
||||||
|
idx = Math.max( 0, idx );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
idx = Math.min( lvl / 2, 4 );
|
||||||
|
idx = Math.max( 0, idx );
|
||||||
|
}
|
||||||
|
return idx;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Note [1] --------------------------------------------------------------------
|
||||||
|
// Make sure it's precisely a string or array since some template engines jam
|
||||||
|
// their options/context object into the last parameter and we are allowing the
|
||||||
|
// defFont parameter to be omitted in certain cases. This is a little kludgy,
|
||||||
|
// but works fine for this case. If we start doing this regularly, we should
|
||||||
|
// rebind these parameters.
|
||||||
|
|
||||||
|
// Note [2]: -------------------------------------------------------------------
|
||||||
|
// If execution reaches here, some sort of cosmic ray or sunspot has landed on
|
||||||
|
// HackMyResume, or a theme author is deliberately messing with us by doing
|
||||||
|
// something like:
|
||||||
|
//
|
||||||
|
// "fonts": {
|
||||||
|
// "default": "",
|
||||||
|
// "heading1": null
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Rather than sort it out, we'll just fall back to defFont.
|
89
src/helpers/handlebars-helpers.js
Normal file
89
src/helpers/handlebars-helpers.js
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
Template helper definitions for Handlebars.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module handlebars-helpers.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
const HANDLEBARS = require('handlebars');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const helpers = require('./generic-helpers');
|
||||||
|
const path = require('path');
|
||||||
|
const blockHelpers = require('./block-helpers');
|
||||||
|
const HMS = require('../core/status-codes');
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register useful Handlebars helpers.
|
||||||
|
@method registerHelpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = function( theme, rez, opts ) {
|
||||||
|
|
||||||
|
helpers.theme = theme;
|
||||||
|
helpers.opts = opts;
|
||||||
|
helpers.type = 'handlebars';
|
||||||
|
|
||||||
|
// Prepare generic helpers for use with Handlebars. We do this by wrapping them
|
||||||
|
// in a Handlebars-aware wrapper which calls the helper internally.
|
||||||
|
const wrappedHelpers = _.mapObject(helpers, function( hVal/*, hKey*/ ) {
|
||||||
|
if (_.isFunction(hVal)) {
|
||||||
|
return _.wrap(hVal, function(func) {
|
||||||
|
const args = Array.prototype.slice.call(arguments);
|
||||||
|
args.shift(); // lose the 1st element (func) [^1]
|
||||||
|
//args.pop() # lose the last element (HB options hash)
|
||||||
|
args[ args.length - 1 ] = rez; // replace w/ resume object
|
||||||
|
return func.apply(this, args);
|
||||||
|
}); // call the generic helper
|
||||||
|
}
|
||||||
|
return hVal;
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
HANDLEBARS.registerHelper(wrappedHelpers);
|
||||||
|
|
||||||
|
// Prepare Handlebars-specific helpers - "blockHelpers" is really a misnomer
|
||||||
|
// since any kind of Handlebars-specific helper can live here
|
||||||
|
HANDLEBARS.registerHelper(blockHelpers);
|
||||||
|
|
||||||
|
// Register any theme-provided custom helpers...
|
||||||
|
|
||||||
|
// Normalize "theme.helpers" (string or array) to an array
|
||||||
|
if (_.isString(theme.helpers)) { theme.helpers = [ theme.helpers ]; }
|
||||||
|
|
||||||
|
if (_.isArray(theme.helpers)) {
|
||||||
|
const glob = require('glob');
|
||||||
|
const slash = require('slash');
|
||||||
|
let curGlob = null;
|
||||||
|
try {
|
||||||
|
_.each(theme.helpers, function(fGlob) { // foreach theme.helpers entry
|
||||||
|
curGlob = fGlob; // ..cache in case of exception
|
||||||
|
fGlob = path.join(theme.folder, fGlob); // ..make relative to theme
|
||||||
|
const files = glob.sync(slash(fGlob)); // ..expand the glob
|
||||||
|
if (files.length > 0) { // ..guard against empty glob
|
||||||
|
_.each(files, function(f) { // ..loop over concrete paths
|
||||||
|
HANDLEBARS.registerHelper(require(f)); // ..register the path
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
throw {fluenterror: HMS.themeHelperLoad, inner: null, glob: fGlob};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} catch (ex) {
|
||||||
|
throw{
|
||||||
|
fluenterror: HMS.themeHelperLoad,
|
||||||
|
inner: ex,
|
||||||
|
glob: curGlob, exit: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// [^1]: This little bit of acrobatics ensures that our generic helpers are
|
||||||
|
// called as generic helpers, not as Handlebars-specific helpers. This allows
|
||||||
|
// them to be used in other templating engines, like Underscore. If you need a
|
||||||
|
// Handlebars-specific helper with normal Handlebars context and options, put it
|
||||||
|
// in block-helpers.coffee.
|
35
src/helpers/underscore-helpers.js
Normal file
35
src/helpers/underscore-helpers.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Template helper definitions for Underscore.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module handlebars-helpers.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const _ = require('underscore');
|
||||||
|
const helpers = require('./generic-helpers');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Register useful Underscore helpers.
|
||||||
|
@method registerHelpers
|
||||||
|
*/
|
||||||
|
module.exports = function( theme, opts, cssInfo, ctx, eng ) {
|
||||||
|
helpers.theme = theme;
|
||||||
|
helpers.opts = opts;
|
||||||
|
helpers.cssInfo = cssInfo;
|
||||||
|
helpers.engine = eng;
|
||||||
|
ctx.h = helpers;
|
||||||
|
_.each(helpers, function( hVal ) {
|
||||||
|
if (_.isFunction(hVal)) {
|
||||||
|
return _.bind(hVal, ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
, this);
|
||||||
|
};
|
270
src/index.js
270
src/index.js
@ -1,242 +1,46 @@
|
|||||||
#! /usr/bin/env node
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Command-line interface (CLI) for HackMyResume.
|
External API surface for HackMyResume.
|
||||||
@license MIT. Copyright (c) 2015 hacksalot (https://github.com/hacksalot)
|
@license MIT. See LICENSE.md for details.
|
||||||
@module index.js
|
@module hackmycore/index
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var SPAWNW = require('./core/spawn-watch')
|
/** API facade for HackMyResume. */
|
||||||
, HMR = require( './hackmyapi')
|
|
||||||
, PKG = require('../package.json')
|
|
||||||
, FS = require('fs')
|
|
||||||
, EXTEND = require('./utils/extend')
|
|
||||||
, chalk = require('chalk')
|
|
||||||
, PATH = require('path')
|
|
||||||
, HACKMYSTATUS = require('./core/status-codes')
|
|
||||||
, safeLoadJSON = require('./utils/safe-json-loader')
|
|
||||||
, _opts = { }
|
|
||||||
, title = chalk.white.bold('\n*** HackMyResume v' + PKG.version + ' ***')
|
|
||||||
, StringUtils = require('./utils/string.js')
|
|
||||||
, _ = require('underscore')
|
|
||||||
, Command = require('commander').Command;
|
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
verbs: {
|
||||||
|
build: require('./verbs/build'),
|
||||||
|
analyze: require('./verbs/analyze'),
|
||||||
|
validate: require('./verbs/validate'),
|
||||||
|
convert: require('./verbs/convert'),
|
||||||
|
new: require('./verbs/create'),
|
||||||
|
peek: require('./verbs/peek')
|
||||||
|
},
|
||||||
|
|
||||||
try {
|
alias: {
|
||||||
main();
|
generate: require('./verbs/build'),
|
||||||
}
|
create: require('./verbs/create')
|
||||||
catch( ex ) {
|
},
|
||||||
require('./core/error-handler').err( ex, true );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
options: require('./core/default-options'),
|
||||||
/**
|
formats: require('./core/default-formats'),
|
||||||
Kick off the HackMyResume application.
|
Sheet: require('./core/fresh-resume'),
|
||||||
*/
|
FRESHResume: require('./core/fresh-resume'),
|
||||||
function main() {
|
JRSResume: require('./core/jrs-resume'),
|
||||||
|
FRESHTheme: require('./core/fresh-theme'),
|
||||||
var args = initialize();
|
JRSTheme: require('./core/jrs-theme'),
|
||||||
|
ResumeFactory: require('./core/resume-factory'),
|
||||||
// Create the top-level (application) command...
|
FluentDate: require('./core/fluent-date'),
|
||||||
var program = new Command('hackmyresume')
|
HtmlGenerator: require('./generators/html-generator'),
|
||||||
.version(PKG.version)
|
TextGenerator: require('./generators/text-generator'),
|
||||||
.description(chalk.yellow.bold('*** HackMyResume ***'))
|
HtmlPdfCliGenerator: require('./generators/html-pdf-cli-generator'),
|
||||||
.option('-o --opts <optionsFile>', 'Path to a .hackmyrc options file')
|
WordGenerator: require('./generators/word-generator'),
|
||||||
.option('-s --silent', 'Run in silent mode')
|
MarkdownGenerator: require('./generators/markdown-generator'),
|
||||||
.option('--no-color', 'Disable colors')
|
JsonGenerator: require('./generators/json-generator'),
|
||||||
.option('--color', 'Enable colors');
|
YamlGenerator: require('./generators/yaml-generator'),
|
||||||
//.usage('COMMAND <sources> [TO <targets>]');
|
JsonYamlGenerator: require('./generators/json-yaml-generator'),
|
||||||
|
LaTeXGenerator: require('./generators/latex-generator'),
|
||||||
// Create the NEW command
|
HtmlPngGenerator: require('./generators/html-png-generator')
|
||||||
program
|
};
|
||||||
.command('new')
|
|
||||||
.arguments('<sources...>')
|
|
||||||
.option('-f --format <fmt>', 'FRESH or JRS format', 'FRESH')
|
|
||||||
.alias('create')
|
|
||||||
.description('Create resume(s) in FRESH or JSON RESUME format.')
|
|
||||||
.action(function( sources ) {
|
|
||||||
execVerb.call( this, sources, [], this.opts(), logMsg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the VALIDATE command
|
|
||||||
program
|
|
||||||
.command('validate')
|
|
||||||
.arguments('<sources...>')
|
|
||||||
.option('-a --assert', 'Treat validation warnings as errors', false)
|
|
||||||
.description('Validate a resume in FRESH or JSON RESUME format.')
|
|
||||||
.action(function(sources) {
|
|
||||||
execVerb.call( this, sources, [], this.opts(), logMsg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the CONVERT command
|
|
||||||
program
|
|
||||||
.command('convert')
|
|
||||||
//.arguments('<sources...>')
|
|
||||||
.description('Convert a resume to/from FRESH or JSON RESUME format.')
|
|
||||||
.action(function() {
|
|
||||||
var x = splitSrcDest.call( this );
|
|
||||||
execVerb.call( this, x.src, x.dst, this.opts(), logMsg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the ANALYZE command
|
|
||||||
program
|
|
||||||
.command('analyze')
|
|
||||||
.arguments('<sources...>')
|
|
||||||
.description('Analyze one or more resumes.')
|
|
||||||
.action(function( sources ) {
|
|
||||||
execVerb.call( this, sources, [], this.opts(), logMsg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create the BUILD command
|
|
||||||
program
|
|
||||||
.command('build')
|
|
||||||
.alias('generate')
|
|
||||||
//.arguments('<sources> TO [targets]')
|
|
||||||
//.usage('...')
|
|
||||||
.option('-t --theme <theme>', 'Theme name or path')
|
|
||||||
.option('-n --no-prettify', 'Disable HTML prettification', true)
|
|
||||||
.option('-c --css <option>', 'CSS linking / embedding', 'embed')
|
|
||||||
.option('-p --pdf <engine>', 'PDF generation engine')
|
|
||||||
.option('--no-tips', 'Disable theme tips and warnings.', false)
|
|
||||||
.description('Generate resume to multiple formats')
|
|
||||||
.action(function( sources, targets, options ) {
|
|
||||||
var x = splitSrcDest.call( this );
|
|
||||||
execVerb.call( this, x.src, x.dst, this.opts(), logMsg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// program.on('--help', function(){
|
|
||||||
// console.log(' Examples:');
|
|
||||||
// console.log('');
|
|
||||||
// console.log(' $ custom-help --help');
|
|
||||||
// console.log(' $ custom-help -h');
|
|
||||||
// console.log('');
|
|
||||||
// });
|
|
||||||
|
|
||||||
program.parse( args );
|
|
||||||
|
|
||||||
if (!program.args.length) { throw { fluenterror: 4 }; }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Massage command-line args and setup Commander.js.
|
|
||||||
*/
|
|
||||||
function initialize() {
|
|
||||||
|
|
||||||
logMsg( title );
|
|
||||||
|
|
||||||
// Support case-insensitive sub-commands (build, generate, validate, etc.)..
|
|
||||||
var oVerb, verb = '', args = process.argv.slice(), cleanArgs = args.slice(2);
|
|
||||||
if( cleanArgs.length ) {
|
|
||||||
var verbIdx = _.findIndex( cleanArgs, function(v){ return v[0] !== '-'; });
|
|
||||||
if( verbIdx !== -1 ) {
|
|
||||||
oVerb = cleanArgs[ verbIdx ];
|
|
||||||
verb = args[ verbIdx + 2 ] = oVerb.trim().toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle invalid verbs here (a bit easier here than in commander.js)...
|
|
||||||
if( verb && !HMR.verbs[ verb ] && !HMR.alias[ verb ] ) {
|
|
||||||
throw { fluenterror: HACKMYSTATUS.invalidCommand, shouldExit: true,
|
|
||||||
attempted: oVerb };
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override the .missingArgument behavior
|
|
||||||
Command.prototype.missingArgument = function(name) {
|
|
||||||
if( this.name() !== 'new' )
|
|
||||||
throw { fluenterror: HACKMYSTATUS.resumeNotFound };
|
|
||||||
};
|
|
||||||
|
|
||||||
// Override the .helpInformation behavior
|
|
||||||
Command.prototype.helpInformation = function() {
|
|
||||||
var manPage = FS.readFileSync( PATH.join(__dirname, 'use.txt'), 'utf8' );
|
|
||||||
return chalk.green.bold(manPage);
|
|
||||||
};
|
|
||||||
|
|
||||||
return args;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Invoke a HackMyResume verb.
|
|
||||||
*/
|
|
||||||
function execVerb( src, dst, opts, log ) {
|
|
||||||
loadOptions.call( this, opts );
|
|
||||||
HMR.verbs[ this.name() ].call( null, src, dst, _opts, log );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Initialize HackMyResume options.
|
|
||||||
*/
|
|
||||||
function loadOptions( opts ) {
|
|
||||||
|
|
||||||
opts.opts = this.parent.opts;
|
|
||||||
|
|
||||||
// Load the specified options file (if any) and apply options
|
|
||||||
if( opts.opts && String.is( opts.opts )) {
|
|
||||||
var json = safeLoadJSON( PATH.relative( process.cwd(), opts.opts ) );
|
|
||||||
json && ( opts = EXTEND( true, opts, json ) );
|
|
||||||
if( !json ) {
|
|
||||||
throw safeLoadJSON.error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge in command-line options
|
|
||||||
opts = EXTEND( true, opts, this.opts() );
|
|
||||||
opts.silent = this.parent.silent;
|
|
||||||
_opts = opts;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Split multiple command-line filenames by the 'TO' keyword
|
|
||||||
*/
|
|
||||||
function splitSrcDest() {
|
|
||||||
|
|
||||||
var params = this.parent.args.filter(function(j) { return String.is(j); });
|
|
||||||
if( params.length === 0 )
|
|
||||||
throw { fluenterror: HACKMYSTATUS.resumeNotFound };
|
|
||||||
|
|
||||||
// Find the TO keyword, if any
|
|
||||||
var splitAt = _.findIndex( params, function(p) {
|
|
||||||
return p.toLowerCase() === 'to';
|
|
||||||
});
|
|
||||||
|
|
||||||
// TO can't be the last keyword
|
|
||||||
if( splitAt === params.length - 1 && splitAt !== -1 ) {
|
|
||||||
logMsg(chalk.yellow('Please ') +
|
|
||||||
chalk.yellow.bold('specify an output file') +
|
|
||||||
chalk.yellow(' for this operation or ') +
|
|
||||||
chalk.yellow.bold('omit the TO keyword') +
|
|
||||||
chalk.yellow('.') );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
src: params.slice(0, splitAt === -1 ? undefined : splitAt ),
|
|
||||||
dst: splitAt === -1 ? [] : params.slice( splitAt + 1 )
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Simple logging placeholder.
|
|
||||||
*/
|
|
||||||
function logMsg( msg ) {
|
|
||||||
msg = msg || '';
|
|
||||||
_opts.silent || console.log( msg );
|
|
||||||
}
|
|
||||||
|
54
src/inspectors/duration-inspector.js
Normal file
54
src/inspectors/duration-inspector.js
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
const FluentDate = require('../core/fluent-date');
|
||||||
|
const _ = require('underscore');
|
||||||
|
const lo = require('lodash');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
/**
|
||||||
|
Compute the total duration of the work history.
|
||||||
|
@returns The total duration of the sheet's work history, that is, the number
|
||||||
|
of years between the start date of the earliest job on the resume and the
|
||||||
|
*latest end date of all jobs in the work history*. This last condition is for
|
||||||
|
sheets that have overlapping jobs.
|
||||||
|
*/
|
||||||
|
run(rez, collKey, startKey, endKey, unit) {
|
||||||
|
unit = unit || 'years';
|
||||||
|
const hist = lo.get(rez, collKey);
|
||||||
|
if (!hist || !hist.length) { return 0; }
|
||||||
|
|
||||||
|
// BEGIN CODE DUPLICATION --> src/inspectors/gap-inspector.coffee (TODO)
|
||||||
|
|
||||||
|
// Convert the candidate's employment history to an array of dates,
|
||||||
|
// where each element in the array is a start date or an end date of a
|
||||||
|
// job -- it doesn't matter which.
|
||||||
|
let new_e = hist.map(function( job ) {
|
||||||
|
let obj = _.pick( job, [startKey, endKey] );
|
||||||
|
// Synthesize an end date if this is a "current" gig
|
||||||
|
if (!_.has(obj, endKey)) { obj[endKey] = 'current'; }
|
||||||
|
if (obj && (obj[startKey] || obj[endKey])) {
|
||||||
|
obj = _.pairs(obj);
|
||||||
|
obj[0][1] = FluentDate.fmt( obj[0][1] );
|
||||||
|
if (obj.length > 1) {
|
||||||
|
obj[1][1] = FluentDate.fmt( obj[1][1] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Flatten the array, remove empties, and sort
|
||||||
|
new_e = _.filter(_.flatten( new_e, true ), v => v && v.length && v[0] && v[0].length);
|
||||||
|
if (!new_e || !new_e.length) { return 0; }
|
||||||
|
new_e = _.sortBy(new_e, elem => elem[1].unix());
|
||||||
|
|
||||||
|
// END CODE DUPLICATION
|
||||||
|
|
||||||
|
const firstDate = _.first( new_e )[1];
|
||||||
|
const lastDate = _.last( new_e )[1];
|
||||||
|
return lastDate.diff(firstDate, unit);
|
||||||
|
}
|
||||||
|
};
|
@ -1,151 +1,157 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Employment gap analysis for HackMyResume.
|
Employment gap analysis for HackMyResume.
|
||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module gap-inspector.js
|
@module inspectors/gap-inspector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
const _ = require('underscore');
|
||||||
|
const FluentDate = require('../core/fluent-date');
|
||||||
|
const moment = require('moment');
|
||||||
|
const LO = require('lodash');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
/**
|
||||||
var FluentDate = require('../core/fluent-date');
|
Identify gaps in the candidate's employment history.
|
||||||
var moment = require('moment');
|
*/
|
||||||
var LO = require('lodash');
|
module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
moniker: 'gap-inspector',
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Identify gaps in the candidate's employment history.
|
Run the Gap Analyzer on a resume.
|
||||||
@class gapInspector
|
@method run
|
||||||
|
@return {Array} An array of object representing gaps in the candidate's
|
||||||
|
employment history. Each object provides the start, end, and duration of the
|
||||||
|
gap:
|
||||||
|
{ <-- gap
|
||||||
|
start: // A Moment.js date
|
||||||
|
end: // A Moment.js date
|
||||||
|
duration: // Gap length
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
var gapInspector = module.exports = {
|
|
||||||
|
|
||||||
|
run(rez) {
|
||||||
|
|
||||||
|
// This is what we'll return
|
||||||
|
const coverage = {
|
||||||
|
gaps: [],
|
||||||
|
overlaps: [],
|
||||||
|
pct: '0%',
|
||||||
|
duration: {
|
||||||
|
total: 0,
|
||||||
|
work: 0,
|
||||||
|
gaps: 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
moniker: 'gap-inspector',
|
// Missing employment section? Bye bye.
|
||||||
|
const hist = LO.get(rez, 'employment.history');
|
||||||
|
|
||||||
|
if (!hist || !hist.length) { return coverage; }
|
||||||
|
|
||||||
|
// Convert the candidate's employment history to an array of dates,
|
||||||
/**
|
// where each element in the array is a start date or an end date of a
|
||||||
Run the Gap Analyzer on a resume.
|
// job -- it doesn't matter which.
|
||||||
@method run
|
let new_e = hist.map( function( job ) {
|
||||||
@return An array of object representing gaps in the candidate's employment
|
let obj = _.pick( job, ['start', 'end'] );
|
||||||
history. Each object provides the start, end, and duration of the gap:
|
if (obj && (obj.start || obj.end)) {
|
||||||
{ <-- gap
|
obj = _.pairs( obj );
|
||||||
start: // A Moment.js date
|
obj[0][1] = FluentDate.fmt( obj[0][1] );
|
||||||
end: // A Moment.js date
|
if (obj.length > 1) {
|
||||||
duration: // Gap length
|
obj[1][1] = FluentDate.fmt( obj[1][1] );
|
||||||
}
|
|
||||||
*/
|
|
||||||
run: function( rez ) {
|
|
||||||
|
|
||||||
// This is what we'll return
|
|
||||||
var coverage = {
|
|
||||||
gaps: [],
|
|
||||||
overlaps: [],
|
|
||||||
duration: {
|
|
||||||
total: 0,
|
|
||||||
work: 0,
|
|
||||||
gaps: 0
|
|
||||||
},
|
|
||||||
pct: '0%'
|
|
||||||
};
|
|
||||||
|
|
||||||
// Missing employment section? Bye bye.
|
|
||||||
var hist = LO.get( rez, 'employment.history' );
|
|
||||||
if( !hist || !hist.length ) { return coverage; }
|
|
||||||
|
|
||||||
// Convert the candidate's employment history to an array of dates,
|
|
||||||
// where each element in the array is a start date or an end date of a
|
|
||||||
// job -- it doesn't matter which.
|
|
||||||
var new_e = hist.map( function( job ){
|
|
||||||
var obj = _.pick( job, ['start', 'end'] );
|
|
||||||
if( obj && (obj.start || obj.end)) {
|
|
||||||
obj = _.pairs( obj );
|
|
||||||
obj[0][1] = FluentDate.fmt( obj[0][1] );
|
|
||||||
if( obj.length > 1 )
|
|
||||||
obj[1][1] = FluentDate.fmt( obj[1][1] );
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Flatten the array, remove empties, and sort
|
|
||||||
new_e = _.filter( _.flatten( new_e, true ), function(v) {
|
|
||||||
return ( v && v.length && v[0] && v[0].length );
|
|
||||||
});
|
|
||||||
if( !new_e || !new_e.length ) return coverage;
|
|
||||||
new_e = _.sortBy( new_e, function( elem ) { return elem[1].unix(); });
|
|
||||||
|
|
||||||
// Iterate over elements in the array. Each time a start date is found,
|
|
||||||
// increment a reference count. Each time an end date is found, decrement
|
|
||||||
// the reference count. When the reference count reaches 0, we have a gap.
|
|
||||||
// When the reference count is > 0, the candidate is employed. When the
|
|
||||||
// reference count reaches 2, the candidate is overlapped.
|
|
||||||
|
|
||||||
var num_gaps = 0, ref_count = 0, total_gap_days = 0, total_work_days = 0
|
|
||||||
, gap_start;
|
|
||||||
|
|
||||||
new_e.forEach( function(point) {
|
|
||||||
var inc = point[0] === 'start' ? 1 : -1;
|
|
||||||
ref_count += inc;
|
|
||||||
if( ref_count === 0 ) {
|
|
||||||
coverage.gaps.push( { start: point[1], end: null });
|
|
||||||
}
|
|
||||||
else if( ref_count === 1 && inc === 1 ) {
|
|
||||||
var lastGap = _.last( coverage.gaps );
|
|
||||||
if( lastGap ) {
|
|
||||||
lastGap.end = point[1];
|
|
||||||
lastGap.duration = lastGap.end.diff( lastGap.start, 'days' );
|
|
||||||
total_gap_days += lastGap.duration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( ref_count === 2 && inc === 1 ) {
|
|
||||||
coverage.overlaps.push( { start: point[1], end: null });
|
|
||||||
}
|
|
||||||
else if( ref_count === 1 && inc === -1 ) {
|
|
||||||
var lastOver = _.last( coverage.overlaps );
|
|
||||||
if( lastOver ) {
|
|
||||||
lastOver.end = point[1];
|
|
||||||
lastOver.duration = lastOver.end.diff( lastOver.start, 'days' );
|
|
||||||
if( lastOver.duration === 0 ) {
|
|
||||||
coverage.overlaps.pop();
|
|
||||||
}
|
|
||||||
total_work_days += lastOver.duration;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// It's possible that the last overlap didn't have an explicit .end date.
|
|
||||||
// If so, set the end date to the present date and compute the overlap
|
|
||||||
// duration normally.
|
|
||||||
if( coverage.overlaps.length ) {
|
|
||||||
if( !_.last( coverage.overlaps ).end ) {
|
|
||||||
var l = _.last( coverage.overlaps );
|
|
||||||
l.end = moment();
|
|
||||||
l.duration = l.end.diff( l.start, 'days' );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return obj;
|
||||||
|
});
|
||||||
|
|
||||||
var dur = {
|
// Flatten the array, remove empties, and sort
|
||||||
total: rez.duration('days'),
|
new_e = _.filter(_.flatten( new_e, true ), v => v && v.length && v[0] && v[0].length);
|
||||||
work: total_work_days,
|
|
||||||
gaps: total_gap_days
|
|
||||||
};
|
|
||||||
coverage.pct = ( dur.total > 0 && dur.work > 0 ) ?
|
|
||||||
((((dur.total - dur.gaps) / dur.total) * 100)).toFixed(1) + '%' :
|
|
||||||
'???';
|
|
||||||
coverage.duration = dur;
|
|
||||||
|
|
||||||
return coverage;
|
if (!new_e || !new_e.length) { return coverage; }
|
||||||
|
new_e = _.sortBy(new_e, elem => elem[1].unix());
|
||||||
|
|
||||||
|
// Iterate over elements in the array. Each time a start date is found,
|
||||||
|
// increment a reference count. Each time an end date is found, decrement
|
||||||
|
// the reference count. When the reference count reaches 0, we have a gap.
|
||||||
|
// When the reference count is > 0, the candidate is employed. When the
|
||||||
|
// reference count reaches 2, the candidate is overlapped.
|
||||||
|
|
||||||
|
let ref_count = 0;
|
||||||
|
let total_gap_days = 0;
|
||||||
|
|
||||||
|
new_e.forEach(function(point) {
|
||||||
|
|
||||||
|
const inc = point[0] === 'start' ? 1 : -1;
|
||||||
|
ref_count += inc;
|
||||||
|
|
||||||
|
// If the ref count just reached 0, start a new GAP
|
||||||
|
if (ref_count === 0) {
|
||||||
|
return coverage.gaps.push( { start: point[1], end: null });
|
||||||
|
|
||||||
|
// If the ref count reached 1 by rising, end the last GAP
|
||||||
|
} else if ((ref_count === 1) && (inc === 1)) {
|
||||||
|
const lastGap = _.last( coverage.gaps );
|
||||||
|
if (lastGap) {
|
||||||
|
lastGap.end = point[1];
|
||||||
|
lastGap.duration = lastGap.end.diff( lastGap.start, 'days' );
|
||||||
|
return total_gap_days += lastGap.duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the ref count reaches 2 by rising, start a new OVERLAP
|
||||||
|
} else if ((ref_count === 2) && (inc === 1)) {
|
||||||
|
return coverage.overlaps.push( { start: point[1], end: null });
|
||||||
|
|
||||||
|
// If the ref count reaches 1 by falling, end the last OVERLAP
|
||||||
|
} else if ((ref_count === 1) && (inc === -1)) {
|
||||||
|
const lastOver = _.last( coverage.overlaps );
|
||||||
|
if (lastOver) {
|
||||||
|
lastOver.end = point[1];
|
||||||
|
lastOver.duration = lastOver.end.diff( lastOver.start, 'days' );
|
||||||
|
if (lastOver.duration === 0) {
|
||||||
|
return coverage.overlaps.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// It's possible that the last gap/overlap didn't have an explicit .end
|
||||||
|
// date.If so, set the end date to the present date and compute the
|
||||||
|
// duration normally.
|
||||||
|
if (coverage.overlaps.length) {
|
||||||
|
const o = _.last( coverage.overlaps );
|
||||||
|
if (o && !o.end) {
|
||||||
|
o.end = moment();
|
||||||
|
o.duration = o.end.diff( o.start, 'days' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (coverage.gaps.length) {
|
||||||
|
const g = _.last( coverage.gaps );
|
||||||
|
if (g && !g.end) {
|
||||||
|
g.end = moment();
|
||||||
|
g.duration = g.end.diff( g.start, 'days' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
// Package data for return to the client
|
||||||
|
const tdur = rez.duration('days');
|
||||||
|
const dur = {
|
||||||
|
total: tdur,
|
||||||
|
work: tdur - total_gap_days,
|
||||||
|
gaps: total_gap_days
|
||||||
|
};
|
||||||
|
|
||||||
|
coverage.pct = (dur.total > 0) && (dur.work > 0) ? ((((dur.total - dur.gaps) / dur.total) * 100)).toFixed(1) + '%' : '???';
|
||||||
|
coverage.duration = dur;
|
||||||
}());
|
return coverage;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -1,71 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Keyword analysis for HackMyResume.
|
Keyword analysis for HackMyResume.
|
||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module keyword-inspector.js
|
@module inspectors/keyword-inspector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
Analyze the resume's use of keywords.
|
||||||
|
TODO: BUG: Keyword search regex is inaccurate, especially for one or two
|
||||||
|
letter keywords like "C" or "CLI".
|
||||||
|
@class keywordInspector
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
/** A unique name for this inspector. */
|
||||||
(function() {
|
moniker: 'keyword-inspector',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
|
||||||
var FluentDate = require('../core/fluent-date');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Analyze the resume's use of keywords.
|
Run the Keyword Inspector on a resume.
|
||||||
@class keywordInspector
|
@method run
|
||||||
|
@return An collection of statistical keyword data.
|
||||||
*/
|
*/
|
||||||
var keywordInspector = module.exports = {
|
run( rez ) {
|
||||||
|
|
||||||
|
// "Quote" or safely escape a keyword so it can be used as a regex. For
|
||||||
|
// example, if the keyword is "C++", yield "C\+\+".
|
||||||
|
// http://stackoverflow.com/a/2593661/4942583
|
||||||
|
const regex_quote = str => (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, '\\$&');
|
||||||
|
|
||||||
|
// Create a searchable plain-text digest of the resume
|
||||||
|
// TODO: BUG: Don't search within keywords for other keywords. Job A
|
||||||
|
// declares the "foo" keyword. Job B declares the "foo & bar" keyword. Job
|
||||||
|
// B's mention of "foobar" should not count as a mention of "foo".
|
||||||
|
// To achieve this, remove keywords from the search digest and treat them
|
||||||
|
// separately.
|
||||||
|
let searchable = '';
|
||||||
|
rez.transformStrings(['imp', 'computed', 'safe'], ( key, val ) => searchable += ` ${val}`);
|
||||||
|
|
||||||
/**
|
// Assemble a regex skeleton we can use to test for keywords with a bit
|
||||||
A unique name for this inspector.
|
// more
|
||||||
*/
|
const prefix = `(?:${['^', '\\s+', '[\\.,]+'].join('|')})`;
|
||||||
moniker: 'keyword-inspector',
|
const suffix = `(?:${['$', '\\s+', '[\\.,]+'].join('|')})`;
|
||||||
|
|
||||||
|
return rez.keywords().map(function(kw) {
|
||||||
|
|
||||||
|
// 1. Using word boundary or other regex class is inaccurate
|
||||||
|
//
|
||||||
|
// var regex = new RegExp( '\\b' + regex_quote( kw )/* + '\\b'*/, 'ig');
|
||||||
|
//
|
||||||
|
// 2. Searching for the raw keyword is inaccurate ("C" will match any
|
||||||
|
// word containing a 'c'!).
|
||||||
|
//
|
||||||
|
// var regex = new RegExp( regex_quote( kw ), 'ig');
|
||||||
|
//
|
||||||
|
// 3. Instead, use a custom regex with special delimeters.
|
||||||
|
|
||||||
/**
|
const regex_str = prefix + regex_quote( kw ) + suffix;
|
||||||
Run the Keyword Inspector on a resume.
|
const regex = new RegExp( regex_str, 'ig');
|
||||||
@method run
|
let count = 0;
|
||||||
@return An collection of statistical keyword data.
|
while (regex.exec( searchable ) !== null) {
|
||||||
*/
|
count++;
|
||||||
run: function( rez ) {
|
|
||||||
|
|
||||||
// http://stackoverflow.com/a/2593661/4942583
|
|
||||||
function regex_quote(str) {
|
|
||||||
return (str + '').replace(/[.?*+^$[\]\\(){}|-]/ig, "\\$&");
|
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
var searchable = '';
|
name: kw,
|
||||||
rez.transformStrings( ['imp', 'computed', 'safe'], function trxString( key, val ) {
|
count
|
||||||
searchable += ' ' + val;
|
};
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return rez.keywords().map(function(kw) {
|
};
|
||||||
//var regex = new RegExp( '\\b' + regex_quote( kw )/* + '\\b'*/, 'ig');
|
|
||||||
var regex = new RegExp( regex_quote( kw ), 'ig');
|
|
||||||
var myArray, count = 0;
|
|
||||||
while ((myArray = regex.exec( searchable )) !== null) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
name: kw,
|
|
||||||
count: count
|
|
||||||
};
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
@ -1,59 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Section analysis for HackMyResume.
|
Section analysis for HackMyResume.
|
||||||
@license MIT. See LICENSE.md for details.
|
@license MIT. See LICENSE.md for details.
|
||||||
@module totals-inspector.js
|
@module inspectors/totals-inspector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
const _ = require('underscore');
|
||||||
|
|
||||||
|
/**
|
||||||
|
Retrieve sectional overview and summary information.
|
||||||
|
@class totalsInspector
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
(function() {
|
moniker: 'totals-inspector',
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
|
||||||
var FluentDate = require('../core/fluent-date');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Retrieve sectional overview and summary information.
|
Run the Totals Inspector on a resume.
|
||||||
@class totalsInspector
|
@method run
|
||||||
|
@return An object containing summary information for each section on the
|
||||||
|
resume.
|
||||||
*/
|
*/
|
||||||
var totalsInspector = module.exports = {
|
run( rez ) {
|
||||||
|
|
||||||
|
const sectionTotals = { };
|
||||||
|
_.each(rez, function(val, key) {
|
||||||
|
if (_.isArray( val ) && !_.isString(val)) {
|
||||||
|
return sectionTotals[ key ] = val.length;
|
||||||
|
} else if (val.history && _.isArray( val.history )) {
|
||||||
|
return sectionTotals[ key ] = val.history.length;
|
||||||
|
} else if (val.sets && _.isArray( val.sets )) {
|
||||||
|
return sectionTotals[ key ] = val.sets.length;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
moniker: 'totals-inspector',
|
totals: sectionTotals,
|
||||||
|
numSections: Object.keys( sectionTotals ).length
|
||||||
|
};
|
||||||
|
}
|
||||||
/**
|
};
|
||||||
Run the Totals Inspector on a resume.
|
|
||||||
@method run
|
|
||||||
@return An array of objects containing summary information for each section
|
|
||||||
on the resume.
|
|
||||||
*/
|
|
||||||
run: function( rez ) {
|
|
||||||
|
|
||||||
var ret = { };
|
|
||||||
_.each( rez, function(val, key){
|
|
||||||
if( _.isArray( val ) && !_.isString(val) ) {
|
|
||||||
ret[ key ] = val.length;
|
|
||||||
}
|
|
||||||
else if( val.history && _.isArray( val.history ) ) {
|
|
||||||
ret[ key ] = val.history.length;
|
|
||||||
}
|
|
||||||
else if( val.sets && _.isArray( val.sets ) ) {
|
|
||||||
ret[ key ] = val.sets.length;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
118
src/renderers/handlebars-generator.js
Normal file
118
src/renderers/handlebars-generator.js
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the HandlebarsGenerator class.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module renderers/handlebars-generator
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const _ = require('underscore');
|
||||||
|
const HANDLEBARS = require('handlebars');
|
||||||
|
const FS = require('fs');
|
||||||
|
const registerHelpers = require('../helpers/handlebars-helpers');
|
||||||
|
const PATH = require('path');
|
||||||
|
const parsePath = require('parse-filepath');
|
||||||
|
const READFILES = require('recursive-readdir-sync');
|
||||||
|
const HMSTATUS = require('../core/status-codes');
|
||||||
|
const SLASH = require('slash');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform template-based resume generation using Handlebars.js.
|
||||||
|
@class HandlebarsGenerator
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
generateSimple( data, tpl ) {
|
||||||
|
|
||||||
|
let template;
|
||||||
|
try {
|
||||||
|
// Compile and run the Handlebars template.
|
||||||
|
template = HANDLEBARS.compile(tpl, {
|
||||||
|
strict: false,
|
||||||
|
assumeObjects: false,
|
||||||
|
noEscape: data.opts.noescape
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return template(data);
|
||||||
|
} catch (err) {
|
||||||
|
throw{
|
||||||
|
fluenterror:
|
||||||
|
HMSTATUS[ template ? 'invokeTemplate' : 'compileTemplate' ],
|
||||||
|
inner: err
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
generate( json, jst, format, curFmt, opts, theme ) {
|
||||||
|
|
||||||
|
// Preprocess text
|
||||||
|
let encData = json;
|
||||||
|
if ((format === 'html') || (format === 'pdf')) {
|
||||||
|
encData = json.markdownify();
|
||||||
|
}
|
||||||
|
if( format === 'doc' ) {
|
||||||
|
encData = json.xmlify();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up partials and helpers
|
||||||
|
registerPartials(format, theme);
|
||||||
|
registerHelpers(theme, encData, opts);
|
||||||
|
|
||||||
|
// Set up the context
|
||||||
|
const ctx = {
|
||||||
|
r: encData,
|
||||||
|
RAW: json,
|
||||||
|
filt: opts.filters,
|
||||||
|
format,
|
||||||
|
opts,
|
||||||
|
engine: this,
|
||||||
|
results: curFmt.files,
|
||||||
|
headFragment: opts.headFragment || ''
|
||||||
|
};
|
||||||
|
|
||||||
|
// Render the template
|
||||||
|
return this.generateSimple(ctx, jst);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var registerPartials = function(format, theme) {
|
||||||
|
|
||||||
|
if (_.contains( ['html','doc','md','txt','pdf'], format )) {
|
||||||
|
|
||||||
|
// Locate the global partials folder
|
||||||
|
const partialsFolder = PATH.join(
|
||||||
|
parsePath( require.resolve('fresh-themes') ).dirname,
|
||||||
|
'/partials/',
|
||||||
|
format === 'pdf' ? 'html' : format
|
||||||
|
);
|
||||||
|
|
||||||
|
// Register global partials in the /partials/[format] folder
|
||||||
|
// TODO: Only do this once per HMR invocation.
|
||||||
|
_.each(READFILES( partialsFolder ), function( el ) {
|
||||||
|
const name = SLASH(PATH.relative( partialsFolder, el ).replace(/\.(?:html|xml|hbs|md|txt)$/i, ''));
|
||||||
|
const tplData = FS.readFileSync(el, 'utf8');
|
||||||
|
const compiledTemplate = HANDLEBARS.compile(tplData);
|
||||||
|
HANDLEBARS.registerPartial(name, compiledTemplate);
|
||||||
|
return theme.partialsInitialized = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register theme-specific partials
|
||||||
|
return _.each(theme.partials, function( el ) {
|
||||||
|
const tplData = FS.readFileSync(el.path, 'utf8');
|
||||||
|
const compiledTemplate = HANDLEBARS.compile(tplData);
|
||||||
|
return HANDLEBARS.registerPartial(el.name, compiledTemplate);
|
||||||
|
});
|
||||||
|
};
|
45
src/renderers/jrs-generator.js
Normal file
45
src/renderers/jrs-generator.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the JRSGenerator class.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module renderers/jrs-generator
|
||||||
|
*/
|
||||||
|
|
||||||
|
const MD = require('marked');
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform template-based resume generation for JSON Resume themes.
|
||||||
|
@class JRSGenerator
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
generate( json, jst, format, cssInfo, opts, theme ) {
|
||||||
|
|
||||||
|
// Disable JRS theme chatter (console.log, console.error, etc.)
|
||||||
|
const turnoff = ['log', 'error', 'dir'];
|
||||||
|
const org = turnoff.map(function(c) {
|
||||||
|
const ret = console[c]; // eslint-disable-line no-console
|
||||||
|
console[c] = function() {}; // eslint-disable-line no-console
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Freeze and render
|
||||||
|
let rezHtml = theme.render(json.harden());
|
||||||
|
|
||||||
|
// Turn logging back on
|
||||||
|
turnoff.forEach((c, idx) => console[c] = org[idx]); // eslint-disable-line no-console
|
||||||
|
|
||||||
|
// Unfreeze and apply Markdown
|
||||||
|
return rezHtml = rezHtml.replace(/@@@@~[\s\S]*?~@@@@/g, val => MDIN( val.replace( /~@@@@/g,'' ).replace( /@@@@~/g,'' ) ));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var MDIN = txt => // TODO: Move this
|
||||||
|
MD(txt || '' ).replace(/^\s*<p>|<\/p>\s*$/gi, '')
|
||||||
|
;
|
90
src/renderers/underscore-generator.js
Normal file
90
src/renderers/underscore-generator.js
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Definition of the UnderscoreGenerator class.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module underscore-generator.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const _ = require('underscore');
|
||||||
|
const registerHelpers = require('../helpers/underscore-helpers');
|
||||||
|
require('../utils/string');
|
||||||
|
const escapeLaTeX = require('escape-latex');
|
||||||
|
|
||||||
|
/**
|
||||||
|
Perform template-based resume generation using Underscore.js.
|
||||||
|
@class UnderscoreGenerator
|
||||||
|
*/
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
generateSimple( data, tpl ) {
|
||||||
|
let t;
|
||||||
|
try {
|
||||||
|
// Compile and run the Handlebars template.
|
||||||
|
t = _.template(tpl);
|
||||||
|
return t(data);
|
||||||
|
} catch (err) {
|
||||||
|
//console.dir _error
|
||||||
|
const HMS = require('../core/status-codes');
|
||||||
|
throw{
|
||||||
|
fluenterror: HMS[t ? 'invokeTemplate' : 'compileTemplate'],
|
||||||
|
inner: err
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
generate( json, jst, format, cssInfo, opts, theme ) {
|
||||||
|
|
||||||
|
// Tweak underscore's default template delimeters
|
||||||
|
let delims = (opts.themeObj && opts.themeObj.delimeters) || opts.template;
|
||||||
|
if (opts.themeObj && opts.themeObj.delimeters) {
|
||||||
|
delims = _.mapObject(delims, (val) => new RegExp(val, 'ig'));
|
||||||
|
}
|
||||||
|
_.templateSettings = delims;
|
||||||
|
|
||||||
|
// Massage resume strings / text
|
||||||
|
let r = null;
|
||||||
|
switch (format) {
|
||||||
|
case 'html': r = json.markdownify(); break;
|
||||||
|
case 'pdf': r = json.markdownify(); break;
|
||||||
|
case 'png': r = json.markdownify(); break;
|
||||||
|
case 'latex':
|
||||||
|
var traverse = require('traverse');
|
||||||
|
r = traverse(json).map(function() {
|
||||||
|
if (this.isLeaf && String.is(this.node)) {
|
||||||
|
return escapeLaTeX(this.node);
|
||||||
|
}
|
||||||
|
return this.node;
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default: r = json;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up the context
|
||||||
|
const ctx = {
|
||||||
|
r,
|
||||||
|
filt: opts.filters,
|
||||||
|
XML: require('xml-escape'),
|
||||||
|
RAW: json,
|
||||||
|
cssInfo,
|
||||||
|
//engine: @
|
||||||
|
headFragment: opts.headFragment || '',
|
||||||
|
opts
|
||||||
|
};
|
||||||
|
|
||||||
|
// Link to our helpers
|
||||||
|
registerHelpers(theme, opts, cssInfo, ctx, this);
|
||||||
|
|
||||||
|
// Generate!
|
||||||
|
return this.generateSimple(ctx, jst);
|
||||||
|
}
|
||||||
|
};
|
27
src/use.txt
27
src/use.txt
@ -1,27 +0,0 @@
|
|||||||
Usage:
|
|
||||||
|
|
||||||
hackmyresume <COMMAND> <SOURCES> [TO <TARGETS>] [-t <THEME>] [-f <FORMAT>]
|
|
||||||
|
|
||||||
<COMMAND> should be BUILD, NEW, CONVERT, VALIDATE, ANALYZE or HELP. <SOURCES>
|
|
||||||
should be the path to one or more FRESH or JSON Resume format resumes. <TARGETS>
|
|
||||||
should be the name of the destination resume to be created, if any. The <THEME>
|
|
||||||
parameter should be the name of a predefined theme (for example: COMPACT,
|
|
||||||
MINIMIST, MODERN, or HELLO-WORLD) or the relative path to a custom theme.
|
|
||||||
<FORMAT> should be either FRESH (for a FRESH-format resume) or JRS (for a JSON
|
|
||||||
Resume-format resume).
|
|
||||||
|
|
||||||
hackmyresume BUILD resume.json TO out/resume.all
|
|
||||||
hackmyresume NEW resume.json
|
|
||||||
hackmyresume CONVERT resume.json TO resume-jrs.json
|
|
||||||
hackmyresume ANALYZE resume.json
|
|
||||||
hackmyresume VALIDATE resume.json
|
|
||||||
|
|
||||||
Both SOURCES and TARGETS can accept multiple files:
|
|
||||||
|
|
||||||
hackmyresume BUILD r1.json r2.json TO out/resume.all out2/resume.html
|
|
||||||
hackmyresume NEW r1.json r2.json r3.json
|
|
||||||
hackmyresume ANALYZE r1.json r2.json r3.json
|
|
||||||
hackmyresume VALIDATE resume.json resume2.json resume3.json
|
|
||||||
|
|
||||||
See https://github.com/hacksalot/hackmyresume/blob/master/README.md for more
|
|
||||||
information.
|
|
@ -1,72 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of John Resig's `Class` class.
|
|
||||||
@module class.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Simple JavaScript Inheritance
|
|
||||||
* By John Resig http://ejohn.org/
|
|
||||||
* MIT Licensed.
|
|
||||||
* http://ejohn.org/blog/simple-javascript-inheritance/
|
|
||||||
*/
|
|
||||||
// Inspired by base2 and Prototype
|
|
||||||
(function(){
|
|
||||||
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
|
||||||
|
|
||||||
// The base Class implementation (does nothing)
|
|
||||||
this.Class = function(){};
|
|
||||||
module.exports = Class;
|
|
||||||
|
|
||||||
// Create a new Class that inherits from this class
|
|
||||||
Class.extend = function(prop) {
|
|
||||||
var _super = this.prototype;
|
|
||||||
|
|
||||||
// Instantiate a base class (but only create the instance,
|
|
||||||
// don't run the init constructor)
|
|
||||||
initializing = true;
|
|
||||||
var prototype = new this();
|
|
||||||
initializing = false;
|
|
||||||
|
|
||||||
// Copy the properties over onto the new prototype
|
|
||||||
for (var name in prop) {
|
|
||||||
// Check if we're overwriting an existing function
|
|
||||||
prototype[name] = typeof prop[name] == "function" &&
|
|
||||||
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
|
||||||
(function(name, fn){
|
|
||||||
return function() {
|
|
||||||
var tmp = this._super;
|
|
||||||
|
|
||||||
// Add a new ._super() method that is the same method
|
|
||||||
// but on the super-class
|
|
||||||
this._super = _super[name];
|
|
||||||
|
|
||||||
// The method only need to be bound temporarily, so we
|
|
||||||
// remove it when we're done executing
|
|
||||||
var ret = fn.apply(this, arguments);
|
|
||||||
this._super = tmp;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
})(name, prop[name]) : // jshint ignore:line
|
|
||||||
prop[name];
|
|
||||||
}
|
|
||||||
|
|
||||||
// The dummy class constructor
|
|
||||||
function Class() {
|
|
||||||
// All construction is actually done in the init method
|
|
||||||
if ( !initializing && this.init )
|
|
||||||
this.init.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate our constructed prototype object
|
|
||||||
Class.prototype = prototype;
|
|
||||||
|
|
||||||
// Enforce the constructor to be what we expect
|
|
||||||
Class.prototype.constructor = Class;
|
|
||||||
|
|
||||||
// And make this class extendable
|
|
||||||
Class.extend = arguments.callee;
|
|
||||||
|
|
||||||
return Class;
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
|
@ -1,79 +0,0 @@
|
|||||||
/**
|
|
||||||
Definition of the `extend` method.
|
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
|
||||||
@module extend.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
function _extend() {
|
|
||||||
|
|
||||||
function isPlainObject( obj ) {
|
|
||||||
if ((typeof obj !== "object") || obj.nodeType ||
|
|
||||||
(obj !== null && obj === obj.window)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (obj.constructor &&
|
|
||||||
!hasOwnProperty.call( obj.constructor.prototype, "isPrototypeOf" )) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var options
|
|
||||||
, name
|
|
||||||
, src
|
|
||||||
, copy
|
|
||||||
, copyIsArray
|
|
||||||
, clone
|
|
||||||
, target = arguments[0] || {}
|
|
||||||
, i = 1
|
|
||||||
, length = arguments.length
|
|
||||||
, deep = false;
|
|
||||||
|
|
||||||
// Handle a deep copy situation
|
|
||||||
if (typeof target === "boolean") {
|
|
||||||
deep = target;
|
|
||||||
// Skip the boolean and the target
|
|
||||||
target = arguments[i] || {};
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle case when target is a string or something (possible in deep copy)
|
|
||||||
//if (typeof target !== "object" && !jQuery.isFunction(target))
|
|
||||||
if (typeof target !== "object" && typeof target !== "function")
|
|
||||||
target = {};
|
|
||||||
|
|
||||||
for (; i < length; i++) {
|
|
||||||
// Only deal with non-null/undefined values
|
|
||||||
if ((options = arguments[i]) !== null) {
|
|
||||||
// Extend the base object
|
|
||||||
for (name in options) {
|
|
||||||
src = target[name];
|
|
||||||
copy = options[name];
|
|
||||||
|
|
||||||
// Prevent never-ending loop
|
|
||||||
if (target === copy) continue;
|
|
||||||
|
|
||||||
// Recurse if we're merging plain objects or arrays
|
|
||||||
if (deep && copy && (isPlainObject(copy) ||
|
|
||||||
(copyIsArray = (copy.constructor === Array)))) {
|
|
||||||
if (copyIsArray) {
|
|
||||||
copyIsArray = false;
|
|
||||||
clone = src && (src.constructor === Array) ? src : [];
|
|
||||||
} else {
|
|
||||||
clone = src && isPlainObject(src) ? src : {};
|
|
||||||
}
|
|
||||||
// Never move original objects, clone them
|
|
||||||
target[name] = _extend(deep, clone, copy);
|
|
||||||
// Don't bring in undefined values
|
|
||||||
} else if (copy !== undefined) {
|
|
||||||
target[name] = copy;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the modified object
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = _extend;
|
|
@ -1,12 +1,11 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the SyntaxErrorEx class.
|
Definition of the SyntaxErrorEx class.
|
||||||
@module file-contains.js
|
@module file-contains.js
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function(){
|
module.exports = ( file, needle ) => require('fs').readFileSync(file,'utf-8').indexOf( needle ) > -1;
|
||||||
|
|
||||||
module.exports = function( file, needle ) {
|
|
||||||
return require('fs').readFileSync(file,'utf-8').indexOf( needle ) > -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
27
src/utils/fresh-version-regex.js
Normal file
27
src/utils/fresh-version-regex.js
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Defines a regex suitable for matching FRESH versions.
|
||||||
|
@module file-contains.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Set up a regex that matches all of the following:
|
||||||
|
//
|
||||||
|
// - FRESH
|
||||||
|
// - JRS
|
||||||
|
// - FRESCA
|
||||||
|
// - FRESH@1.0.0
|
||||||
|
// - FRESH@1.0
|
||||||
|
// - FRESH@1
|
||||||
|
// - JRS@0.16.0
|
||||||
|
// - JRS@0.16
|
||||||
|
// - JRS@0
|
||||||
|
//
|
||||||
|
// Don't use a SEMVER regex (eg, NPM's semver-regex) because a) we want to
|
||||||
|
// support partial semvers like "0" or "1.2" and b) we'll expand this later to
|
||||||
|
// support fully scoped FRESH versions.
|
||||||
|
|
||||||
|
module.exports = () => RegExp('^(FRESH|FRESCA|JRS)(?:@(\\d+(?:\\.\\d+)?(?:\\.\\d+)?))?$');
|
@ -1,66 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
/**
|
/**
|
||||||
Definition of the Markdown to WordProcessingML conversion routine.
|
Definition of the Markdown to WordProcessingML conversion routine.
|
||||||
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
@license MIT. Copyright (c) 2015 James Devlin / FluentDesk.
|
||||||
@module html-to-wpml.js
|
@module utils/html-to-wpml
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function(){
|
|
||||||
|
|
||||||
var _ = require('underscore');
|
const XML = require('xml-escape');
|
||||||
var HTML5Tokenizer = require('simple-html-tokenizer');
|
const _ = require('underscore');
|
||||||
|
const HTML5Tokenizer = require('simple-html-tokenizer');
|
||||||
|
|
||||||
module.exports = function( html ) {
|
module.exports = function( html ) {
|
||||||
|
|
||||||
// Tokenize the HTML stream.
|
// Tokenize the HTML stream.
|
||||||
var tokens = HTML5Tokenizer.tokenize( html );
|
let is_bold, is_italic, is_link, link_url;
|
||||||
|
const tokens = HTML5Tokenizer.tokenize( html );
|
||||||
|
let final = (is_bold = (is_italic = (is_link = (link_url = ''))));
|
||||||
|
|
||||||
var final = '', is_bold, is_italic, is_link, link_url;
|
// Process <em>, <strong>, and <a> elements in the HTML stream, producing
|
||||||
|
// equivalent WordProcessingML that can be dumped into a <w:p> or other
|
||||||
|
// text container element.
|
||||||
|
_.each(tokens, function( tok ) {
|
||||||
|
|
||||||
// Process <em>, <strong>, and <a> elements in the HTML stream, producing
|
switch (tok.type) {
|
||||||
// equivalent WordProcessingML that can be dumped into a <w:p> or other
|
|
||||||
// text container element.
|
|
||||||
_.each( tokens, function( tok ) {
|
|
||||||
|
|
||||||
switch( tok.type ) {
|
case 'StartTag':
|
||||||
|
switch (tok.tagName) {
|
||||||
|
case 'p': return final += '<w:p>';
|
||||||
|
case 'strong': return is_bold = true;
|
||||||
|
case 'em': return is_italic = true;
|
||||||
|
case 'a':
|
||||||
|
is_link = true;
|
||||||
|
return link_url = tok.attributes.filter(attr => attr[0] === 'href')[0][1];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 'StartTag':
|
case 'EndTag':
|
||||||
switch( tok.tagName ) {
|
switch (tok.tagName) {
|
||||||
case 'p': final += '<w:p>'; break;
|
case 'p': return final += '</w:p>';
|
||||||
case 'strong': is_bold = true; break;
|
case 'strong': return is_bold = false;
|
||||||
case 'em': is_italic = true; break;
|
case 'em': return is_italic = false;
|
||||||
case 'a':
|
case 'a': return is_link = false;
|
||||||
is_link = true;
|
}
|
||||||
link_url = tok.attributes.filter(function(attr){
|
break;
|
||||||
return attr[0] === 'href'; }
|
|
||||||
)[0][1];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'EndTag':
|
case 'Chars':
|
||||||
switch( tok.tagName ) {
|
if( tok.chars.trim().length ) {
|
||||||
case 'p': final += '</w:p>'; break;
|
let style = is_bold ? '<w:b/>' : '';
|
||||||
case 'strong': is_bold = false; break;
|
style += is_italic ? '<w:i/>' : '';
|
||||||
case 'em': is_italic = false; break;
|
|
||||||
case 'a': is_link = false; break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'Chars':
|
|
||||||
if( tok.chars.trim().length ) {
|
|
||||||
var style = is_bold ? '<w:b/>' : '';
|
|
||||||
style += is_italic ? '<w:i/>': '';
|
|
||||||
style += is_link ? '<w:rStyle w:val="Hyperlink"/>' : '';
|
style += is_link ? '<w:rStyle w:val="Hyperlink"/>' : '';
|
||||||
final +=
|
return final +=
|
||||||
(is_link ? ('<w:hlink w:dest="' + link_url + '">') : '') +
|
(is_link ? (`<w:hlink w:dest="${link_url}">`) : '') +
|
||||||
'<w:r><w:rPr>' + style + '</w:rPr><w:t>' + tok.chars +
|
'<w:r><w:rPr>' + style + '</w:rPr><w:t>' + XML(tok.chars) +
|
||||||
'</w:t></w:r>' + (is_link ? '</w:hlink>' : '');
|
'</w:t></w:r>' + (is_link ? '</w:hlink>' : '');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return final;
|
return final;
|
||||||
|
};
|
||||||
};
|
|
||||||
|
|
||||||
}());
|
|
||||||
|
20
src/utils/md2chalk.js
Normal file
20
src/utils/md2chalk.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* decaffeinate suggestions:
|
||||||
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
Inline Markdown-to-Chalk conversion routines.
|
||||||
|
@license MIT. See LICENSE.md for details.
|
||||||
|
@module utils/md2chalk
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
const CHALK = require('chalk');
|
||||||
|
const LO = require('lodash');
|
||||||
|
|
||||||
|
module.exports = function( v, style, boldStyle ) {
|
||||||
|
boldStyle = boldStyle || 'bold';
|
||||||
|
const temp = v.replace(/\*\*(.*?)\*\*/g, LO.get( CHALK, boldStyle )('$1'));
|
||||||
|
if (style) { return LO.get( CHALK, style )(temp); } else { return temp; }
|
||||||
|
};
|
84
src/utils/rasterize.js
Normal file
84
src/utils/rasterize.js
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
(function() {
|
||||||
|
// Exemplar script for generating documents with Phantom.js.
|
||||||
|
// https://raw.githubusercontent.com/ariya/phantomjs/master/examples/rasterize.js
|
||||||
|
// Converted to CoffeeScript by hacksalot
|
||||||
|
"use strict";
|
||||||
|
var address, output, page, pageHeight, pageWidth, size, system;
|
||||||
|
|
||||||
|
page = require('webpage').create();
|
||||||
|
|
||||||
|
system = require('system');
|
||||||
|
|
||||||
|
address = output = size = null;
|
||||||
|
|
||||||
|
if (system.args.length < 3 || system.args.length > 5) {
|
||||||
|
console.log('Usage: rasterize.js URL filename [paperwidth*paperheight|paperformat] [zoom]');
|
||||||
|
console.log(' paper (pdf output) examples: "5in*7.5in", "10cm*20cm", "A4", "Letter"');
|
||||||
|
console.log(' image (png/jpg output) examples: "1920px" entire page, window width 1920px');
|
||||||
|
console.log(' "800px*600px" window, clipped to 800x600');
|
||||||
|
phantom.exit(1);
|
||||||
|
} else {
|
||||||
|
address = system.args[1];
|
||||||
|
output = system.args[2];
|
||||||
|
page.viewportSize = {
|
||||||
|
width: 600,
|
||||||
|
height: 600
|
||||||
|
};
|
||||||
|
if (system.args.length > 3 && system.args[2].substr(-4) === ".pdf") {
|
||||||
|
size = system.args[3].split('*');
|
||||||
|
page.paperSize = size.length === 2 ? {
|
||||||
|
width: size[0],
|
||||||
|
height: size[1],
|
||||||
|
margin: '0px'
|
||||||
|
} : {
|
||||||
|
format: system.args[3],
|
||||||
|
orientation: 'portrait',
|
||||||
|
margin: '1cm'
|
||||||
|
};
|
||||||
|
} else if (system.args.length > 3 && system.args[3].substr(-2) === "px") {
|
||||||
|
size = system.args[3].split('*');
|
||||||
|
if (size.length === 2) {
|
||||||
|
pageWidth = parseInt(size[0], 10);
|
||||||
|
pageHeight = parseInt(size[1], 10);
|
||||||
|
page.viewportSize = {
|
||||||
|
width: pageWidth,
|
||||||
|
height: pageHeight
|
||||||
|
};
|
||||||
|
page.clipRect = {
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: pageWidth,
|
||||||
|
height: pageHeight
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
console.log("size:", system.args[3]);
|
||||||
|
pageWidth = parseInt(system.args[3], 10);
|
||||||
|
pageHeight = parseInt(pageWidth * 3 / 4, 10); // it's as good an assumption as any
|
||||||
|
console.log("pageHeight:", pageHeight);
|
||||||
|
page.viewportSize = {
|
||||||
|
width: pageWidth,
|
||||||
|
height: pageHeight
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (system.args.length > 4) {
|
||||||
|
page.zoomFactor = system.args[4];
|
||||||
|
}
|
||||||
|
page.open(address, function(status) {
|
||||||
|
if (status !== 'success') {
|
||||||
|
console.log('Unable to load the address!');
|
||||||
|
phantom.exit(1);
|
||||||
|
} else {
|
||||||
|
return window.setTimeout(function() {
|
||||||
|
page.render(output);
|
||||||
|
phantom.exit();
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
|
|
||||||
|
/* eslint-enable */
|
||||||
|
//# sourceMappingURL=rasterize.js.map
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user