aboutsummaryrefslogtreecommitdiff
path: root/src/View/Resume.hs
blob: ffd5c8c8d708680d0c2f480ed88e1800e586afa9 (plain)
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
{-# 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