aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2019-12-28 19:04:54 +0100
committerpacien2019-12-28 19:04:54 +0100
commit538996dc84b03eab1429ddd693334673b857c005 (patch)
tree65b8c0e31895b6a96d559e73a038ebcf6395dbf6
parentc002224309f0149e7ef03b3037d1549f770f2f09 (diff)
downloadldgallery-538996dc84b03eab1429ddd693334673b857c005.tar.gz
compiler: parameterise gallery name
-rw-r--r--compiler/src/Compiler.hs4
-rw-r--r--compiler/src/Config.hs6
-rw-r--r--compiler/src/Gallery.hs6
-rw-r--r--design-notes.md2
-rw-r--r--example/gallery.yaml7
5 files changed, 20 insertions, 5 deletions
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs
index 2584570..dbe6cae 100644
--- a/compiler/src/Compiler.hs
+++ b/compiler/src/Compiler.hs
@@ -38,7 +38,7 @@ import qualified Data.Aeson as JSON
38import Config 38import Config
39import Input (decodeYamlFile, readInputTree) 39import Input (decodeYamlFile, readInputTree)
40import Resource (ResourceTree, buildResourceTree, cleanupResourceDir) 40import Resource (ResourceTree, buildResourceTree, cleanupResourceDir)
41import Gallery (buildGalleryTree) 41import Gallery (buildGallery)
42import Files 42import Files
43 ( FileName 43 ( FileName
44 , FSNode(..) 44 , FSNode(..)
@@ -81,7 +81,7 @@ compileGallery inputDirPath outputDirPath rebuildAll =
81 81
82 cleanupResourceDir resourceTree outputDirPath 82 cleanupResourceDir resourceTree outputDirPath
83 83
84 buildGalleryTree resourceTree 84 buildGallery (galleryName config) resourceTree
85 & writeJSON outputIndex 85 & writeJSON outputIndex
86 86
87 viewer fullConfig 87 viewer fullConfig
diff --git a/compiler/src/Config.hs b/compiler/src/Config.hs
index fe981c3..044a155 100644
--- a/compiler/src/Config.hs
+++ b/compiler/src/Config.hs
@@ -41,13 +41,15 @@ import Processors (Resolution(..))
41 41
42 42
43data CompilerConfig = CompilerConfig 43data CompilerConfig = CompilerConfig
44 { thumbnailResolution :: Resolution 44 { galleryName :: String
45 , thumbnailResolution :: Resolution
45 , pictureMaxResolution :: Maybe Resolution 46 , pictureMaxResolution :: Maybe Resolution
46 } deriving (Generic, Show) 47 } deriving (Generic, Show)
47 48
48instance FromJSON CompilerConfig where 49instance FromJSON CompilerConfig where
49 parseJSON = withObject "CompilerConfig" $ \v -> CompilerConfig 50 parseJSON = withObject "CompilerConfig" $ \v -> CompilerConfig
50 <$> v .:? "thumbnailResolution" .!= (Resolution 400 400) 51 <$> v .:? "galleryName" .!= "Gallery"
52 <*> v .:? "thumbnailResolution" .!= (Resolution 400 400)
51 <*> v .:? "pictureMaxResolution" 53 <*> v .:? "pictureMaxResolution"
52 54
53 55
diff --git a/compiler/src/Gallery.hs b/compiler/src/Gallery.hs
index f12eddb..1fa4036 100644
--- a/compiler/src/Gallery.hs
+++ b/compiler/src/Gallery.hs
@@ -23,7 +23,7 @@
23#-} 23#-}
24 24
25module Gallery 25module Gallery
26 ( GalleryItem(..), buildGalleryTree 26 ( GalleryItem(..), buildGallery
27 ) where 27 ) where
28 28
29 29
@@ -128,3 +128,7 @@ buildGalleryTree (DirResource dirItems path@(dirname:_) thumbnail) =
128 128
129 unique :: Ord a => [a] -> [a] 129 unique :: Ord a => [a] -> [a]
130 unique = Set.toList . Set.fromList 130 unique = Set.toList . Set.fromList
131
132buildGallery :: String -> ResourceTree -> GalleryItem
133buildGallery galleryName resourceTree =
134 (buildGalleryTree resourceTree) { title = galleryName }
diff --git a/design-notes.md b/design-notes.md
index 14fef31..02bd253 100644
--- a/design-notes.md
+++ b/design-notes.md
@@ -68,6 +68,8 @@ Proposed configuration file, named `gallery.yaml` at the root of the source dire
68 68
69```yaml 69```yaml
70compiler: 70compiler:
71 galleryName: My Little Gallery
72
71 thumbnailResolution: 73 thumbnailResolution:
72 width: 400 # default 74 width: 400 # default
73 height: 400 # default 75 height: 400 # default
diff --git a/example/gallery.yaml b/example/gallery.yaml
index 0a16e59..85b1edd 100644
--- a/example/gallery.yaml
+++ b/example/gallery.yaml
@@ -1,6 +1,13 @@
1compiler: 1compiler:
2 galleryName: Example gallery
3
4 #thumbnailResolution:
5 # width: 400 # default
6 # height: 400 # default
7
2 pictureMaxResolution: 8 pictureMaxResolution:
3 width: 1024 9 width: 1024
4 height: 768 10 height: 768
5 11
12
6viewer: {} 13viewer: {}