diff options
author | pacien | 2019-12-28 19:04:54 +0100 |
---|---|---|
committer | pacien | 2019-12-28 19:04:54 +0100 |
commit | 538996dc84b03eab1429ddd693334673b857c005 (patch) | |
tree | 65b8c0e31895b6a96d559e73a038ebcf6395dbf6 | |
parent | c002224309f0149e7ef03b3037d1549f770f2f09 (diff) | |
download | ldgallery-538996dc84b03eab1429ddd693334673b857c005.tar.gz |
compiler: parameterise gallery name
-rw-r--r-- | compiler/src/Compiler.hs | 4 | ||||
-rw-r--r-- | compiler/src/Config.hs | 6 | ||||
-rw-r--r-- | compiler/src/Gallery.hs | 6 | ||||
-rw-r--r-- | design-notes.md | 2 | ||||
-rw-r--r-- | example/gallery.yaml | 7 |
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 | |||
38 | import Config | 38 | import Config |
39 | import Input (decodeYamlFile, readInputTree) | 39 | import Input (decodeYamlFile, readInputTree) |
40 | import Resource (ResourceTree, buildResourceTree, cleanupResourceDir) | 40 | import Resource (ResourceTree, buildResourceTree, cleanupResourceDir) |
41 | import Gallery (buildGalleryTree) | 41 | import Gallery (buildGallery) |
42 | import Files | 42 | import 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 | ||
43 | data CompilerConfig = CompilerConfig | 43 | data 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 | ||
48 | instance FromJSON CompilerConfig where | 49 | instance 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 | ||
25 | module Gallery | 25 | module 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 | |||
132 | buildGallery :: String -> ResourceTree -> GalleryItem | ||
133 | buildGallery 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 |
70 | compiler: | 70 | compiler: |
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 @@ | |||
1 | compiler: | 1 | compiler: |
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 | |||
6 | viewer: {} | 13 | viewer: {} |