├── .gitignore
├── .pre-commit-config.yaml
├── Cargo.toml
├── LICENSE
├── README.md
├── examples
├── coruscant_de.html
├── coruscant_de.pdf
├── coruscant_en.html
├── coruscant_en.pdf
├── kirk.jpg
├── kirk_resume_de.yaml
└── kirk_resume_en.yaml
├── git-conventional-commits.json
└── src
├── io
├── load_json_resume.rs
├── mod.rs
├── resolve_image_path.rs
└── save_to_pdf.rs
├── main.rs
└── templates
├── coruscant
├── basics
│ ├── basics_box.rs
│ ├── contact_info
│ │ ├── contact_info_wrapper.rs
│ │ ├── icons
│ │ │ ├── address.svg
│ │ │ ├── email.svg
│ │ │ └── phone.svg
│ │ ├── index.html
│ │ └── mod.rs
│ ├── index.html
│ ├── languages
│ │ ├── index.html
│ │ ├── language_wrapper.rs
│ │ └── mod.rs
│ ├── mod.rs
│ └── skills
│ │ ├── index.html
│ │ ├── mod.rs
│ │ └── skills_wrapper.rs
├── data_model
│ ├── basics.rs
│ ├── education.rs
│ ├── language.rs
│ ├── location.rs
│ ├── mod.rs
│ ├── publication.rs
│ ├── supported_resume_data.rs
│ ├── utils.rs
│ └── work.rs
├── education
│ ├── education_wrapper.rs
│ ├── index.html
│ └── mod.rs
├── index.html
├── mod.rs
├── publication
│ ├── index.html
│ ├── mod.rs
│ └── publication_wrapper.rs
├── shared
│ ├── entry.rs
│ ├── index.html
│ ├── mod.rs
│ └── render_template.rs
├── style.css
├── supported_languages.rs
├── template.rs
└── work
│ ├── index.html
│ ├── mod.rs
│ └── work_wrapper.rs
├── mod.rs
└── template.rs
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | debug/
4 | target/
5 |
6 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
7 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
8 | Cargo.lock
9 |
10 | # These are backup files generated by rustfmt
11 | **/*.rs.bk
12 |
13 | # MSVC Windows builds of rustc generate these, which store debugging information
14 | *.pdb
15 |
16 | # RustRover
17 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
18 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
19 | # and can be added to the global gitignore or merged into this file. For a more nuclear
20 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
21 | #.idea/
22 |
23 | # Added by cargo
24 | /target
25 |
26 | # MacOS
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 | .DocumentRevisions-V100
31 | .fseventsd
32 | .Spotlight-V100
33 | .TemporaryItems
34 | .Trashes
35 | .VolumeIcon.icns
36 | .com.apple.timemachine.donotpresent
37 |
38 | # Visual Studio Code
39 | .vscode/*
40 |
41 | # Sandbox directory for all files that should stay private
42 | playground/
43 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | default_install_hook_types: [commit-msg, pre-commit]
2 | default_stages: [commit, merge-commit]
3 | minimum_pre_commit_version: 3.2.0
4 | repos:
5 | - repo: https://github.com/pre-commit/pre-commit-hooks
6 | rev: v4.5.0
7 | hooks:
8 | - id: check-added-large-files
9 | - id: check-ast
10 | - id: check-builtin-literals
11 | - id: check-case-conflict
12 | - id: check-executables-have-shebangs
13 | - id: check-json
14 | - id: check-merge-conflict
15 | - id: check-shebang-scripts-are-executable
16 | - id: check-symlinks
17 | - id: check-toml
18 | - id: check-vcs-permalinks
19 | - id: check-xml
20 | - id: check-yaml
21 | - id: debug-statements
22 | - id: destroyed-symlinks
23 |
24 | - repo: https://github.com/doublify/pre-commit-rust
25 | rev: master
26 | hooks:
27 | - id: fmt
28 | name: cargo fmt
29 | - id: clippy
30 | name: cargo clippy
31 |
32 | - repo: local
33 | hooks:
34 | - id: cargo-test
35 | name: cargo test
36 | description: Run tests
37 | entry: cargo test
38 | language: system
39 | pass_filenames: false
40 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "rsume"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | [dependencies]
7 | clap = { version = "4.5.18", features = ["derive"] }
8 | headless_chrome = "1.0.15"
9 | json-resume = "0.2.0"
10 | minijinja = "2.3.1"
11 | serde = "1.0.210"
12 | serde_json = "1.0.128"
13 | serde_yaml = "0.9.34"
14 | tempfile = "3.12.0"
15 |
16 | [profile.release]
17 | lto = true
18 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # rsume
2 | A tool for effortlessly generating resumes.
3 |
4 | ## Elevator Pitch
5 | The hiring process as a software developer can be super tedious. You never hear back from the majority of companies you have applied to and if they reach out, you have to jump through a lot of hoops to land the job. Since it is recommended to customize your resume for every single application, it may mean that you have to create dozens of resume before finally getting hired. Who has time for that? This tool is here to simplify the process by generating a high-quality resume with minimal work required.
6 |
7 | ## Getting started
8 | Currently, the only supported method for installing this program is by downloading or cloning this repo and building the binary yourself using `cargo` or `rustc`.
9 |
10 | An instance of Google Chrome or Chromedriver is required for executing the program.
11 |
12 | ## Usage
13 | `rsume`should be used from the command line like this:
14 | ```bash
15 | rsume /path/to/resume_data.yaml /target/path.pdf --template "coruscant" --language "english"
16 | ```
17 | The `--template` and `--language` options are optional.
18 |
19 | The resume data should follow the [JSONResume](https://jsonresume.org/) schema and can either be stored as a `.json` or `.yaml` file. Look at [examples/kirk_resume_en.yaml](https://github.com/unexcellent/rsume/blob/main/examples/kirk_resume_en.yaml).
20 |
21 | ## Known Issues
22 | Currently, only a single template is available. In the future more template are planned.
23 | - If the content of the resume is short enough that only one page is filled, an empty second page is generated regardless
24 | - Page breaks in the coruscant template may separate the section title (like "Education") from the first entry
--------------------------------------------------------------------------------
/examples/coruscant_de.html:
--------------------------------------------------------------------------------
1 |
2 |
454 | Lieutenant Commander and first officer.
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 | Jan 2259
466 |
467 |
468 |
469 |
470 |
471 | Dec 2254
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 | U.S.S Farragut NCC-1647
482 |
483 |
484 | Junior Officer
485 |
486 |
487 |
Commanding planetary survey parties
488 |
489 |
490 |
Participation in Klingon war
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 | Nov 2254
502 |
503 |
504 |
505 |
506 |
507 | Dec 2252
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 | U.S.S Republic NCC-1371
518 |
519 |
520 | Cadet
521 |
522 |
523 |
Nuclear incident handling
524 |
525 |
526 |
Promotion priority adjustment
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 | Education
536 |
537 |
538 |
539 |
540 |
541 | Nov 2254
542 |
543 |
544 |
545 |
546 |
547 | Jan 2252
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 | Starfleet Academy
558 |
559 |
560 | Master in Starship Operations
561 |
562 |
563 |
566 |
567 |
568 |
569 |
570 |
571 | Publications
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 | Jul 2260
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 | A Comparative Analysis of Starship Propulsion Systems
594 |
595 |
596 | This paper compares the efficiency, speed, and safety of various starship propulsion systems, such as warp drives and impulse engines. It also explores the potential for future advancements in propulsion technology.
597 |
598 |
599 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
--------------------------------------------------------------------------------
/examples/coruscant_en.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unexcellent/rsume/209479bf95a129d20bf12e497b5d26fedf2e5695/examples/coruscant_en.pdf
--------------------------------------------------------------------------------
/examples/kirk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/unexcellent/rsume/209479bf95a129d20bf12e497b5d26fedf2e5695/examples/kirk.jpg
--------------------------------------------------------------------------------
/examples/kirk_resume_de.yaml:
--------------------------------------------------------------------------------
1 | basics:
2 | name: James T. Kirk
3 | label: Starfleet Captain
4 | image: kirk.jpg
5 | email: kirk@starfleet.int
6 | phone: 1-919-271-0076
7 | location:
8 | address: 1234 Sunny Ave.
9 | postalCode: 52327
10 | city: Riverside
11 | countryCode: IA
12 |
13 | languages:
14 | - language: EN
15 | fluency: C2
16 | - language: DE
17 | fluency: B1
18 | - language: KL
19 | fluency: A2
20 |
21 | skills:
22 | - name: Raumschiffe Kommandieren
23 | - name: Crewmitglieder Managen
24 | - name: Interplanetäre Kriegsführung
25 | - name: MS Excel
26 | - name: Schießen
27 | - name: Diplotie
28 |
29 | work:
30 | - name: U.S.S Enterprise NCC-1701
31 | description: Kapitän
32 | startDate: Jul 2265
33 | endDate: Fortlaufend
34 | highlights:
35 | - Historische 5 jährige Mission
36 | - Entdeckung von Methoden fürs Zeitreisen
37 | - Auseinandersetzungen mit den Klingonen und Romulanern
38 |
39 | education:
40 | - institution: Starfleet Academie
41 | startDate: Jan 2252
42 | endDate: Nov 2254
43 | studyType: Meister
44 | area: Raumschiffsbetrieb
45 |
--------------------------------------------------------------------------------
/examples/kirk_resume_en.yaml:
--------------------------------------------------------------------------------
1 | basics:
2 | name: James T. Kirk
3 | label: Starfleet Captain
4 | image: kirk.jpg
5 | email: kirk@starfleet.int
6 | phone: 1-919-271-0076
7 | location:
8 | address: 1234 Sunny Ave.
9 | postalCode: 52327
10 | city: Riverside
11 | countryCode: IA
12 |
13 | languages:
14 | - language: EN
15 | fluency: C2
16 | - language: KL
17 | fluency: A2
18 |
19 | skills:
20 | - name: Commanding Starfleet Ships
21 | - name: Managing Crew
22 | - name: Interplanetary Tactical Warfare
23 | - name: MS Excel
24 | - name: Shooting
25 | - name: Diplomacy
26 |
27 | work:
28 | - name: U.S.S Enterprise NCC-1701
29 | description: Commanding officer
30 | startDate: Jul 2265
31 | endDate: Present
32 | highlights:
33 | - Historic five year mission
34 | - Discovery of replicable means of time travel
35 | - Conflicts with the Klingon and Romulan Empires
36 |
37 | - name: U.S.S Farragut NCC-1647
38 | description: Lieutenant Commander and first officer.
39 | startDate: Feb 2259
40 | endDate: Jun 2265
41 |
42 | - name: U.S.S Farragut NCC-1647
43 | description: Junior Officer
44 | startDate: Dec 2254
45 | endDate: Jan 2259
46 | highlights:
47 | - Commanding planetary survey parties
48 | - Participation in Klingon war
49 |
50 | - name: U.S.S Republic NCC-1371
51 | description: Cadet
52 | startDate: Dec 2252
53 | endDate: Nov 2254
54 | highlights:
55 | - Nuclear incident handling
56 | - Promotion priority adjustment
57 |
58 | education:
59 | - institution: Starfleet Academy
60 | startDate: Jan 2252
61 | endDate: Nov 2254
62 | studyType: "Master"
63 | area: "Starship Operations"
64 | score: 87/100
65 |
66 | publications:
67 | - name: A Comparative Analysis of Starship Propulsion Systems
68 | publisher: IESDGE
69 | releaseDate: Jul 2260
70 | url: iesdge.starfleet.int/papers/kirk-crisis-management
71 | summary: This paper compares the efficiency, speed, and safety of various starship propulsion systems, such as warp drives and impulse engines. It also explores the potential for future advancements in propulsion technology.
72 |
--------------------------------------------------------------------------------
/git-conventional-commits.json:
--------------------------------------------------------------------------------
1 | {
2 | "convention" : {
3 | "commitTypes": [
4 | "build",
5 | "chore",
6 | "ci",
7 | "docs",
8 | "feat",
9 | "fix",
10 | "merge",
11 | "perf",
12 | "refactor",
13 | "revert",
14 | "test",
15 |
16 | "lint",
17 | "style"
18 | ],
19 | "commitScopes": []
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/io/load_json_resume.rs:
--------------------------------------------------------------------------------
1 | use std::{error::Error, fs, path::PathBuf};
2 |
3 | /// Try to load the contents of a JSONResume file into a struct. The file can either be of type .json or .yaml.
4 | pub fn load_json_resume(path: &PathBuf) -> Result> {
5 | let contents = fs::read_to_string(path)?;
6 | let resume_data = match path.extension().unwrap().to_str() {
7 | Some("json") => serde_json::from_str(&contents)?,
8 | Some("yaml") | Some("yml") => serde_yaml::from_str(&contents)?,
9 | _ => Err(format!(
10 | "Unsupported file extension: {:?}",
11 | path.extension()
12 | ))?,
13 | };
14 |
15 | Ok(resume_data)
16 | }
17 |
18 | #[cfg(test)]
19 | pub mod tests {
20 | use super::*;
21 | use tempfile::TempDir;
22 |
23 | #[test]
24 | fn json() {
25 | let contents = "
26 | {
27 | \"basics\": {
28 | \"name\": \"Kirk\"
29 | }
30 | }
31 | ";
32 |
33 | let tmp_dir = TempDir::new().unwrap();
34 | let file_path = tmp_dir.path().join("resume.json");
35 | fs::write(&file_path, contents).unwrap();
36 |
37 | let resume_data = load_json_resume(&file_path).unwrap();
38 | assert_eq!(resume_data.basics.unwrap().name, Some("Kirk".to_string()));
39 | }
40 |
41 | #[test]
42 | fn yaml() {
43 | let contents = "
44 | basics:
45 | name: Kirk
46 | ";
47 |
48 | let tmp_dir = TempDir::new().unwrap();
49 | let file_path = tmp_dir.path().join("resume.yaml");
50 | fs::write(&file_path, contents).unwrap();
51 |
52 | let resume_data = load_json_resume(&file_path).unwrap();
53 | assert_eq!(resume_data.basics.unwrap().name, Some("Kirk".to_string()));
54 | }
55 |
56 | #[test]
57 | fn unsupported_type() {
58 | let contents = "";
59 |
60 | let tmp_dir = TempDir::new().unwrap();
61 | let file_path = tmp_dir.path().join("resume.UNSUPPORTED");
62 | fs::write(&file_path, contents).unwrap();
63 |
64 | let resume_data = load_json_resume(&file_path);
65 | assert!(resume_data.is_err());
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/io/mod.rs:
--------------------------------------------------------------------------------
1 | pub mod load_json_resume;
2 | pub mod resolve_image_path;
3 | pub mod save_to_pdf;
4 |
--------------------------------------------------------------------------------
/src/io/resolve_image_path.rs:
--------------------------------------------------------------------------------
1 | use std::{fs, path::Path};
2 |
3 | /// Image paths can either be given as absolute or relative paths from the JSONResume file. This function resolves relative paths.
4 | pub fn resolve_image_path(resume_data_path: &Path, image_path: &Option) -> Option {
5 | image_path.as_ref().map(|img_path| {
6 | fs::canonicalize(resume_data_path.parent().unwrap().join(img_path))
7 | .unwrap()
8 | .to_str()
9 | .unwrap()
10 | .to_string()
11 | })
12 | }
13 |
14 | #[cfg(test)]
15 | pub mod tests {
16 | use tempfile::TempDir;
17 |
18 | use super::*;
19 | use std::path::PathBuf;
20 |
21 | #[test]
22 | fn none() {
23 | let resume_data_path = PathBuf::from("/path/to/some/resume.json");
24 | let image_path = None;
25 |
26 | let actual = resolve_image_path(&resume_data_path, &image_path);
27 | assert_eq!(actual, None)
28 | }
29 |
30 | #[test]
31 | fn same_folder() {
32 | let tmp_dir = TempDir::new().unwrap();
33 | let resume_data_path = tmp_dir.path().join("resume.json");
34 | let image_path = Some("profile.png".to_string());
35 |
36 | fs::write(&resume_data_path, "").unwrap();
37 | fs::write(tmp_dir.path().join("profile.png"), "").unwrap();
38 |
39 | let actual = resolve_image_path(&resume_data_path, &image_path);
40 | assert!(PathBuf::from(actual.unwrap()).is_file())
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/io/save_to_pdf.rs:
--------------------------------------------------------------------------------
1 | use std::{error::Error, fs, path::PathBuf};
2 |
3 | use headless_chrome::{types::PrintToPdfOptions, Browser};
4 | use tempfile::TempDir;
5 |
6 | /// Save the resume design into a PDF.
7 | pub fn save_to_pdf(html_resume: String, target_path: &PathBuf) -> Result<(), Box> {
8 | let tmp_dir = TempDir::new()?;
9 | let tmp_storage_path = tmp_dir.path().join("resume.html");
10 | fs::write(&tmp_storage_path, html_resume)?;
11 |
12 | let browser = Browser::default()?;
13 | let tab = browser.new_tab()?;
14 | let pdf = tab
15 | .navigate_to(&format!("file://{}", tmp_storage_path.to_str().unwrap()))?
16 | .wait_until_navigated()?
17 | .print_to_pdf(Some(PrintToPdfOptions {
18 | margin_bottom: Some(0.0),
19 | margin_top: Some(0.0),
20 | margin_left: Some(0.0),
21 | margin_right: Some(0.0),
22 | print_background: Some(true),
23 | ..PrintToPdfOptions::default()
24 | }))?;
25 |
26 | fs::write(target_path, pdf)?;
27 |
28 | Ok(())
29 | }
30 |
31 | #[cfg(test)]
32 | pub mod tests {
33 |
34 | use super::*;
35 |
36 | #[test]
37 | fn file_is_written() {
38 | let html_resume = "
39 |
40 |
41 |
42 |
43 | ";
44 |
45 | let tmp_dir = TempDir::new().unwrap();
46 | let target_path = tmp_dir.path().join("resume.pdf");
47 |
48 | let result = save_to_pdf(html_resume.to_string(), &target_path);
49 | assert!(result.is_ok());
50 | assert!(target_path.is_file());
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | mod io;
2 | mod templates;
3 |
4 | use std::error::Error;
5 | use std::path::PathBuf;
6 |
7 | use crate::io::load_json_resume::load_json_resume;
8 | use crate::io::resolve_image_path::resolve_image_path;
9 | use crate::io::save_to_pdf::save_to_pdf;
10 | use crate::templates::Coruscant;
11 | use clap::Parser;
12 | use templates::template::Template;
13 |
14 | /// Program for generating a resume from JSONResume data.
15 | #[derive(Parser, Debug)]
16 | #[command(version, about, long_about = None)]
17 | pub struct Args {
18 | /// Path to the data describing your resume. It needs to comply with theJSONResume schema (see https://jsonresume.org/).
19 | resume_data_path: PathBuf,
20 |
21 | /// Location where the generated PDF should be stored.
22 | target_path: PathBuf,
23 |
24 | /// Template that should be used. Currently, the only available option is 'coruscant'. Default is 'coruscant'.
25 | #[arg(short, long)]
26 | template: Option,
27 |
28 | /// Language of the template. Available options are 'english' and 'deutsch'. Default is english.
29 | #[arg(short, long)]
30 | language: Option,
31 | }
32 |
33 | fn main() -> Result<(), Box> {
34 | let args = Args::parse();
35 |
36 | let language = match args.language {
37 | Some(language_string) => GloballySupportedLanguages::try_from(language_string)?,
38 | None => GloballySupportedLanguages::EN,
39 | };
40 |
41 | let template = match args.template {
42 | Some(template_string) => AvailableTemplates::try_from(template_string)?,
43 | None => AvailableTemplates::Coruscant,
44 | };
45 |
46 | generate_pdf(args.resume_data_path, args.target_path, template, language)?;
47 |
48 | Ok(())
49 | }
50 |
51 | /// Generate a resume and save it as a PDF.
52 | pub fn generate_pdf(
53 | resume_data_path: PathBuf,
54 | target_path: PathBuf,
55 | template_enum: AvailableTemplates,
56 | language: GloballySupportedLanguages,
57 | ) -> Result<(), Box> {
58 | let mut resume_data = load_json_resume(&resume_data_path).unwrap();
59 |
60 | if let Some(ref mut basics) = resume_data.basics {
61 | basics.image = resolve_image_path(&resume_data_path, &basics.image);
62 | }
63 |
64 | let template = match template_enum {
65 | AvailableTemplates::Coruscant => Coruscant::new(resume_data, &language).unwrap(),
66 | };
67 |
68 | let html_resume = template.build();
69 | save_to_pdf(html_resume, &target_path)?;
70 |
71 | Ok(())
72 | }
73 |
74 | /// All templates that are available.
75 | pub enum AvailableTemplates {
76 | /// A modern, minimalist, and professional resume design.
77 | Coruscant,
78 | }
79 | impl AvailableTemplates {
80 | /// Try constructing a this struct from a string.
81 | pub fn try_from(template_string: String) -> Result {
82 | match template_string.to_lowercase().as_str() {
83 | "coruscant" => Ok(AvailableTemplates::Coruscant),
84 | _ => Err(format!("{template_string} is not a supported template.")),
85 | }
86 | }
87 | }
88 |
89 | /// Language in which the resume should be generated in.
90 | pub enum GloballySupportedLanguages {
91 | /// English
92 | EN,
93 | /// German
94 | DE,
95 | }
96 | impl GloballySupportedLanguages {
97 | /// Try constructing a this struct from a string.
98 | pub fn try_from(language_string: String) -> Result {
99 | match language_string.to_lowercase().as_str() {
100 | "english" | "en" => Ok(GloballySupportedLanguages::EN),
101 | "deutsch" | "german" | "de" => Ok(GloballySupportedLanguages::DE),
102 | _ => Err(format!("{language_string} is not a supported language.")),
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/templates/coruscant/basics/basics_box.rs:
--------------------------------------------------------------------------------
1 | use minijinja::context;
2 |
3 | use crate::templates::coruscant::{
4 | basics::{
5 | contact_info::contact_info_wrapper::build_contact_info_wrapper,
6 | languages::language_wrapper::build_languages_wrapper,
7 | skills::skills_wrapper::build_skills_wrapper,
8 | },
9 | data_model::supported_resume_data::SupportedResumeData,
10 | shared::render_template::render_template,
11 | supported_languages::SupportedLanguages,
12 | };
13 |
14 | /// Return the basics wrapper as HTML.
15 | pub fn build_basics_wrapper(
16 | resume_data: &SupportedResumeData,
17 | language: &SupportedLanguages,
18 | ) -> String {
19 | let rendered_template = render_template(
20 | include_str!("index.html"),
21 | context!(
22 | name => resume_data.basics.name,
23 | image => resume_data.basics.image,
24 | label => resume_data.basics.label,
25 | contact_info => build_contact_info_wrapper(resume_data),
26 | languages => build_languages_wrapper(resume_data, language),
27 | skills => build_skills_wrapper(resume_data, language),
28 | ),
29 | );
30 |
31 | match rendered_template {
32 | Ok(t) => t,
33 | Err(_) => panic!("Failed to render basics template."),
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/templates/coruscant/basics/contact_info/contact_info_wrapper.rs:
--------------------------------------------------------------------------------
1 | use minijinja::context;
2 |
3 | use crate::templates::coruscant::{
4 | data_model::supported_resume_data::SupportedResumeData,
5 | shared::render_template::render_template,
6 | };
7 |
8 | /// Return the contact info wrapper as HTML.
9 | pub fn build_contact_info_wrapper(resume_data: &SupportedResumeData) -> String {
10 | let rendered_template = render_template(
11 | include_str!("index.html"),
12 | context!(
13 | email => resume_data.basics.email,
14 | phone => resume_data.basics.phone,
15 | address => resume_data.basics.location.address,
16 | city => resume_data.basics.location.city,
17 | postal_code => resume_data.basics.location.postal_code,
18 | country_code => resume_data.basics.location.country_code,
19 | email_icon => include_str!("icons/email.svg"),
20 | phone_icon => include_str!("icons/phone.svg"),
21 | address_icon => include_str!("icons/address.svg"),
22 | ),
23 | );
24 |
25 | match rendered_template {
26 | Ok(t) => t,
27 | Err(_) => panic!("Failed to render contact info template."),
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/templates/coruscant/basics/contact_info/icons/address.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/templates/coruscant/basics/contact_info/icons/email.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/templates/coruscant/basics/contact_info/icons/phone.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/templates/coruscant/basics/contact_info/index.html:
--------------------------------------------------------------------------------
1 |