diff options
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Company.hs | 13 | ||||
-rw-r--r-- | src/Model/Date.hs | 30 | ||||
-rw-r--r-- | src/Model/Degree.hs | 18 | ||||
-rw-r--r-- | src/Model/Header.hs | 25 | ||||
-rw-r--r-- | src/Model/Identity.hs | 14 | ||||
-rw-r--r-- | src/Model/Job.hs | 22 | ||||
-rw-r--r-- | src/Model/Project.hs | 18 | ||||
-rw-r--r-- | src/Model/School.hs | 13 | ||||
-rw-r--r-- | src/Model/SkillType.hs | 15 | ||||
-rw-r--r-- | src/Model/Translated.hs | 19 | ||||
-rw-r--r-- | src/Model/Translation/Key.hs | 28 | ||||
-rw-r--r-- | src/Model/Translation/Language.hs | 12 | ||||
-rw-r--r-- | src/Model/Translation/Message.hs | 90 |
13 files changed, 317 insertions, 0 deletions
diff --git a/src/Model/Company.hs b/src/Model/Company.hs new file mode 100644 index 0000000..3069488 --- /dev/null +++ b/src/Model/Company.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Company where + +import GHC.Generics +import Data.Yaml + +data Company = Company + { name :: String + , location :: String + } deriving (Show, Read, Eq, Generic) + +instance FromJSON Company diff --git a/src/Model/Date.hs b/src/Model/Date.hs new file mode 100644 index 0000000..7edb6fb --- /dev/null +++ b/src/Model/Date.hs @@ -0,0 +1,30 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Date where + +import GHC.Generics +import Data.Yaml + +data Date = Date + { month :: Int + , year :: Int + } deriving (Show, Read, Eq, Generic) + +yearAndMonthDiff :: Date -> Date -> (Int, Int) +yearAndMonthDiff d1 d2 = + let totalMonths = monthDiff d1 d2 + in (totalMonths `div` 12, totalMonths `mod` 12) + +monthDiff :: Date -> Date -> Int +monthDiff (Date m1 y1) (Date m2 y2) = + if y1 == y2 then + 1 + abs (m1 - m2) + else + let (minM, minY, maxM, maxY) = + if y1 < y2 then + (m1, y1, m2, y2) + else + (m2, y2, m1, y1) + in 12 * (maxY - minY - 1) + (13 - minM) + maxM + +instance FromJSON Date diff --git a/src/Model/Degree.hs b/src/Model/Degree.hs new file mode 100644 index 0000000..90feacc --- /dev/null +++ b/src/Model/Degree.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Degree where + +import GHC.Generics +import Data.Yaml + +import Model.School +import Model.Translated + +data Degree = Degree + { name :: Translated + , school :: School + , year :: Int + , topics :: [Translated] + } deriving (Show, Read, Eq, Generic) + +instance FromJSON Degree diff --git a/src/Model/Header.hs b/src/Model/Header.hs new file mode 100644 index 0000000..7581fc5 --- /dev/null +++ b/src/Model/Header.hs @@ -0,0 +1,25 @@ +module Model.Header + ( Header(..) + , allHeaders + , headerLink + , headerKey + ) where + +import Model.Translation.Key (Key) +import qualified Model.Translation.Key as K + +data Header = + Resume + | Projects + deriving (Enum, Bounded, Show, Eq) + +allHeaders :: [Header] +allHeaders = [minBound..] + +headerLink :: Header -> String +headerLink Resume = "/" +headerLink Projects = "/projects" + +headerKey :: Header -> Key +headerKey Resume = K.Resume +headerKey Projects = K.Projects diff --git a/src/Model/Identity.hs b/src/Model/Identity.hs new file mode 100644 index 0000000..fb640fa --- /dev/null +++ b/src/Model/Identity.hs @@ -0,0 +1,14 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Identity where + +import Data.Yaml +import GHC.Generics + +data Identity = Identity + { name :: String + , website :: String + , git :: String + } deriving (Show, Read, Eq, Generic) + +instance FromJSON Identity diff --git a/src/Model/Job.hs b/src/Model/Job.hs new file mode 100644 index 0000000..f6865f4 --- /dev/null +++ b/src/Model/Job.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Job where + +import Data.Yaml +import GHC.Generics + +import Model.Company +import Model.Date +import Model.Translated + +data Job = Job + { name :: Translated + , description :: Translated + , details :: Maybe [Translated] + , technos :: Maybe [String] + , company :: Company + , beginDate :: Date + , endDate :: Maybe Date + } deriving (Show, Read, Eq, Generic) + +instance FromJSON Job diff --git a/src/Model/Project.hs b/src/Model/Project.hs new file mode 100644 index 0000000..7825e60 --- /dev/null +++ b/src/Model/Project.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Project where + +import GHC.Generics +import Data.Yaml + +import Model.Translated + +data Project = Project + { name :: String + , technologies :: [String] + , description :: Maybe Translated + , git :: String + , pageLink :: Maybe String + } deriving (Show, Read, Eq, Generic) + +instance FromJSON Project diff --git a/src/Model/School.hs b/src/Model/School.hs new file mode 100644 index 0000000..cb10ed9 --- /dev/null +++ b/src/Model/School.hs @@ -0,0 +1,13 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.School where + +import GHC.Generics +import Data.Yaml + +data School = School + { name :: String + , location :: Maybe String + } deriving (Show, Read, Eq, Generic) + +instance FromJSON School diff --git a/src/Model/SkillType.hs b/src/Model/SkillType.hs new file mode 100644 index 0000000..3e533b8 --- /dev/null +++ b/src/Model/SkillType.hs @@ -0,0 +1,15 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.SkillType where + +import GHC.Generics +import Data.Yaml + +import Model.Translated + +data SkillType = SkillType + { name :: Translated + , skills :: [Translated] + } deriving (Show, Read, Eq, Generic) + +instance FromJSON SkillType diff --git a/src/Model/Translated.hs b/src/Model/Translated.hs new file mode 100644 index 0000000..b92ae39 --- /dev/null +++ b/src/Model/Translated.hs @@ -0,0 +1,19 @@ +{-# LANGUAGE DeriveGeneric #-} + +module Model.Translated where + +import GHC.Generics +import Data.Yaml + +import Model.Translation.Language + +data Translated = Translated + { english :: String + , french :: String + } deriving (Show, Read, Eq, Generic) + +instance FromJSON Translated + +getTranslation :: Language -> Translated -> String +getTranslation English translated = english translated +getTranslation French translated = french translated diff --git a/src/Model/Translation/Key.hs b/src/Model/Translation/Key.hs new file mode 100644 index 0000000..43381fb --- /dev/null +++ b/src/Model/Translation/Key.hs @@ -0,0 +1,28 @@ +module Model.Translation.Key + ( Key(..) + ) where + +data Key = + + Home + | Resume + | Projects + | Contact + + | Experience + | EducationalBackground + | Skills + | Interests + + | Since + | From + | To + | And + + | Month Int + | MonthText Int + | YearText Int + + | TryIt + + | PageNotFound diff --git a/src/Model/Translation/Language.hs b/src/Model/Translation/Language.hs new file mode 100644 index 0000000..a8f5eb9 --- /dev/null +++ b/src/Model/Translation/Language.hs @@ -0,0 +1,12 @@ +module Model.Translation.Language + ( Language(..) + , languages + ) where + +data Language = + English + | French + deriving (Show, Read, Eq, Enum, Bounded) + +languages :: [Language] +languages = [minBound..] diff --git a/src/Model/Translation/Message.hs b/src/Model/Translation/Message.hs new file mode 100644 index 0000000..c9e0fcb --- /dev/null +++ b/src/Model/Translation/Message.hs @@ -0,0 +1,90 @@ +module Model.Translation.Message + ( getMessage + ) where + +import Model.Translation.Language +import Model.Translation.Key + +getMessage :: Key -> Language -> String + +getMessage Home English = "home" +getMessage Home French = "accueil" + +getMessage Resume English = "resume" +getMessage Resume French = "curriculum" + +getMessage Projects English = "projects" +getMessage Projects French = "projets" + +getMessage Contact English = "contact" +getMessage Contact French = "contact" + +getMessage Experience English = "experience" +getMessage Experience French = "expérience" + +getMessage EducationalBackground English = "educational background" +getMessage EducationalBackground French = "études" + +getMessage Skills English = "skills" +getMessage Skills French = "compétences" + +getMessage Interests English = "interests" +getMessage Interests French = "intérêts" + +getMessage Since English = "since" +getMessage Since French = "depuis" + +getMessage From English = "from" +getMessage From French = "de" + +getMessage To English = "to" +getMessage To French = "à" + +getMessage And English = "and" +getMessage And French = "et" + +getMessage (Month m) English = + case m of + 1 -> "january" + 2 -> "february" + 3 -> "march" + 4 -> "april" + 5 -> "may" + 6 -> "june" + 7 -> "july" + 8 -> "august" + 9 -> "september" + 10 -> "october" + 11 -> "november" + 12 -> "december" + _ -> "" +getMessage (Month m) French = + case m of + 1 -> "janvier" + 2 -> "février" + 3 -> "mars" + 4 -> "avril" + 5 -> "mai" + 6 -> "juin" + 7 -> "juillet" + 8 -> "août" + 9 -> "septembre" + 10 -> "octoble" + 11 -> "novembre" + 12 -> "décembre" + _ -> "" + +getMessage (MonthText count) English = "month" ++ (plural count) +getMessage (MonthText _) French = "mois" + +getMessage (YearText count) English = "year" ++ (plural count) +getMessage (YearText count) French = "an" ++ (plural count) + +getMessage TryIt English = "Try it!" +getMessage TryIt French = "Voir" + +getMessage PageNotFound English = "Page not found." +getMessage PageNotFound French = "La page que vous recherchez n'est pas disponible." + +plural :: Int -> String +plural count = if count > 1 then "s" else "" |