1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
{-# LANGUAGE OverloadedStrings #-}
module View.LaTeX.Resume
( resumeLaTeX
) where
import Text.LaTeX
import Text.LaTeX.Base.Syntax (LaTeX (TeXComm), TeXArg (FixArg))
import Data.Maybe (fromMaybe, listToMaybe)
import Conf (Conf)
import qualified Conf as Conf
import Model (Model)
import qualified Model as M
import qualified Model.Company as C
import Model.Date (Date)
import Model.Degree (Degree)
import qualified Model.Degree as D
import Model.Identity (Identity)
import qualified Model.Identity as I
import Model.Job (Job)
import qualified Model.Job as J
import qualified Model.School as S
import Model.SkillType (SkillType)
import qualified Model.SkillType as ST
import Model.Translated
import Model.Translation.Key (Key)
import qualified Model.Translation.Key as K
import Model.Translation.Language
import Model.Translation.Message
import View.Interval (renderDurationAndInterval)
import Utils.String
resumeLaTeX :: Conf -> Language -> Date -> Model -> LaTeX
resumeLaTeX conf language currentDate model =
preamble
<> document (body conf language currentDate model)
preamble :: LaTeX
preamble = documentclass [] "resume"
body :: Conf -> Language -> Date -> Model -> LaTeX
body conf language currentDate model =
identityLaTeX conf language (M.identity model) (M.jobs model)
<> jobsLaTeX language currentDate (M.jobs model)
<> degreesLaTeX language (M.degrees model)
<> skillTypesLaTeX language (M.skillTypes model)
<> interestsLaTeX language (M.interests model)
identityLaTeX :: Conf -> Language -> Identity -> [Job] -> LaTeX
identityLaTeX conf language identity jobs =
TeXComm "header"
[ FixArg (fromString $ I.name identity)
, FixArg (fromString . fromMaybe "" . (fmap (getTranslation language . J.name)) . listToMaybe $ jobs)
, FixArg (fromString $ I.website identity)
, FixArg (fromString $ Conf.git conf)
, FixArg (fromString $ I.git identity)
]
jobsLaTeX :: Language -> Date -> [Job] -> LaTeX
jobsLaTeX language currentDate jobs =
translatedSection K.Experience language
<> mconcat (map (jobLaTeX language currentDate) jobs)
jobLaTeX :: Language -> Date -> Job -> LaTeX
jobLaTeX language currentDate job =
customCommand "position"
[ fromString . getTranslation language $ J.name job
, fromString $ renderDurationAndInterval language currentDate (J.beginDate job) (J.endDate job)
, fromString $ ((C.name . J.company) job) ++ ", " ++ ((C.location . J.company) job)
, (fromString . getTranslation language . J.description $ job)
, case J.details job of
Just details@(_:_) -> translatedBullets language details
_ -> mempty
, case J.technos job of
Just ts -> technos ts
_ -> mempty
]
degreesLaTeX :: Language -> [Degree] -> LaTeX
degreesLaTeX language degrees =
translatedSection K.EducationalBackground language
<> mconcat (map (degreeLaTeX language) degrees)
degreeLaTeX :: Language -> Degree -> LaTeX
degreeLaTeX language degree =
customCommand "position"
[ fromString . getTranslation language $ D.name degree
, fromString . show . D.year $ degree
, fromString $ S.name school ++ (fromMaybe "" (((++) ", ") <$> S.location school))
, mempty
, translatedBullets language $ D.topics degree
, mempty
]
where school = D.school degree
skillTypesLaTeX :: Language -> [SkillType] -> LaTeX
skillTypesLaTeX language skillTypes =
translatedSection K.Skills language
<> (mconcat . map (skillTypeLaTeX language) $ skillTypes)
skillTypeLaTeX :: Language -> SkillType -> LaTeX
skillTypeLaTeX language skillType =
subsection (fromString . capitalizeFirstWord . getTranslation language . ST.name $ skillType)
<> translatedBullets language (ST.skills skillType)
interestsLaTeX :: Language -> [Translated] -> LaTeX
interestsLaTeX language interests =
translatedSection K.Interests language
<> translatedBullets language interests
translatedBullets :: Language -> [Translated] -> LaTeX
translatedBullets language = itemsEnv "bullets" . map (getTranslation language)
itemsEnv :: String -> [String] -> LaTeX
itemsEnv name items =
environment name . mconcat . concat . map getItem $ items
where getItem i =
[ item Nothing
, fromString . capitalizeFirstWord $ i
]
technos :: [String] -> LaTeX
technos names =
environment "technos" . mconcat . concat . map getItem $ names
where getItem name =
[ item Nothing
, TeXComm "techno" [ FixArg (fromString name) ]
]
translatedSection :: Key -> Language -> LaTeX
translatedSection key language =
section (fromString . capitalizeWords $ getMessage key language)
customCommand :: String -> [LaTeX] -> LaTeX
customCommand commandName commandParameters =
TeXComm commandName (map FixArg commandParameters)
environment :: String -> LaTeX -> LaTeX
environment name inside =
(TeXComm "begin" [ FixArg (fromString name) ])
<> inside
<> (TeXComm "end" [ FixArg (fromString name) ])
|