From 2766f5f9a491c5f7ebf1eeac1c970daec3656be2 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 25 Feb 2020 16:03:00 +0100 Subject: transverse: combine item tree and gallery-wide properties GitHub: closes #142 --- compiler/src/Compiler.hs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'compiler') diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index 73ac8a4..2970102 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs @@ -22,6 +22,7 @@ module Compiler ) where +import GHC.Generics (Generic) import Control.Monad (liftM2, when) import Data.List (any) import System.FilePath (()) @@ -33,7 +34,7 @@ import qualified Data.Aeson as JSON import Config import Input (readInputTree) -import Resource (buildGalleryTree, galleryCleanupResourceDir) +import Resource (GalleryItem, buildGalleryTree, galleryCleanupResourceDir) import Files ( FileName , FSNode(..) @@ -53,9 +54,6 @@ defaultGalleryConf = "gallery.yaml" indexFile :: String indexFile = "index.json" -viewerConfFile :: String -viewerConfFile = "viewer.json" - itemsDir :: String itemsDir = "items" @@ -63,6 +61,12 @@ thumbnailsDir :: String thumbnailsDir = "thumbnails" +data GalleryIndex = GalleryIndex + { properties :: ViewerConfig + , tree :: GalleryItem + } deriving (Generic, Show, ToJSON) + + writeJSON :: ToJSON a => FileName -> a -> IO () writeJSON outputPath object = do @@ -117,17 +121,13 @@ compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cle resources <- galleryBuilder inputTree when cleanOutput $ galleryCleanupResourceDir resources outputDirPath - writeJSON outputIndex resources - writeJSON outputViewerConf $ viewerConfig config + writeJSON (outputDirPath indexFile) $ GalleryIndex (viewerConfig config) resources where inputGalleryConf :: FilePath -> FilePath inputGalleryConf "" = inputDirPath defaultGalleryConf inputGalleryConf file = file - outputIndex = outputDirPath indexFile - outputViewerConf = outputDirPath viewerConfFile - itemProcessor config cache = itemFileProcessor (pictureMaxResolution config) cache -- cgit v1.2.3