{-# LANGUAGE OverloadedStrings #-} module View.Resume ( renderResume ) where import Data.Maybe import Data.String (fromString) import Text.Blaze.Html import Text.Blaze.Html5 hiding (details) import qualified Text.Blaze.Html5 as H import Text.Blaze.Html5.Attributes import Conf (Conf) import qualified Model as M import qualified Model.Company as C import Model.Date import qualified Model.Degree as D import Model.Header (Header (Resume)) import qualified Model.Identity as I import qualified Model.Job as J import qualified Model.School as S 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.Git (renderGit) import View.Header (renderHeader) import View.Icon (renderIcon) import View.Interval (renderDurationAndInterval) import Resume (resumePath) renderResume :: Conf -> Language -> Date -> M.Model -> Html renderResume conf language currentDate model = H.div $ do renderHeader language (Just Resume) H.div ! class_ "resumePage" $ do renderIdentity conf language model renderJobs language currentDate . M.jobs $ model renderDegrees language . M.degrees $ model renderSkillTypes language . M.skillTypes $ model renderInterests language . M.interests $ model renderIdentity :: Conf -> Language -> M.Model -> Html renderIdentity conf language model = let identity = M.identity model in H.div ! class_ "section" $ do H.div ! class_ "identity" $ do h1 (fromString (I.name identity)) renderGit conf (I.git identity) a ! href (fromString $ resumePath model language) ! class_ "pdf" ! target "_blank" $ renderIcon "print" renderJobs :: Language -> Date -> [J.Job] -> Html renderJobs language currentDate jobs = H.div ! class_ "section" $ do sectionTitle K.Experience language mapM_ (renderJob language currentDate) jobs renderJob :: Language -> Date -> J.Job -> Html renderJob language currentDate job = H.div ! class_ "item" $ do H.div ! class_ "title" $ do H.div ! class_ "text" $ fromString . getTranslation language . J.name $ job H.div ! class_ "date" $ fromString $ renderDurationAndInterval language currentDate (J.beginDate job) (J.endDate job) H.div ! class_ "location" $ do let company = J.company job companyName = C.name company companyLocation = C.location company fromString $ companyName ++ ", " ++ companyLocation H.div ! class_ "description" $ do _ <- fromString . getTranslation language . J.description $ job case J.details job of Just details -> ul ! class_ "bullets detail" $ mapM_ (\detail -> li . fromString . getTranslation language $ detail) details Nothing -> fromString "" renderTechnos $ fromMaybe [] (J.technos job) renderTechnos :: [String] -> Html renderTechnos = (ul ! class_ "technos") . mapM_ ((li ! class_ "techno") . fromString) renderDegrees :: Language -> [D.Degree] -> Html renderDegrees language degrees = H.div ! class_ "section" $ do sectionTitle K.EducationalBackground language mapM_ (renderDegree language) degrees renderDegree :: Language -> D.Degree -> Html renderDegree language degree = H.div ! class_ "item" $ do H.div ! class_ "title" $ do H.div ! class_ "text " $ fromString . getTranslation language . D.name $ degree H.div ! class_ "date" $ fromString . show . D.year $ degree H.div ! class_ "location" $ let school = D.school degree location = fromMaybe "" $ fmap (", " ++ ) (S.location school) in fromString $ (S.name school) ++ location ul ! class_ "bullets itemList" $ mapM_ (\topic -> li . fromString . getTranslation language $ topic) (D.topics degree) renderSkillTypes :: Language -> [ST.SkillType] -> Html renderSkillTypes language skillTypes = H.div ! class_ "section" $ do sectionTitle K.Skills language mapM_ (renderSkillType language) skillTypes renderSkillType :: Language -> ST.SkillType -> Html renderSkillType language skillType = H.div ! class_ "item" $ do H.div ! class_ "title skills" $ H.div ! class_ "text" $ fromString . getTranslation language . ST.name $ skillType ul ! class_ "bullets itemList" $ mapM_ (\skill -> li . fromString . getTranslation language $ skill) (ST.skills skillType) renderInterests :: Language -> [Translated] -> Html renderInterests language interests = H.div ! class_ "section" $ do sectionTitle K.Interests language ul ! class_ "bullets" $ mapM_ (\interest -> li . fromString . getTranslation language $ interest) interests sectionTitle :: Key -> Language -> Html sectionTitle key language = h1 . fromString $ getMessage key language