create a minimal working example

This commit is contained in:
Sina Atalay 2023-08-20 20:48:11 +02:00
parent c240fe90b8
commit ac1bf47cbf
4 changed files with 290 additions and 47 deletions

View File

@ -1,79 +1,80 @@
from pydantic import BaseModel, HttpUrl from pydantic import BaseModel, HttpUrl
from pydantic_extra_types.phone_numbers import PhoneNumber from pydantic_extra_types.phone_numbers import PhoneNumber
from typing import Literal 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): class Location(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
city: str city: str
country: str country: str
# 2) Optional user inputs: # 2) Optional user inputs:
state: str state: str = None
class Skill(BaseModel): class Skill(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
name: str name: str
# 2) Optional user inputs: # 2) Optional user inputs:
details: str details: str = None
class Activity(BaseModel): class Activity(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
organization: Organization organization: str
position: str position: str
start_date: date
end_date: date
location: Location location: Location
# 2) Optional user inputs: # 2) Optional user inputs:
company_url: HttpUrl start_date: Date = None
highlights: list[str] end_date: Date = None
company_url: HttpUrl = None
highlights: list[str] = None
class TestScore(BaseModel): class TestScore(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
name: str name: str
score: str score: str
# 2) Optional user inputs: # 2) Optional user inputs:
url: HttpUrl url: HttpUrl = None
details: str date: Date = None
date: date
class Project(BaseModel): class Project(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
name: str name: str
start_date: date
end_date: date
location: Location location: Location
# 2) Optional user inputs: # 2) Optional user inputs:
url: HttpUrl start_date: Date= None
highlights: list[str] end_date: Date = None
url: HttpUrl = None
highlights: list[str] = None
class WorkExperience(BaseModel): class WorkExperience(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
company: Organization company: str
position: str position: str
start_date: date start_date: Date
end_date: date
location: Location location: Location
# 2) Optional user inputs: # 2) Optional user inputs:
highlights: list[str] end_date: Date = None
highlights: list[str] = None
class Education(BaseModel): class Education(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
institution: Organization institution: str
study_type: str
area: str area: str
location: Location location: Location
start_date: date start_date: Date
end_date: date
# 2) Optional user inputs: # 2) Optional user inputs:
gpa: str end_date: Date = None
transcript_url: HttpUrl study_type: str = None
highlights: list[str] gpa: str = None
transcript_url: HttpUrl = None
highlights: list[str] = None
class SocialNetwork(BaseModel): class SocialNetwork(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
@ -81,20 +82,19 @@ class SocialNetwork(BaseModel):
username: str username: str
url: HttpUrl url: HttpUrl
class CurriculumVitae(BaseModel): class CurriculumVitae(BaseModel):
# 1) Mandotory user inputs: # 1) Mandotory user inputs:
name: str name: str
# 2) Optional user inputs: # 2) Optional user inputs:
email: str email: str = None
phone: PhoneNumber phone: PhoneNumber = None
website: HttpUrl website: HttpUrl = None
summary: str location: Location = None
location: Location social_networks: list[SocialNetwork] = None
social_networks: list[SocialNetwork] education: list[Education] = None
education: list[Education] work_experience: list[WorkExperience] = None
work_experience: list[WorkExperience] academic_projects: list[Project] = None
academic_projects: list[Project] extracurricular_activities: list[Activity] = None
extracurricular_activities: list[Activity] test_scores: list[TestScore] = None
test_scores: list[TestScore] skills: list[Skill] = None
skills: list[Skill]

View File

@ -1,4 +1,23 @@
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from data.content import CurriculumVitae
import os
import json
env = Environment(loader=FileSystemLoader("templates/")) workspace = os.path.dirname(os.path.dirname(__file__))
template = env.get_template("template1.tex.j2") 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)

View File

@ -54,7 +54,9 @@
\directlua{printHeader()} \directlua{printHeader()}
\section{Education} \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} \section{Work Experience}
\directlua{printExperience()} \directlua{printExperience()}

222
tests/inputs/test.json Normal file
View File

@ -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."
]
}
]
}