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 +++++- 3 files changed, 11 insertions(+), 5 deletions(-) (limited to 'compiler/src') 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 } -- cgit v1.2.3