From ac1bf47cbf3132a9119cd1779ab170ceb28281dc Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Sun, 20 Aug 2023 20:48:11 +0200 Subject: [PATCH] create a minimal working example --- rendercv/data/content.py | 88 +++++------ rendercv/rendercv.py | 23 ++- rendercv/templates/template1.tex.j2 | 4 +- tests/inputs/test.json | 222 ++++++++++++++++++++++++++++ 4 files changed, 290 insertions(+), 47 deletions(-) create mode 100644 tests/inputs/test.json diff --git a/rendercv/data/content.py b/rendercv/data/content.py index 8b1913e..3f54c01 100644 --- a/rendercv/data/content.py +++ b/rendercv/data/content.py @@ -1,79 +1,80 @@ from pydantic import BaseModel, HttpUrl from pydantic_extra_types.phone_numbers import PhoneNumber from typing import Literal -from datetime import date +from datetime import date as Date -class Organization(BaseModel): - # 1) Mandotory user inputs: - name: str - # 2) Optional user inputs: - url: HttpUrl class Location(BaseModel): # 1) Mandotory user inputs: city: str country: str # 2) Optional user inputs: - state: str + state: str = None + class Skill(BaseModel): # 1) Mandotory user inputs: name: str # 2) Optional user inputs: - details: str + details: str = None + class Activity(BaseModel): # 1) Mandotory user inputs: - organization: Organization + organization: str position: str - start_date: date - end_date: date location: Location # 2) Optional user inputs: - company_url: HttpUrl - highlights: list[str] + start_date: Date = None + end_date: Date = None + company_url: HttpUrl = None + highlights: list[str] = None + class TestScore(BaseModel): # 1) Mandotory user inputs: name: str score: str # 2) Optional user inputs: - url: HttpUrl - details: str - date: date + url: HttpUrl = None + date: Date = None + class Project(BaseModel): # 1) Mandotory user inputs: name: str - start_date: date - end_date: date location: Location # 2) Optional user inputs: - url: HttpUrl - highlights: list[str] + start_date: Date= None + end_date: Date = None + url: HttpUrl = None + highlights: list[str] = None + class WorkExperience(BaseModel): # 1) Mandotory user inputs: - company: Organization + company: str position: str - start_date: date - end_date: date + start_date: Date location: Location # 2) Optional user inputs: - highlights: list[str] + end_date: Date = None + highlights: list[str] = None + class Education(BaseModel): # 1) Mandotory user inputs: - institution: Organization - study_type: str + institution: str area: str location: Location - start_date: date - end_date: date + start_date: Date # 2) Optional user inputs: - gpa: str - transcript_url: HttpUrl - highlights: list[str] + end_date: Date = None + study_type: str = None + gpa: str = None + transcript_url: HttpUrl = None + highlights: list[str] = None + class SocialNetwork(BaseModel): # 1) Mandotory user inputs: @@ -81,20 +82,19 @@ class SocialNetwork(BaseModel): username: str url: HttpUrl + class CurriculumVitae(BaseModel): # 1) Mandotory user inputs: name: str # 2) Optional user inputs: - email: str - phone: PhoneNumber - website: HttpUrl - summary: str - location: Location - social_networks: list[SocialNetwork] - education: list[Education] - work_experience: list[WorkExperience] - academic_projects: list[Project] - extracurricular_activities: list[Activity] - test_scores: list[TestScore] - skills: list[Skill] - + email: str = None + phone: PhoneNumber = None + website: HttpUrl = None + location: Location = None + social_networks: list[SocialNetwork] = None + education: list[Education] = None + work_experience: list[WorkExperience] = None + academic_projects: list[Project] = None + extracurricular_activities: list[Activity] = None + test_scores: list[TestScore] = None + skills: list[Skill] = None diff --git a/rendercv/rendercv.py b/rendercv/rendercv.py index dccf8f9..c810c64 100644 --- a/rendercv/rendercv.py +++ b/rendercv/rendercv.py @@ -1,4 +1,23 @@ from jinja2 import Environment, FileSystemLoader +from data.content import CurriculumVitae +import os +import json -env = Environment(loader=FileSystemLoader("templates/")) -template = env.get_template("template1.tex.j2") +workspace = os.path.dirname(os.path.dirname(__file__)) +environment = Environment(loader=FileSystemLoader(os.path.join(workspace, "rendercv", "templates"))) +environment.block_start_string = "((*" +environment.block_end_string = "*))" +environment.variable_start_string = "(((" +environment.variable_end_string = ")))" +environment.comment_start_string = "((=" +environment.comment_end_string = "=))" + +template = environment.get_template("template1.tex.j2") + +input_file_path = os.path.join(workspace, "tests", "inputs", "test.json") +with open(input_file_path) as file: + raw_json = json.load(file) + +data = CurriculumVitae(**raw_json) + +output_latex_file = template.render(data=data) diff --git a/rendercv/templates/template1.tex.j2 b/rendercv/templates/template1.tex.j2 index 1e4168d..76158c5 100644 --- a/rendercv/templates/template1.tex.j2 +++ b/rendercv/templates/template1.tex.j2 @@ -54,7 +54,9 @@ \directlua{printHeader()} \section{Education} - \directlua{printEducation()} + ((* for education in data.education *)) + \EducationEntry{(((education.institution)))}{(((education.area)))}{(((education.studyType)))}{(((education.startDate)))}{(((education.endDate)))}{(((education.gpa)))}{(((education.courses)))}{(((education.location)))} + ((* endfor *)) \section{Work Experience} \directlua{printExperience()} diff --git a/tests/inputs/test.json b/tests/inputs/test.json new file mode 100644 index 0000000..fa515c2 --- /dev/null +++ b/tests/inputs/test.json @@ -0,0 +1,222 @@ +{ + "name": "John Doe", + "url": "https://sinaatalay.com", + "location": { + "city": "Geneva", + "country": "Switzerland" + }, + "social_networks": [ + { + "network": "LinkedIn", + "username": "sinaatalay", + "url": "https://www.linkedin.com/in/sinaatalay" + }, + { + "network": "GitHub", + "username": "sinaatalay", + "url": "https://github.com/sinaatalay" + } + ], + "education": [ + { + "institution": "Boğaziçi University", + "url": "https://boun.edu.tr", + "area": "Mechanical Engineering", + "study_type": "BS", + "location": { + "city": "Istanbul", + "country": "Turkey" + }, + "start_date": "2017-09-01", + "end_date": "2023-01-01", + "gpa": "3.80/4.00", + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ] + }, + { + "institution": "The University of Texas at Austin", + "url": "https://utexas.edu", + "area": "Mechanical Engineering, Student Exchange Program", + "studyType": "BS", + "location": { + "city": "Austin", + "state": "Texas", + "country": "USA" + }, + "start_date": "2021-08-01", + "end_date": "2022-01-15", + "gpa": "4.00/4.00", + "highlights": [] + } + ], + "work_experience": [ + { + "company": "CERN", + "position": "Mechanical Engineer (Technical Student)", + "location": { + "city": "Geneva", + "country": "Switzerland" + }, + "url": "https://home.cern", + "start_date": "2023-02-01", + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ] + }, + { + "company": "Turkish Aerospace Industries", + "position": "Mechanical Engineering Intern", + "location":{ + "city": "Ankara", + "country": "Turkey" + }, + "url": "https://tusas.com", + "start_date": "2022-08-01", + "end_date": "2022-09-01", + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ] + }, + { + "company": "Simularge", + "position": "Mechanical Engineering Intern", + "location": { + "city": "Istanbul", + "country": "Turkey" + }, + "url": "https://simularge.com", + "start_date": "2022-06-15", + "end_date": "2022-08-01", + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ] + }, + { + "company": "Aselsan", + "position": "Mechanical Engineering Intern", + "location":{ + "city": "Ankara", + "country": "Turkey" + }, + "url": "https://aselsan.com.tr", + "start_date": "2021-07-26", + "end_date": "2021-08-20", + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ] + } + ], + "academic_projects": [ + { + "name": "An Ion Thruster Simulation Program: Ionizer", + "location": { + "city": "Istanbul", + "country": "Turkey" + }, + "start_date": "2022-04-08", + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ], + "url": "https://github.com/sinaatalay/Ionizer" + }, + { + "name": "Design and Construction of a Dynamometer", + "location": { + "city": "Istanbul", + "country": "Turkey" + }, + "highlights": [ + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", + "Id leo in vitae turpis massa sed, posuere aliquam ultrices sagittis orci a scelerisque, lorem ipsum dolor sit amet." + ] + } + ], + "certificates": [ + { + "name": "Machine Learning by Stanford University", + "date": "2022-09-01", + "highlights": [], + "url": "https://coursera.org/verify/MZDLHBUQSULA" + } + ], + "skills": [ + { + "name": "Programming", + "details": "C++, C, Python, JavaScript, MATLAB, Lua, LaTeX" + }, + { + "name": "CAE", + "details": "GMSH, GetDP, CalculiX ——— show these in GitHub!!!" + }, + { + "name": "CAD", + "details": "FreeCAD, Siemens NX, SolidWorks ——— draw your projects with these to show on your website" + }, + { + "name": "OS", + "details": "Windows, Ubuntu, !!!macOS!!!" + }, + { + "name": "Other tools", + "details": "Git, Premake, !!!CMake!!!, !!!PyTorch!!!, HTML, CSS, React" + }, + { + "name": "Languages", + "details": "English (Advanced), !!!French (Lower Intermediate)!!!, Turkish (Native)" + } + ], + "test_scores": [ + { + "name": "TOEFL", + "date": "2022-10-01", + "score": "113/120 — Reading: 29/30, Listening: 30/30, Speaking: 27/30, Writing: 27/30" + }, + { + "name": "GRE", + "score": "Verbal Reasoning: 160/170, Quantitative Reasoning: 170/170, Analytical Writing: 5/6" + } + ], + "personalProjects": [ + { + "name": "Teaching Videos", + "highlights": [ + "Instructed the entire \"Engineering Mechanics: Dynamics\" course on YouTube that has garnered over 300,000 views to date." + ], + "url": "https://youtube.com/c/SinaAtalay" + }, + { + "name": "Teaching Videos", + "highlights": [ + "Instructed the entire \"Engineering Mechanics: Dynamics\" course on YouTube that has garnered over 300,000 views to date." + ], + "url": "https://youtube.com/c/SinaAtalay" + } + ], + "extracurricular_activities": [ + { + "organization": "Alacati Surf Paradise Club (ASPC)", + "position": "Windsurfing Instructor", + "location":{ + "city": "Izmir", + "country": "Turkey" + }, + "highlights": [ + "Taught windsurfing during summers as a Turkish Sailing Federation certified windsurfing instructor." + ] + } + ] +}