aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Config.hs
diff options
context:
space:
mode:
authorpacien2019-12-27 12:38:01 +0100
committerpacien2019-12-27 12:38:01 +0100
commit63b06627f200f155f66ecdb6c5f41ab44808dd6b (patch)
tree64eee82c70b3a3b85f062a7ecb3508912840eb30 /compiler/src/Config.hs
parentc3f1d45743e274f588e5a23ba25e1fc124728c11 (diff)
downloadldgallery-63b06627f200f155f66ecdb6c5f41ab44808dd6b.tar.gz
compiler: add compiler config keys
Diffstat (limited to 'compiler/src/Config.hs')
-rw-r--r--compiler/src/Config.hs19
1 files changed, 13 insertions, 6 deletions
diff --git a/compiler/src/Config.hs b/compiler/src/Config.hs
index f147bdd..fe981c3 100644
--- a/compiler/src/Config.hs
+++ b/compiler/src/Config.hs
@@ -20,6 +20,7 @@
20 DuplicateRecordFields 20 DuplicateRecordFields
21 , DeriveGeneric 21 , DeriveGeneric
22 , DeriveAnyClass 22 , DeriveAnyClass
23 , OverloadedStrings
23#-} 24#-}
24 25
25module Config 26module Config
@@ -29,25 +30,31 @@ module Config
29 ) where 30 ) where
30 31
31 32
33import Data.Text (Text)
32import GHC.Generics (Generic) 34import GHC.Generics (Generic)
33import Data.Aeson (ToJSON, FromJSON) 35import Data.Aeson (ToJSON, FromJSON, withObject, (.:?), (.!=))
34import qualified Data.Aeson as JSON 36import qualified Data.Aeson as JSON
35 37
36import Files (FileName) 38import Files (FileName)
37import Input (decodeYamlFile) 39import Input (decodeYamlFile)
40import Processors (Resolution(..))
38 41
39 42
40data CompilerConfig = CompilerConfig 43data CompilerConfig = CompilerConfig
41 { dummy :: Maybe String -- TODO 44 { thumbnailResolution :: Resolution
42 } deriving (Generic, FromJSON, Show) 45 , pictureMaxResolution :: Maybe Resolution
46 } deriving (Generic, Show)
47
48instance FromJSON CompilerConfig where
49 parseJSON = withObject "CompilerConfig" $ \v -> CompilerConfig
50 <$> v .:? "thumbnailResolution" .!= (Resolution 400 400)
51 <*> v .:? "pictureMaxResolution"
52
43 53
44data GalleryConfig = GalleryConfig 54data GalleryConfig = GalleryConfig
45 { compiler :: CompilerConfig 55 { compiler :: CompilerConfig
46 , viewer :: JSON.Object 56 , viewer :: JSON.Object
47 } deriving (Generic, FromJSON, Show) 57 } deriving (Generic, FromJSON, Show)
48 58
49-- TODO: add compiler config keys and their default values
50
51
52readConfig :: FileName -> IO GalleryConfig 59readConfig :: FileName -> IO GalleryConfig
53readConfig = decodeYamlFile 60readConfig = decodeYamlFile