From 538996dc84b03eab1429ddd693334673b857c005 Mon Sep 17 00:00:00 2001 From: pacien Date: Sat, 28 Dec 2019 19:04:54 +0100 Subject: compiler: parameterise gallery name --- compiler/src/Compiler.hs | 4 ++-- compiler/src/Config.hs | 6 ++++-- compiler/src/Gallery.hs | 6 +++++- design-notes.md | 2 ++ 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 import Config import Input (decodeYamlFile, readInputTree) import Resource (ResourceTree, buildResourceTree, cleanupResourceDir) -import Gallery (buildGalleryTree) +import Gallery (buildGallery) import Files ( FileName , FSNode(..) @@ -81,7 +81,7 @@ compileGallery inputDirPath outputDirPath rebuildAll = cleanupResourceDir resourceTree outputDirPath - buildGalleryTree resourceTree + buildGallery (galleryName config) resourceTree & writeJSON outputIndex 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(..)) data CompilerConfig = CompilerConfig - { thumbnailResolution :: Resolution + { galleryName :: String + , thumbnailResolution :: Resolution , pictureMaxResolution :: Maybe Resolution } deriving (Generic, Show) instance FromJSON CompilerConfig where parseJSON = withObject "CompilerConfig" $ \v -> CompilerConfig - <$> v .:? "thumbnailResolution" .!= (Resolution 400 400) + <$> v .:? "galleryName" .!= "Gallery" + <*> v .:? "thumbnailResolution" .!= (Resolution 400 400) <*> v .:? "pictureMaxResolution" 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 @@ #-} module Gallery - ( GalleryItem(..), buildGalleryTree + ( GalleryItem(..), buildGallery ) where @@ -128,3 +128,7 @@ buildGalleryTree (DirResource dirItems path@(dirname:_) thumbnail) = unique :: Ord a => [a] -> [a] unique = Set.toList . Set.fromList + +buildGallery :: String -> ResourceTree -> GalleryItem +buildGallery galleryName resourceTree = + (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 ```yaml compiler: + galleryName: My Little Gallery + thumbnailResolution: width: 400 # default 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 @@ compiler: + galleryName: Example gallery + + #thumbnailResolution: + # width: 400 # default + # height: 400 # default + pictureMaxResolution: width: 1024 height: 768 + viewer: {} -- cgit v1.2.3