diff options
Diffstat (limited to 'src/View/LaTeX/Resume.hs')
-rw-r--r-- | src/View/LaTeX/Resume.hs | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/src/View/LaTeX/Resume.hs b/src/View/LaTeX/Resume.hs new file mode 100644 index 0000000..6ec717f --- /dev/null +++ b/src/View/LaTeX/Resume.hs @@ -0,0 +1,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) ]) |