aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Compiler.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Compiler.hs')
-rw-r--r--compiler/src/Compiler.hs18
1 files changed, 9 insertions, 9 deletions
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
22 ) where 22 ) where
23 23
24 24
25import GHC.Generics (Generic)
25import Control.Monad (liftM2, when) 26import Control.Monad (liftM2, when)
26import Data.List (any) 27import Data.List (any)
27import System.FilePath ((</>)) 28import System.FilePath ((</>))
@@ -33,7 +34,7 @@ import qualified Data.Aeson as JSON
33 34
34import Config 35import Config
35import Input (readInputTree) 36import Input (readInputTree)
36import Resource (buildGalleryTree, galleryCleanupResourceDir) 37import Resource (GalleryItem, buildGalleryTree, galleryCleanupResourceDir)
37import Files 38import Files
38 ( FileName 39 ( FileName
39 , FSNode(..) 40 , FSNode(..)
@@ -53,9 +54,6 @@ defaultGalleryConf = "gallery.yaml"
53indexFile :: String 54indexFile :: String
54indexFile = "index.json" 55indexFile = "index.json"
55 56
56viewerConfFile :: String
57viewerConfFile = "viewer.json"
58
59itemsDir :: String 57itemsDir :: String
60itemsDir = "items" 58itemsDir = "items"
61 59
@@ -63,6 +61,12 @@ thumbnailsDir :: String
63thumbnailsDir = "thumbnails" 61thumbnailsDir = "thumbnails"
64 62
65 63
64data GalleryIndex = GalleryIndex
65 { properties :: ViewerConfig
66 , tree :: GalleryItem
67 } deriving (Generic, Show, ToJSON)
68
69
66writeJSON :: ToJSON a => FileName -> a -> IO () 70writeJSON :: ToJSON a => FileName -> a -> IO ()
67writeJSON outputPath object = 71writeJSON outputPath object =
68 do 72 do
@@ -117,17 +121,13 @@ compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cle
117 resources <- galleryBuilder inputTree 121 resources <- galleryBuilder inputTree
118 122
119 when cleanOutput $ galleryCleanupResourceDir resources outputDirPath 123 when cleanOutput $ galleryCleanupResourceDir resources outputDirPath
120 writeJSON outputIndex resources 124 writeJSON (outputDirPath </> indexFile) $ GalleryIndex (viewerConfig config) resources
121 writeJSON outputViewerConf $ viewerConfig config
122 125
123 where 126 where
124 inputGalleryConf :: FilePath -> FilePath 127 inputGalleryConf :: FilePath -> FilePath
125 inputGalleryConf "" = inputDirPath </> defaultGalleryConf 128 inputGalleryConf "" = inputDirPath </> defaultGalleryConf
126 inputGalleryConf file = file 129 inputGalleryConf file = file
127 130
128 outputIndex = outputDirPath </> indexFile
129 outputViewerConf = outputDirPath </> viewerConfFile
130
131 itemProcessor config cache = 131 itemProcessor config cache =
132 itemFileProcessor 132 itemFileProcessor
133 (pictureMaxResolution config) cache 133 (pictureMaxResolution config) cache